From e6f389a544a42d0042564d131a45c4b1d312ee00 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 6 Mar 2019 20:27:19 +0100 Subject: [PATCH] Kernel: Add two error checks for open() to return EISDIR or ENODEV. --- Kernel/VirtualFileSystem.cpp | 5 +++++ 1 file changed, 5 insertions(+) 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 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);