mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-23 04:55:15 +00:00
Parse out major/minor device from character and block device inodes.
This commit is contained in:
parent
03a0dc0103
commit
fa3b11ac64
Notes:
sideshowbarker
2024-07-19 18:48:30 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/fa3b11ac642
4 changed files with 21 additions and 1 deletions
|
@ -186,6 +186,12 @@ InodeMetadata Ext2FileSystem::inodeMetadata(InodeIdentifier inode) const
|
|||
metadata.ctime = e2inode->i_ctime;
|
||||
metadata.mtime = e2inode->i_mtime;
|
||||
metadata.dtime = e2inode->i_dtime;
|
||||
|
||||
if (isBlockDevice(e2inode->i_mode) || isCharacterDevice(e2inode->i_mode)) {
|
||||
unsigned dev = e2inode->i_block[0];
|
||||
metadata.majorDevice = (dev & 0xfff00) >> 8;
|
||||
metadata.minorDevice= (dev & 0xff) | ((dev >> 12) & 0xfff00);
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ struct InodeMetadata {
|
|||
time_t ctime { 0 };
|
||||
time_t mtime { 0 };
|
||||
time_t dtime { 0 };
|
||||
unsigned majorDevice { 0 };
|
||||
unsigned minorDevice { 0 };
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ VFS_OBJS = \
|
|||
DeviceBackedFileSystem.o \
|
||||
SyntheticFileSystem.o \
|
||||
InodeIdentifier.o \
|
||||
CharacterDevice.o \
|
||||
ZeroDevice.o \
|
||||
test.o
|
||||
|
||||
OBJS = $(AK_OBJS) $(VFS_OBJS)
|
||||
|
|
|
@ -199,6 +199,10 @@ void VirtualFileSystem::listDirectory(const String& path)
|
|||
nameColorBegin = "\033[42;30m";
|
||||
nameColorEnd = "\033[0m";
|
||||
}
|
||||
if (metadata.isCharacterDevice() || metadata.isBlockDevice()) {
|
||||
nameColorBegin = "\033[33;1m";
|
||||
nameColorEnd = "\033[0m";
|
||||
}
|
||||
printf("%02u:%08u ",
|
||||
metadata.inode.fileSystemID(),
|
||||
metadata.inode.index());
|
||||
|
@ -236,7 +240,13 @@ void VirtualFileSystem::listDirectory(const String& path)
|
|||
else
|
||||
printf("%c", metadata.mode & 00001 ? 'x' : '-');
|
||||
|
||||
printf("%12u ", metadata.size);
|
||||
if (metadata.isCharacterDevice() || metadata.isBlockDevice()) {
|
||||
char buf[16];
|
||||
sprintf(buf, "%u, %u", metadata.majorDevice, metadata.minorDevice);
|
||||
printf("%12s ", buf);
|
||||
} else {
|
||||
printf("%12u ", metadata.size);
|
||||
}
|
||||
|
||||
printf("\033[30;1m");
|
||||
auto tm = *localtime(&metadata.mtime);
|
||||
|
|
Loading…
Add table
Reference in a new issue