diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-31 17:24:54 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-31 17:24:54 +0200 |
commit | ecb1b93d53864646550ccecf7fc5ecf37391b6ae (patch) | |
tree | 22b741285ffc867ad2842be1a29a4c5522a546ca /Kernel | |
parent | 6b5fbad2503be27bcc52de1ecdfa6c8e8d7a3eb9 (diff) | |
download | serenity-ecb1b93d53864646550ccecf7fc5ecf37391b6ae.zip |
Ext2FS: Fix fetching of the major/minor device numbers for st_rdev.
This is how it seems to work:
- If ext2_inode.i_blocks[0] is non-zero, it contains the major/minor.
- Otherwise, it's in ext2_inode.i_blocks[1].
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/FileSystem/Ext2FileSystem.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 7bf28a1886..b23b76c0aa 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -422,13 +422,10 @@ InodeMetadata Ext2FSInode::metadata() const metadata.block_size = fs().block_size(); metadata.block_count = m_raw_inode.i_blocks; - if (::is_character_device(m_raw_inode.i_mode)) { + if (::is_character_device(m_raw_inode.i_mode) || ::is_block_device(m_raw_inode.i_mode)) { unsigned dev = m_raw_inode.i_block[0]; - metadata.major_device = (dev & 0xfff00) >> 8; - metadata.minor_device = (dev & 0xff) | ((dev >> 12) & 0xfff00); - } - if (::is_block_device(m_raw_inode.i_mode)) { - unsigned dev = m_raw_inode.i_block[1]; + if (!dev) + dev = m_raw_inode.i_block[1]; metadata.major_device = (dev & 0xfff00) >> 8; metadata.minor_device = (dev & 0xff) | ((dev >> 12) & 0xfff00); } |