Welcome to The Fiwix Project
A UNIX-like kernel for the i386 architecture
1 /* 2 * fiwix/kernel/syscalls/settimeofday.c 3 * 4 * Copyright 2018, Jordi Sanfeliu. All rights reserved. 5 * Distributed under the terms of the Fiwix License. 6 */ 7 8 #include <fiwix/kernel.h> 9 #include <fiwix/fs.h> 10 #include <fiwix/time.h> 11 #include <fiwix/timer.h> 12 #include <fiwix/process.h> 13 #include <fiwix/errno.h> 14 15 #ifdef __DEBUG__ 16 #include <fiwix/stdio.h> 17 #endif /*__DEBUG__ */ 18 19 int sys_settimeofday(const struct timeval *tv, const struct timezone *tz) 20 { 21 int errno; 22 23 #ifdef __DEBUG__ 24 printk("(pid %d) sys_settimeofday()\n", current->pid); 25 #endif /*__DEBUG__ */ 26 27 if(!IS_SUPERUSER) { 28 return -EPERM; 29 } 30 31 if(tv) { 32 if((errno = check_user_area(VERIFY_READ, tv, sizeof(struct timeval)))) { 33 return errno; 34 } 35 CURRENT_TIME = tv->tv_sec; 36 set_system_time(CURRENT_TIME); 37 } 38 if(tz) { 39 if((errno = check_user_area(VERIFY_READ, tz, sizeof(struct timezone)))) { 40 return errno; 41 } 42 kstat.tz_minuteswest = tz->tz_minuteswest; 43 kstat.tz_dsttime = tz->tz_dsttime; 44 } 45 return 0; 46 }