1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:57:45 +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:
Andreas Kling 2021-03-19 10:43:58 +01:00
parent ed1789cc04
commit d48666489c
6 changed files with 37 additions and 24 deletions

View file

@ -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;
}
}