Kernel: Add new syscall to allow changing the system date

This commit is contained in:
Liav A 2020-03-13 01:17:14 +02:00 committed by Andreas Kling
parent 4fcc10c6c3
commit 4484513b45
Notes: sideshowbarker 2024-07-19 08:14:22 +09:00
3 changed files with 19 additions and 0 deletions

View file

@ -4283,6 +4283,23 @@ int Process::sys$clock_gettime(clockid_t clock_id, timespec* user_ts)
return 0; return 0;
} }
int Process::sys$clock_settime(clockid_t clock_id, timespec* user_ts)
{
SmapDisabler disabler;
REQUIRE_PROMISE(stdio);
if (!validate_write_typed(user_ts))
return -EFAULT;
switch (clock_id) {
case CLOCK_REALTIME:
TimeManagement::the().set_epoch_time(user_ts->tv_sec);
break;
default:
return -EINVAL;
}
return 0;
}
int Process::sys$clock_nanosleep(const Syscall::SC_clock_nanosleep_params* user_params) int Process::sys$clock_nanosleep(const Syscall::SC_clock_nanosleep_params* user_params)
{ {
REQUIRE_PROMISE(stdio); REQUIRE_PROMISE(stdio);

View file

@ -213,6 +213,7 @@ public:
int sys$usleep(useconds_t usec); int sys$usleep(useconds_t usec);
int sys$gettimeofday(timeval*); int sys$gettimeofday(timeval*);
int sys$clock_gettime(clockid_t, timespec*); int sys$clock_gettime(clockid_t, timespec*);
int sys$clock_settime(clockid_t, timespec*);
int sys$clock_nanosleep(const Syscall::SC_clock_nanosleep_params*); int sys$clock_nanosleep(const Syscall::SC_clock_nanosleep_params*);
int sys$gethostname(char*, ssize_t); int sys$gethostname(char*, ssize_t);
int sys$uname(utsname*); int sys$uname(utsname*);

View file

@ -158,6 +158,7 @@ namespace Kernel {
__ENUMERATE_SYSCALL(getrandom) \ __ENUMERATE_SYSCALL(getrandom) \
__ENUMERATE_SYSCALL(setkeymap) \ __ENUMERATE_SYSCALL(setkeymap) \
__ENUMERATE_SYSCALL(clock_gettime) \ __ENUMERATE_SYSCALL(clock_gettime) \
__ENUMERATE_SYSCALL(clock_settime) \
__ENUMERATE_SYSCALL(clock_nanosleep) \ __ENUMERATE_SYSCALL(clock_nanosleep) \
__ENUMERATE_SYSCALL(join_thread) \ __ENUMERATE_SYSCALL(join_thread) \
__ENUMERATE_SYSCALL(module_load) \ __ENUMERATE_SYSCALL(module_load) \