summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/read.cpp
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-11-13 09:28:56 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-13 10:04:46 +0100
commit648a139af36d6803fbe0674d4c6d461f46564e84 (patch)
treea95ada45370fb0d2eb7ad64a3309b43d69709646 /Kernel/Syscalls/read.cpp
parent7f8dc395c10d43c8fff91812834ac8c6db4247a6 (diff)
downloadserenity-648a139af36d6803fbe0674d4c6d461f46564e84.zip
Kernel+LibC: Pass off_t to pread() via a pointer
`off_t` is a 64-bit signed integer, so passing it in a register on i686 is not the best idea. This fix gets us one step closer to making the LLVM port work.
Diffstat (limited to 'Kernel/Syscalls/read.cpp')
-rw-r--r--Kernel/Syscalls/read.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/Kernel/Syscalls/read.cpp b/Kernel/Syscalls/read.cpp
index 4dc7b0d15a..a001285925 100644
--- a/Kernel/Syscalls/read.cpp
+++ b/Kernel/Syscalls/read.cpp
@@ -90,7 +90,7 @@ ErrorOr<FlatPtr> Process::sys$read(int fd, Userspace<u8*> buffer, size_t size)
return TRY(description->read(user_buffer.value(), size));
}
-ErrorOr<FlatPtr> Process::sys$pread(int fd, Userspace<u8*> buffer, size_t size, off_t offset)
+ErrorOr<FlatPtr> Process::sys$pread(int fd, Userspace<u8*> buffer, size_t size, Userspace<off_t*> userspace_offset)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
REQUIRE_PROMISE(stdio);
@@ -98,6 +98,8 @@ ErrorOr<FlatPtr> Process::sys$pread(int fd, Userspace<u8*> buffer, size_t size,
return 0;
if (size > NumericLimits<ssize_t>::max())
return EINVAL;
+ off_t offset;
+ TRY(copy_from_user(&offset, userspace_offset));
if (offset < 0)
return EINVAL;
dbgln_if(IO_DEBUG, "sys$pread({}, {}, {}, {})", fd, buffer.ptr(), size, offset);