1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:47:46 +00:00

Kernel: Use custody_for_dirfd() in more syscalls

This simplifies a lot of syscalls, some of which were doing very
unnecessarily verbose things instead of calling this.
This commit is contained in:
Andreas Kling 2023-04-03 15:59:10 +02:00
parent f0c9c5e076
commit 97ac4601f5
6 changed files with 7 additions and 87 deletions

View file

@ -55,18 +55,7 @@ ErrorOr<FlatPtr> Process::sys$open(Userspace<Syscall::SC_open_params const*> use
dbgln_if(IO_DEBUG, "sys$open(dirfd={}, path='{}', options={}, mode={})", dirfd, path->view(), options, mode);
auto fd_allocation = TRY(allocate_fd());
RefPtr<Custody> base;
if (dirfd == AT_FDCWD) {
base = current_directory();
} else {
auto base_description = TRY(open_file_description(dirfd));
if (!base_description->is_directory())
return ENOTDIR;
if (!base_description->custody())
return EINVAL;
base = base_description->custody();
}
auto base = TRY(custody_for_dirfd(dirfd));
auto description = TRY(VirtualFileSystem::the().open(credentials(), path->view(), options, mode & ~umask(), *base));
if (description->inode() && description->inode()->bound_socket())