diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-02-16 00:47:20 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-02-16 00:47:20 +0100 |
commit | 994279d56c0186d7037c64473010718604d7e869 (patch) | |
tree | fd5140d08b8e33ad8ce455bd720c2cb5d41a553f /Kernel/VirtualFileSystem.cpp | |
parent | c6ca6522fc3f1ccb347b902713f6318e3d665ba6 (diff) | |
download | serenity-994279d56c0186d7037c64473010718604d7e869.zip |
Kernel: Add Device base class for CharacterDevice.
..to prepare for adding a BlockDevice class.
Diffstat (limited to 'Kernel/VirtualFileSystem.cpp')
-rw-r--r-- | Kernel/VirtualFileSystem.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Kernel/VirtualFileSystem.cpp b/Kernel/VirtualFileSystem.cpp index dcdbc52f8c..9254b4342a 100644 --- a/Kernel/VirtualFileSystem.cpp +++ b/Kernel/VirtualFileSystem.cpp @@ -122,7 +122,7 @@ void VFS::traverse_directory_inode(Inode& dir_inode, Function<bool(const FS::Dir }); } -RetainPtr<FileDescriptor> VFS::open(RetainPtr<CharacterDevice>&& device, int& error, int options) +RetainPtr<FileDescriptor> VFS::open(RetainPtr<Device>&& device, int& error, int options) { // FIXME: Respect options. (void) options; @@ -146,9 +146,9 @@ RetainPtr<FileDescriptor> VFS::open(const String& path, int& error, int options, return nullptr; auto metadata = inode->metadata(); if (!(options & O_DONT_OPEN_DEVICE) && metadata.is_character_device()) { - auto it = m_character_devices.find(encoded_device(metadata.major_device, metadata.minor_device)); - if (it == m_character_devices.end()) { - kprintf("VFS::open: no such character device %u,%u\n", metadata.major_device, metadata.minor_device); + auto it = m_devices.find(encoded_device(metadata.major_device, metadata.minor_device)); + if (it == m_devices.end()) { + kprintf("VFS::open: no such device %u,%u\n", metadata.major_device, metadata.minor_device); return nullptr; } auto descriptor = (*it).value->open(error, options); @@ -516,20 +516,20 @@ VFS::Mount::Mount(InodeIdentifier host, RetainPtr<FS>&& guest_fs) { } -void VFS::register_character_device(CharacterDevice& device) +void VFS::register_device(Device& device) { - m_character_devices.set(encoded_device(device.major(), device.minor()), &device); + m_devices.set(encoded_device(device.major(), device.minor()), &device); } -void VFS::unregister_character_device(CharacterDevice& device) +void VFS::unregister_device(Device& device) { - m_character_devices.remove(encoded_device(device.major(), device.minor())); + m_devices.remove(encoded_device(device.major(), device.minor())); } -CharacterDevice* VFS::get_device(unsigned major, unsigned minor) +Device* VFS::get_device(unsigned major, unsigned minor) { - auto it = m_character_devices.find(encoded_device(major, minor)); - if (it == m_character_devices.end()) + auto it = m_devices.find(encoded_device(major, minor)); + if (it == m_devices.end()) return nullptr; return (*it).value; } |