1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:18:14 +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

@ -19,15 +19,7 @@ ErrorOr<FlatPtr> Process::sys$unlink(int dirfd, Userspace<char const*> user_path
if (flags & ~AT_REMOVEDIR)
return Error::from_errno(EINVAL);
RefPtr<Custody> base;
if (dirfd == AT_FDCWD) {
base = current_directory();
} else {
auto base_description = TRY(open_file_description(dirfd));
if (!base_description->custody())
return Error::from_errno(EINVAL);
base = base_description->custody();
}
auto base = TRY(custody_for_dirfd(dirfd));
if (flags & AT_REMOVEDIR)
TRY(VirtualFileSystem::the().rmdir(credentials(), path->view(), *base));