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
Notes: sideshowbarker 2024-07-19 15:54:41 +09:00
8 changed files with 25 additions and 10 deletions

View file

@ -360,7 +360,7 @@ InodeMetadata Ext2FSInode::metadata() const
if (isBlockDevice(m_raw_inode.i_mode) || isCharacterDevice(m_raw_inode.i_mode)) {
unsigned dev = m_raw_inode.i_block[0];
metadata.majorDevice = (dev & 0xfff00) >> 8;
metadata.minorDevice= (dev & 0xff) | ((dev >> 12) & 0xfff00);
metadata.minorDevice = (dev & 0xff) | ((dev >> 12) & 0xfff00);
}
return metadata;
}