mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:27:35 +00:00
Kernel: Make FileDescription::seek() return KResultOr<off_t>
This exposed a bunch of places where errors were not propagated, so this patch is forced to deal with them as well.
This commit is contained in:
parent
ed1789cc04
commit
d48666489c
6 changed files with 37 additions and 24 deletions
|
@ -559,7 +559,8 @@ KResult Process::do_exec(NonnullRefPtr<FileDescription> main_program_description
|
|||
if (interpreter_description) {
|
||||
main_program_fd = alloc_fd();
|
||||
VERIFY(main_program_fd >= 0);
|
||||
main_program_description->seek(0, SEEK_SET);
|
||||
auto seek_result = main_program_description->seek(0, SEEK_SET);
|
||||
VERIFY(!seek_result.is_error());
|
||||
main_program_description->set_readable(true);
|
||||
m_fds[main_program_fd].set(move(main_program_description), FD_CLOEXEC);
|
||||
}
|
||||
|
|
|
@ -38,13 +38,12 @@ KResultOr<int> Process::sys$lseek(int fd, Userspace<off_t*> userspace_offset, in
|
|||
off_t offset;
|
||||
if (!copy_from_user(&offset, userspace_offset))
|
||||
return EFAULT;
|
||||
offset = description->seek(offset, whence);
|
||||
if (!copy_to_user(userspace_offset, &offset))
|
||||
auto seek_result = description->seek(offset, whence);
|
||||
if (seek_result.is_error())
|
||||
return seek_result.error();
|
||||
if (!copy_to_user(userspace_offset, &seek_result.value()))
|
||||
return EFAULT;
|
||||
if (offset < 0)
|
||||
return offset;
|
||||
else
|
||||
return 0;
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -84,8 +84,11 @@ KResultOr<ssize_t> Process::do_write(FileDescription& description, const UserOrK
|
|||
return EAGAIN;
|
||||
}
|
||||
|
||||
if (description.should_append())
|
||||
description.seek(0, SEEK_END);
|
||||
if (description.should_append()) {
|
||||
auto seek_result = description.seek(0, SEEK_END);
|
||||
if (seek_result.is_error())
|
||||
return seek_result.error();
|
||||
}
|
||||
|
||||
while ((size_t)total_nwritten < data_size) {
|
||||
if (!description.can_write()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue