mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Kernel: Use TRY() in sys$stat()
This commit is contained in:
parent
de2c1bc5c3
commit
7efa742a39
Notes:
sideshowbarker
2024-07-18 04:41:31 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7efa742a39e
1 changed files with 5 additions and 10 deletions
|
@ -29,9 +29,8 @@ KResultOr<FlatPtr> Process::sys$stat(Userspace<const Syscall::SC_stat_params*> u
|
||||||
REQUIRE_PROMISE(rpath);
|
REQUIRE_PROMISE(rpath);
|
||||||
auto params = TRY(copy_typed_from_user(user_params));
|
auto params = TRY(copy_typed_from_user(user_params));
|
||||||
|
|
||||||
auto path = get_syscall_path_argument(params.path);
|
auto path = TRY(get_syscall_path_argument(params.path));
|
||||||
if (path.is_error())
|
|
||||||
return path.error();
|
|
||||||
RefPtr<Custody> base;
|
RefPtr<Custody> base;
|
||||||
if (params.dirfd == AT_FDCWD) {
|
if (params.dirfd == AT_FDCWD) {
|
||||||
base = current_directory();
|
base = current_directory();
|
||||||
|
@ -45,13 +44,9 @@ KResultOr<FlatPtr> Process::sys$stat(Userspace<const Syscall::SC_stat_params*> u
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
base = base_description->custody();
|
base = base_description->custody();
|
||||||
}
|
}
|
||||||
auto metadata_or_error = VirtualFileSystem::the().lookup_metadata(path.value()->view(), *base, params.follow_symlinks ? 0 : O_NOFOLLOW_NOERROR);
|
auto metadata = TRY(VirtualFileSystem::the().lookup_metadata(path->view(), *base, params.follow_symlinks ? 0 : O_NOFOLLOW_NOERROR));
|
||||||
if (metadata_or_error.is_error())
|
stat statbuf = {};
|
||||||
return metadata_or_error.error();
|
TRY(metadata.stat(statbuf));
|
||||||
stat statbuf;
|
|
||||||
auto result = metadata_or_error.value().stat(statbuf);
|
|
||||||
if (result.is_error())
|
|
||||||
return result;
|
|
||||||
return copy_to_user(params.statbuf, &statbuf);
|
return copy_to_user(params.statbuf, &statbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue