diff options
author | Brian Gianforcaro <b.gianfo@gmail.com> | 2020-08-09 12:26:56 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-10 12:52:15 +0200 |
commit | 7943655838fc2c87897f630996299523cd46c018 (patch) | |
tree | b78f8f6e64b1ac714464becde43fb5ba98c23783 | |
parent | e7728ca8fdcf46debbda6495ab7e2a8742cf0b5a (diff) | |
download | serenity-7943655838fc2c87897f630996299523cd46c018.zip |
Kernel: Use Userspace<T> for the times syscall
-rw-r--r-- | Kernel/Process.h | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/times.cpp | 17 |
2 files changed, 12 insertions, 7 deletions
diff --git a/Kernel/Process.h b/Kernel/Process.h index 85bd6091b4..30d26037d9 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -278,7 +278,7 @@ public: int sys$fcntl(int fd, int cmd, u32 extra_arg); int sys$ioctl(int fd, unsigned request, FlatPtr arg); int sys$mkdir(Userspace<const char*> pathname, size_t path_length, mode_t mode); - clock_t sys$times(tms*); + clock_t sys$times(Userspace<tms*>); int sys$utime(Userspace<const char*> pathname, size_t path_length, Userspace<const struct utimbuf*>); int sys$link(Userspace<const Syscall::SC_link_params*>); int sys$unlink(const char* pathname, size_t path_length); diff --git a/Kernel/Syscalls/times.cpp b/Kernel/Syscalls/times.cpp index e72bedb9ac..61355595cf 100644 --- a/Kernel/Syscalls/times.cpp +++ b/Kernel/Syscalls/times.cpp @@ -28,15 +28,20 @@ namespace Kernel { -clock_t Process::sys$times(tms* times) +clock_t Process::sys$times(Userspace<tms*> user_times) { REQUIRE_PROMISE(stdio); - if (!validate_write_typed(times)) + if (!validate_write_typed(user_times)) return -EFAULT; - copy_to_user(×->tms_utime, &m_ticks_in_user); - copy_to_user(×->tms_stime, &m_ticks_in_kernel); - copy_to_user(×->tms_cutime, &m_ticks_in_user_for_dead_children); - copy_to_user(×->tms_cstime, &m_ticks_in_kernel_for_dead_children); + + tms times = {}; + times.tms_utime = m_ticks_in_user; + times.tms_stime = m_ticks_in_kernel; + times.tms_cutime = m_ticks_in_user_for_dead_children; + times.tms_cstime = m_ticks_in_kernel_for_dead_children; + + copy_to_user(user_times, ×); + return g_uptime & 0x7fffffff; } |