summaryrefslogtreecommitdiff
path: root/LibC
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-01-31 05:05:57 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-01-31 05:05:57 +0100
commitc4fce9b3f91bd89a9031248fa4bcd7cf20dad91d (patch)
tree30a4324fc2836e68428f617bd5908c77960dceb6 /LibC
parentc3cc318028daf33383ea0466c18ea2a0f1ea980f (diff)
downloadserenity-c4fce9b3f91bd89a9031248fa4bcd7cf20dad91d.zip
Make stat() work on device files again.
FileDescriptor will now keep a pointer to the original inode even after opening it resolves to a character device. Fixed up /bin/ls to display major and minor device numbers instead of size for device files.
Diffstat (limited to 'LibC')
-rw-r--r--LibC/sys/stat.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/LibC/sys/stat.h b/LibC/sys/stat.h
index e5fc40e5e5..b1f6d860a7 100644
--- a/LibC/sys/stat.h
+++ b/LibC/sys/stat.h
@@ -9,4 +9,8 @@ mode_t umask(mode_t);
int chmod(const char* pathname, mode_t);
int mkdir(const char* pathname, mode_t);
+inline dev_t makedev(unsigned int major, unsigned int minor) { return (minor & 0xffu) | (major << 8u) | ((minor & ~0xffu) << 12u); }
+inline unsigned int major(dev_t dev) { return (dev & 0xfff00u) >> 8u; }
+inline unsigned int minor(dev_t dev) { return (dev & 0xffu) | ((dev >> 12u) & 0xfff00u); }
+
__END_DECLS