mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
Kernel: Plumb KResult through FileDescription::read_entire_file() implementation.
Allow file system implementation to return meaningful error codes to callers of the FileDescription::read_entire_file(). This allows both Process::sys$readlink() and Process::sys$module_load() to return more detailed errors to the user.
This commit is contained in:
parent
c459e4ecb2
commit
6a74af8063
14 changed files with 54 additions and 36 deletions
|
@ -1944,10 +1944,10 @@ int Process::sys$readlink(const Syscall::SC_readlink_params* user_params)
|
|||
return -EINVAL;
|
||||
|
||||
auto contents = description->read_entire_file();
|
||||
if (!contents)
|
||||
return -EIO; // FIXME: Get a more detailed error from VFS.
|
||||
if (!contents.is_error())
|
||||
return contents.error();
|
||||
|
||||
auto link_target = String::copy(contents);
|
||||
auto link_target = String::copy(contents.value());
|
||||
if (link_target.length() > params.buffer.size)
|
||||
return -ENAMETOOLONG;
|
||||
copy_to_user(params.buffer.data, link_target.characters(), link_target.length());
|
||||
|
@ -4444,7 +4444,11 @@ int Process::sys$module_load(const char* user_path, size_t path_length)
|
|||
if (description_or_error.is_error())
|
||||
return description_or_error.error();
|
||||
auto& description = description_or_error.value();
|
||||
auto payload = description->read_entire_file();
|
||||
auto payload_or_error = description->read_entire_file();
|
||||
if (payload_or_error.is_error())
|
||||
return payload_or_error.error();
|
||||
|
||||
auto payload = payload_or_error.value();
|
||||
auto storage = KBuffer::create_with_size(payload.size());
|
||||
memcpy(storage.data(), payload.data(), payload.size());
|
||||
payload.clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue