diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-06 20:27:19 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-06 20:27:19 +0100 |
commit | e6f389a544a42d0042564d131a45c4b1d312ee00 (patch) | |
tree | 476c00f53f378c3d4bfbdbff1869fa2a608a3823 /Kernel | |
parent | 7d463756900ad989455e94ec6e1082e830f582cf (diff) | |
download | serenity-e6f389a544a42d0042564d131a45c4b1d312ee00.zip |
Kernel: Add two error checks for open() to return EISDIR or ENODEV.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/VirtualFileSystem.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Kernel/VirtualFileSystem.cpp b/Kernel/VirtualFileSystem.cpp index 9465699319..801b207809 100644 --- a/Kernel/VirtualFileSystem.cpp +++ b/Kernel/VirtualFileSystem.cpp @@ -189,12 +189,17 @@ RetainPtr<FileDescriptor> VFS::open(const String& path, int& error, int options, error = -EACCES; return nullptr; } + if (metadata.is_directory()) { + error = -EISDIR; + return nullptr; + } } if (metadata.is_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); + error = -ENODEV; return nullptr; } auto descriptor = (*it).value->open(error, options); |