1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 18:15:07 +00:00

Kernel: Make VFS::create() fail with EINVAL on invalid file mode

Instead of trying to fix up the mode to look like a regular file,
just fail instead.
This commit is contained in:
Andreas Kling 2021-01-23 16:42:50 +01:00
parent bfb254ed14
commit ca3489eec7

View file

@ -389,10 +389,8 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int optio
if (result.is_error())
return result;
if (!is_socket(mode) && !is_fifo(mode) && !is_block_device(mode) && !is_character_device(mode)) {
// Turn it into a regular file. (This feels rather hackish.)
mode |= 0100000;
}
if (!is_regular_file(mode) && !is_socket(mode) && !is_fifo(mode) && !is_block_device(mode) && !is_character_device(mode))
return EINVAL;
auto& parent_inode = parent_custody.inode();
auto current_process = Process::current();