1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

Kernel: Improvements to Custody absolute path serialization

- Renamed try_create_absolute_path() => try_serialize_absolute_path()
- Use KResultOr and TRY() to propagate errors
- Don't call this when it's only for debug logging
This commit is contained in:
Andreas Kling 2021-09-06 12:24:36 +02:00
parent f173f73f10
commit cda2b9e71c
6 changed files with 21 additions and 33 deletions

View file

@ -83,13 +83,9 @@ KResultOr<FlatPtr> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params
OwnPtr<KString> new_unveiled_path;
auto custody_or_error = VirtualFileSystem::the().resolve_path_without_veil(path->view(), VirtualFileSystem::the().root_custody(), &parent_custody);
if (!custody_or_error.is_error()) {
new_unveiled_path = custody_or_error.value()->try_create_absolute_path();
if (!new_unveiled_path)
return ENOMEM;
new_unveiled_path = TRY(custody_or_error.value()->try_serialize_absolute_path());
} else if (custody_or_error.error() == ENOENT && parent_custody && (new_permissions & UnveilAccess::CreateOrRemove)) {
auto parent_custody_path = parent_custody->try_create_absolute_path();
if (!parent_custody_path)
return ENOMEM;
auto parent_custody_path = TRY(parent_custody->try_serialize_absolute_path());
new_unveiled_path = KLexicalPath::try_join(parent_custody_path->view(), KLexicalPath::basename(path->view()));
if (!new_unveiled_path)
return ENOMEM;