mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +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:
parent
f0c9c5e076
commit
97ac4601f5
6 changed files with 7 additions and 87 deletions
|
@ -28,18 +28,7 @@ ErrorOr<FlatPtr> Process::sys$stat(Userspace<Syscall::SC_stat_params const*> use
|
|||
auto params = TRY(copy_typed_from_user(user_params));
|
||||
|
||||
auto path = TRY(get_syscall_path_argument(params.path));
|
||||
|
||||
RefPtr<Custody> base;
|
||||
if (params.dirfd == AT_FDCWD) {
|
||||
base = current_directory();
|
||||
} else {
|
||||
auto base_description = TRY(open_file_description(params.dirfd));
|
||||
if (!base_description->is_directory())
|
||||
return ENOTDIR;
|
||||
if (!base_description->custody())
|
||||
return EINVAL;
|
||||
base = base_description->custody();
|
||||
}
|
||||
auto base = TRY(custody_for_dirfd(params.dirfd));
|
||||
auto metadata = TRY(VirtualFileSystem::the().lookup_metadata(credentials(), path->view(), *base, params.follow_symlinks ? 0 : O_NOFOLLOW_NOERROR));
|
||||
auto statbuf = TRY(metadata.stat());
|
||||
TRY(copy_to_user(params.statbuf, &statbuf));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue