mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +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:
parent
f173f73f10
commit
cda2b9e71c
6 changed files with 21 additions and 33 deletions
|
@ -40,14 +40,10 @@ KResultOr<FlatPtr> Process::sys$getcwd(Userspace<char*> buffer, size_t size)
|
|||
if (size > NumericLimits<ssize_t>::max())
|
||||
return EINVAL;
|
||||
|
||||
auto maybe_path = current_directory().try_create_absolute_path();
|
||||
if (!maybe_path)
|
||||
return ENOMEM;
|
||||
auto& path = *maybe_path;
|
||||
|
||||
size_t ideal_size = path.length() + 1;
|
||||
auto path = TRY(current_directory().try_serialize_absolute_path());
|
||||
size_t ideal_size = path->length() + 1;
|
||||
auto size_to_copy = min(ideal_size, size);
|
||||
TRY(copy_to_user(buffer, path.characters(), size_to_copy));
|
||||
TRY(copy_to_user(buffer, path->characters(), size_to_copy));
|
||||
// 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