diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-05 17:58:08 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-05 17:58:08 +0200 |
commit | 7efa742a39e9646a0e88ad55b0c401c46ff0c458 (patch) | |
tree | e37b8378e4642959a311a78b450884aeb2f839fc /Kernel | |
parent | de2c1bc5c31e7cf408e614e4d1a4ae5e4d37c8a3 (diff) | |
download | serenity-7efa742a39e9646a0e88ad55b0c401c46ff0c458.zip |
Kernel: Use TRY() in sys$stat()
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Syscalls/stat.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/Kernel/Syscalls/stat.cpp b/Kernel/Syscalls/stat.cpp index 262f5bc22e..dc601d9f08 100644 --- a/Kernel/Syscalls/stat.cpp +++ b/Kernel/Syscalls/stat.cpp @@ -29,9 +29,8 @@ KResultOr<FlatPtr> Process::sys$stat(Userspace<const Syscall::SC_stat_params*> u REQUIRE_PROMISE(rpath); auto params = TRY(copy_typed_from_user(user_params)); - auto path = get_syscall_path_argument(params.path); - if (path.is_error()) - return path.error(); + auto path = TRY(get_syscall_path_argument(params.path)); + RefPtr<Custody> base; if (params.dirfd == AT_FDCWD) { base = current_directory(); @@ -45,13 +44,9 @@ KResultOr<FlatPtr> Process::sys$stat(Userspace<const Syscall::SC_stat_params*> u return EINVAL; base = base_description->custody(); } - auto metadata_or_error = VirtualFileSystem::the().lookup_metadata(path.value()->view(), *base, params.follow_symlinks ? 0 : O_NOFOLLOW_NOERROR); - if (metadata_or_error.is_error()) - return metadata_or_error.error(); - stat statbuf; - auto result = metadata_or_error.value().stat(statbuf); - if (result.is_error()) - return result; + auto metadata = TRY(VirtualFileSystem::the().lookup_metadata(path->view(), *base, params.follow_symlinks ? 0 : O_NOFOLLOW_NOERROR)); + stat statbuf = {}; + TRY(metadata.stat(statbuf)); return copy_to_user(params.statbuf, &statbuf); } |