mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +00:00
Kernel: Custody::absolute_path() => try_create_absolute_path()
This converts most users of Custody::absolute_path() to use the new try_create_absolute_path() API, and return ENOMEM if the KString allocation fails.
This commit is contained in:
parent
0f8a6e574c
commit
d5722eab36
4 changed files with 32 additions and 15 deletions
|
@ -27,11 +27,13 @@ KResultOr<FlatPtr> Process::sys$realpath(Userspace<const Syscall::SC_realpath_pa
|
|||
if (custody_or_error.is_error())
|
||||
return custody_or_error.error();
|
||||
auto& custody = custody_or_error.value();
|
||||
auto absolute_path = custody->absolute_path();
|
||||
auto absolute_path = custody->try_create_absolute_path();
|
||||
if (!absolute_path)
|
||||
return ENOMEM;
|
||||
|
||||
size_t ideal_size = absolute_path.length() + 1;
|
||||
size_t ideal_size = absolute_path->length() + 1;
|
||||
auto size_to_copy = min(ideal_size, params.buffer.size);
|
||||
if (!copy_to_user(params.buffer.data, absolute_path.characters(), size_to_copy))
|
||||
if (!copy_to_user(params.buffer.data, absolute_path->characters(), size_to_copy))
|
||||
return EFAULT;
|
||||
// Note: we return the whole size here, not the copied size.
|
||||
return ideal_size;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue