mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:17:44 +00:00
Parse out major/minor device from character and block device inodes.
This commit is contained in:
parent
03a0dc0103
commit
fa3b11ac64
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.ctime = e2inode->i_ctime;
|
||||||
metadata.mtime = e2inode->i_mtime;
|
metadata.mtime = e2inode->i_mtime;
|
||||||
metadata.dtime = e2inode->i_dtime;
|
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;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@ struct InodeMetadata {
|
||||||
time_t ctime { 0 };
|
time_t ctime { 0 };
|
||||||
time_t mtime { 0 };
|
time_t mtime { 0 };
|
||||||
time_t dtime { 0 };
|
time_t dtime { 0 };
|
||||||
|
unsigned majorDevice { 0 };
|
||||||
|
unsigned minorDevice { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ VFS_OBJS = \
|
||||||
DeviceBackedFileSystem.o \
|
DeviceBackedFileSystem.o \
|
||||||
SyntheticFileSystem.o \
|
SyntheticFileSystem.o \
|
||||||
InodeIdentifier.o \
|
InodeIdentifier.o \
|
||||||
|
CharacterDevice.o \
|
||||||
|
ZeroDevice.o \
|
||||||
test.o
|
test.o
|
||||||
|
|
||||||
OBJS = $(AK_OBJS) $(VFS_OBJS)
|
OBJS = $(AK_OBJS) $(VFS_OBJS)
|
||||||
|
|
|
@ -199,6 +199,10 @@ void VirtualFileSystem::listDirectory(const String& path)
|
||||||
nameColorBegin = "\033[42;30m";
|
nameColorBegin = "\033[42;30m";
|
||||||
nameColorEnd = "\033[0m";
|
nameColorEnd = "\033[0m";
|
||||||
}
|
}
|
||||||
|
if (metadata.isCharacterDevice() || metadata.isBlockDevice()) {
|
||||||
|
nameColorBegin = "\033[33;1m";
|
||||||
|
nameColorEnd = "\033[0m";
|
||||||
|
}
|
||||||
printf("%02u:%08u ",
|
printf("%02u:%08u ",
|
||||||
metadata.inode.fileSystemID(),
|
metadata.inode.fileSystemID(),
|
||||||
metadata.inode.index());
|
metadata.inode.index());
|
||||||
|
@ -236,7 +240,13 @@ void VirtualFileSystem::listDirectory(const String& path)
|
||||||
else
|
else
|
||||||
printf("%c", metadata.mode & 00001 ? 'x' : '-');
|
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");
|
printf("\033[30;1m");
|
||||||
auto tm = *localtime(&metadata.mtime);
|
auto tm = *localtime(&metadata.mtime);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue