diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-12-29 03:33:22 -0800 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2021-12-29 05:54:04 -0800 |
commit | b5367bbf311487ae5d9a764cc6514586652d5680 (patch) | |
tree | 4e1863cfdfb8bd798a7a92158a2ae5eb4fc708a2 /Kernel/Syscalls | |
parent | 9d034785de89187f2722c444740e3333f4c23926 (diff) | |
download | serenity-b5367bbf311487ae5d9a764cc6514586652d5680.zip |
Kernel: Clarify why ftruncate() & pread() are passed `off_t const*`
I fell into this trap and tried to switch the syscalls to pass by
the `off_t` by register. I think it makes sense to add a clarifying
comment for future readers of the code, so they don't fall into the
same trap. :^)
Diffstat (limited to 'Kernel/Syscalls')
-rw-r--r-- | Kernel/Syscalls/ftruncate.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/read.cpp | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/Kernel/Syscalls/ftruncate.cpp b/Kernel/Syscalls/ftruncate.cpp index feaf027a99..f02af95b8a 100644 --- a/Kernel/Syscalls/ftruncate.cpp +++ b/Kernel/Syscalls/ftruncate.cpp @@ -9,6 +9,8 @@ namespace Kernel { +// NOTE: The length is passed by pointer because off_t is 64bit, +// hence it can't be passed by register on 32bit platforms. ErrorOr<FlatPtr> Process::sys$ftruncate(int fd, Userspace<off_t const*> userspace_length) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) diff --git a/Kernel/Syscalls/read.cpp b/Kernel/Syscalls/read.cpp index 2f9e21e98a..cd70a06e10 100644 --- a/Kernel/Syscalls/read.cpp +++ b/Kernel/Syscalls/read.cpp @@ -86,6 +86,8 @@ ErrorOr<FlatPtr> Process::sys$read(int fd, Userspace<u8*> buffer, size_t size) return TRY(description->read(user_buffer, size)); } +// NOTE: The offset is passed by pointer because off_t is 64bit, +// hence it can't be passed by register on 32bit platforms. ErrorOr<FlatPtr> Process::sys$pread(int fd, Userspace<u8*> buffer, size_t size, Userspace<off_t const*> userspace_offset) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) |