mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-01 15:43:36 +03:00
Kernel: Handle O_DIRECTORY in VFS::open() instead of in each syscall
Just taking care of some FIXMEs.
This commit is contained in:
parent
05653a9189
commit
15f3abc849
Notes:
sideshowbarker
2024-07-19 10:24:29 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/15f3abc8490
@ -205,6 +205,9 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::open(StringView path, int options
|
|||||||
auto& inode = custody.inode();
|
auto& inode = custody.inode();
|
||||||
auto metadata = inode.metadata();
|
auto metadata = inode.metadata();
|
||||||
|
|
||||||
|
if ((options & O_DIRECTORY) && !metadata.is_directory())
|
||||||
|
return KResult(-ENOTDIR);
|
||||||
|
|
||||||
bool should_truncate_file = false;
|
bool should_truncate_file = false;
|
||||||
|
|
||||||
// NOTE: Read permission is a bit weird, since O_RDONLY == 0,
|
// NOTE: Read permission is a bit weird, since O_RDONLY == 0,
|
||||||
|
@ -1589,8 +1589,6 @@ int Process::sys$open(const Syscall::SC_open_params* params)
|
|||||||
if (result.is_error())
|
if (result.is_error())
|
||||||
return result.error();
|
return result.error();
|
||||||
auto description = result.value();
|
auto description = result.value();
|
||||||
if (options & O_DIRECTORY && !description->is_directory())
|
|
||||||
return -ENOTDIR; // FIXME: This should be handled by VFS::open.
|
|
||||||
description->set_file_flags(options);
|
description->set_file_flags(options);
|
||||||
u32 fd_flags = (options & O_CLOEXEC) ? FD_CLOEXEC : 0;
|
u32 fd_flags = (options & O_CLOEXEC) ? FD_CLOEXEC : 0;
|
||||||
m_fds[fd].set(move(description), fd_flags);
|
m_fds[fd].set(move(description), fd_flags);
|
||||||
@ -1629,8 +1627,6 @@ int Process::sys$openat(const Syscall::SC_openat_params* params)
|
|||||||
if (result.is_error())
|
if (result.is_error())
|
||||||
return result.error();
|
return result.error();
|
||||||
auto description = result.value();
|
auto description = result.value();
|
||||||
if (options & O_DIRECTORY && !description->is_directory())
|
|
||||||
return -ENOTDIR; // FIXME: This should be handled by VFS::open.
|
|
||||||
description->set_file_flags(options);
|
description->set_file_flags(options);
|
||||||
u32 fd_flags = (options & O_CLOEXEC) ? FD_CLOEXEC : 0;
|
u32 fd_flags = (options & O_CLOEXEC) ? FD_CLOEXEC : 0;
|
||||||
m_fds[fd].set(move(description), fd_flags);
|
m_fds[fd].set(move(description), fd_flags);
|
||||||
|
Loading…
Reference in New Issue
Block a user