1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:37:44 +00:00

Kernel: Use Userspace<T> for the times syscall

This commit is contained in:
Brian Gianforcaro 2020-08-09 12:26:56 -07:00 committed by Andreas Kling
parent e7728ca8fd
commit 7943655838
2 changed files with 12 additions and 7 deletions

View file

@ -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);

View file

@ -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(&times->tms_utime, &m_ticks_in_user);
copy_to_user(&times->tms_stime, &m_ticks_in_kernel);
copy_to_user(&times->tms_cutime, &m_ticks_in_user_for_dead_children);
copy_to_user(&times->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, &times);
return g_uptime & 0x7fffffff;
}