1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:47:34 +00:00

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.
This commit is contained in:
Andreas Kling 2019-01-31 05:05:57 +01:00
parent c3cc318028
commit c4fce9b3f9
8 changed files with 25 additions and 10 deletions

View file

@ -5,6 +5,7 @@
#include <string.h>
#include <getopt.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <AK/AKString.h>
#include <AK/Vector.h>
@ -150,7 +151,10 @@ int do_dir(const char* path)
printf(" %4u %4u", st.st_uid, st.st_gid);
printf(" %10u ", st.st_size);
if (S_ISCHR(st.st_mode))
printf(" %4u,%4u ", major(st.st_dev), minor(st.st_dev));
else
printf(" %10u ", st.st_size);
printf(" %10u ", st.st_mtime);