mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-04 17:33:04 +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:
parent
c3cc318028
commit
c4fce9b3f9
Notes:
sideshowbarker
2024-07-19 15:54:41 +09:00
Author: https://github.com/awesomekling
Commit: c4fce9b3f9
8 changed files with 25 additions and 10 deletions
|
@ -146,13 +146,15 @@ RetainPtr<FileDescriptor> VFS::open(const String& path, int& error, int options,
|
|||
return nullptr;
|
||||
}
|
||||
auto metadata = inode->metadata();
|
||||
if (metadata.isCharacterDevice()) {
|
||||
if (!(options & O_DONT_OPEN_DEVICE) && metadata.isCharacterDevice()) {
|
||||
auto it = m_character_devices.find(encodedDevice(metadata.majorDevice, metadata.minorDevice));
|
||||
if (it == m_character_devices.end()) {
|
||||
kprintf("VFS::open: no such character device %u,%u\n", metadata.majorDevice, metadata.minorDevice);
|
||||
return nullptr;
|
||||
}
|
||||
return (*it).value->open(error, options);
|
||||
auto descriptor = (*it).value->open(error, options);
|
||||
descriptor->set_original_inode(Badge<VFS>(), move(inode));
|
||||
return descriptor;
|
||||
}
|
||||
return FileDescriptor::create(move(inode));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue