mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:17:34 +00:00
Kernel: Use TRY() in sys$unveil()
This commit is contained in:
parent
36efecf3c3
commit
9a1fdb523f
1 changed files with 5 additions and 14 deletions
|
@ -45,21 +45,12 @@ KResultOr<FlatPtr> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params
|
||||||
if (params.permissions.length > 5)
|
if (params.permissions.length > 5)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
auto path_or_error = get_syscall_path_argument(params.path);
|
auto path = TRY(get_syscall_path_argument(params.path));
|
||||||
if (path_or_error.is_error())
|
|
||||||
return path_or_error.error();
|
|
||||||
auto& path = *path_or_error.value();
|
|
||||||
|
|
||||||
if (path.is_empty() || !path.view().starts_with('/'))
|
if (path->is_empty() || !path->view().starts_with('/'))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
OwnPtr<KString> permissions;
|
auto permissions = TRY(try_copy_kstring_from_user(params.permissions));
|
||||||
{
|
|
||||||
auto permissions_or_error = try_copy_kstring_from_user(params.permissions);
|
|
||||||
if (permissions_or_error.is_error())
|
|
||||||
return permissions_or_error.error();
|
|
||||||
permissions = permissions_or_error.release_value();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Let's work out permissions first...
|
// Let's work out permissions first...
|
||||||
unsigned new_permissions = 0;
|
unsigned new_permissions = 0;
|
||||||
|
@ -92,7 +83,7 @@ KResultOr<FlatPtr> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params
|
||||||
// If this case is encountered, the parent node of the path is returned and the custody of that inode is used instead.
|
// If this case is encountered, the parent node of the path is returned and the custody of that inode is used instead.
|
||||||
RefPtr<Custody> parent_custody; // Parent inode in case of ENOENT
|
RefPtr<Custody> parent_custody; // Parent inode in case of ENOENT
|
||||||
OwnPtr<KString> new_unveiled_path;
|
OwnPtr<KString> new_unveiled_path;
|
||||||
auto custody_or_error = VirtualFileSystem::the().resolve_path_without_veil(path.view(), VirtualFileSystem::the().root_custody(), &parent_custody);
|
auto custody_or_error = VirtualFileSystem::the().resolve_path_without_veil(path->view(), VirtualFileSystem::the().root_custody(), &parent_custody);
|
||||||
if (!custody_or_error.is_error()) {
|
if (!custody_or_error.is_error()) {
|
||||||
new_unveiled_path = custody_or_error.value()->try_create_absolute_path();
|
new_unveiled_path = custody_or_error.value()->try_create_absolute_path();
|
||||||
if (!new_unveiled_path)
|
if (!new_unveiled_path)
|
||||||
|
@ -101,7 +92,7 @@ KResultOr<FlatPtr> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params
|
||||||
auto parent_custody_path = parent_custody->try_create_absolute_path();
|
auto parent_custody_path = parent_custody->try_create_absolute_path();
|
||||||
if (!parent_custody_path)
|
if (!parent_custody_path)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
new_unveiled_path = KLexicalPath::try_join(parent_custody_path->view(), KLexicalPath::basename(path.view()));
|
new_unveiled_path = KLexicalPath::try_join(parent_custody_path->view(), KLexicalPath::basename(path->view()));
|
||||||
if (!new_unveiled_path)
|
if (!new_unveiled_path)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue