Kernel: Make sys${ftruncate,pread} take off_t as const pointer

These syscalls don't write back to the off_t value (unlike sys$lseek)
so let's take Userspace<off_t const*> instead of Userspace<off_t*>.
This commit is contained in:
Andreas Kling 2021-12-17 08:34:27 +01:00
commit 39d9337db5
Notes: sideshowbarker 2024-07-17 22:40:15 +09:00
3 changed files with 6 additions and 8 deletions

View file

@ -9,12 +9,11 @@
namespace Kernel {
ErrorOr<FlatPtr> Process::sys$ftruncate(int fd, Userspace<off_t*> userspace_length)
ErrorOr<FlatPtr> Process::sys$ftruncate(int fd, Userspace<off_t const*> userspace_length)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
REQUIRE_PROMISE(stdio);
off_t length;
TRY(copy_from_user(&length, userspace_length));
auto length = TRY(copy_typed_from_user(userspace_length));
if (length < 0)
return EINVAL;
auto description = TRY(fds().open_file_description(fd));