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 pathname, size_t path_length, mode_t mode); - clock_t sys$times(tms*); + clock_t sys$times(Userspace); int sys$utime(Userspace pathname, size_t path_length, Userspace); int sys$link(Userspace); 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 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; }