mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +00:00
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.
This commit is contained in:
parent
9af1e1a3bf
commit
ac71775de5
70 changed files with 747 additions and 742 deletions
|
@ -31,13 +31,13 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
int Process::sys$readlink(Userspace<const Syscall::SC_readlink_params*> user_params)
|
||||
KResultOr<int> Process::sys$readlink(Userspace<const Syscall::SC_readlink_params*> user_params)
|
||||
{
|
||||
REQUIRE_PROMISE(rpath);
|
||||
|
||||
Syscall::SC_readlink_params params;
|
||||
if (!copy_from_user(¶ms, user_params))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
|
||||
auto path = get_syscall_path_argument(params.path);
|
||||
if (path.is_error())
|
||||
|
@ -49,7 +49,7 @@ int Process::sys$readlink(Userspace<const Syscall::SC_readlink_params*> user_par
|
|||
auto description = result.value();
|
||||
|
||||
if (!description->metadata().is_symlink())
|
||||
return -EINVAL;
|
||||
return EINVAL;
|
||||
|
||||
auto contents = description->read_entire_file();
|
||||
if (contents.is_error())
|
||||
|
@ -58,7 +58,7 @@ int Process::sys$readlink(Userspace<const Syscall::SC_readlink_params*> user_par
|
|||
auto& link_target = *contents.value();
|
||||
auto size_to_copy = min(link_target.size(), params.buffer.size);
|
||||
if (!copy_to_user(params.buffer.data, link_target.data(), size_to_copy))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
// Note: we return the whole size here, not the copied size.
|
||||
return link_target.size();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue