diff options
author | Andreas Kling <kling@serenityos.org> | 2021-03-01 13:49:16 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-01 13:54:32 +0100 |
commit | ac71775de5a71945e004f46b184dde4f628d112b (patch) | |
tree | bac755ef16ba74bd63d3a359e6aad9e32d2734ae /Kernel/Syscalls/unveil.cpp | |
parent | 9af1e1a3bf43140dee327eb4f553c56ba95ad9d9 (diff) | |
download | serenity-ac71775de5a71945e004f46b184dde4f628d112b.zip |
Kernel: Make all syscall functions return KResultOr<T>
This makes it a lot easier to return errors since we no longer have to
worry about negating EFOO errors and can just return them flat.
Diffstat (limited to 'Kernel/Syscalls/unveil.cpp')
-rw-r--r-- | Kernel/Syscalls/unveil.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Kernel/Syscalls/unveil.cpp b/Kernel/Syscalls/unveil.cpp index 20a91edb69..cec3b63394 100644 --- a/Kernel/Syscalls/unveil.cpp +++ b/Kernel/Syscalls/unveil.cpp @@ -32,11 +32,11 @@ namespace Kernel { -int Process::sys$unveil(Userspace<const Syscall::SC_unveil_params*> user_params) +KResultOr<int> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params*> user_params) { Syscall::SC_unveil_params params; if (!copy_from_user(¶ms, user_params)) - return -EFAULT; + return EFAULT; if (!params.path.characters && !params.permissions.characters) { m_veil_state = VeilState::Locked; @@ -44,24 +44,24 @@ int Process::sys$unveil(Userspace<const Syscall::SC_unveil_params*> user_params) } if (m_veil_state == VeilState::Locked) - return -EPERM; + return EPERM; if (!params.path.characters || !params.permissions.characters) - return -EINVAL; + return EINVAL; if (params.permissions.length > 5) - return -EINVAL; + return EINVAL; auto path = get_syscall_path_argument(params.path); if (path.is_error()) return path.error(); if (path.value().is_empty() || path.value().characters()[0] != '/') - return -EINVAL; + return EINVAL; auto permissions = copy_string_from_user(params.permissions); if (permissions.is_null()) - return -EFAULT; + return EFAULT; // Let's work out permissions first... unsigned new_permissions = 0; @@ -83,7 +83,7 @@ int Process::sys$unveil(Userspace<const Syscall::SC_unveil_params*> user_params) new_permissions |= UnveilAccess::Browse; break; default: - return -EINVAL; + return EINVAL; } } @@ -114,7 +114,7 @@ int Process::sys$unveil(Userspace<const Syscall::SC_unveil_params*> user_params) // as that would be the first time this path is unveiled. if (old_permissions != UnveilAccess::None || !matching_node.permissions_inherited_from_root()) { if (new_permissions & ~old_permissions) - return -EPERM; + return EPERM; } matching_node.set_metadata({ matching_node.path(), (UnveilAccess)new_permissions, true, false }); return 0; |