X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=kitten%2Fkernel%2Flinux_syscalls%2Fgettimeofday.c;fp=kitten%2Fkernel%2Flinux_syscalls%2Fgettimeofday.c;h=064c00388b02fb5eb1287bf9bbbcd0ef9627b2c9;hb=66a1a4c7a9edcd7d8bc207aca093d694a6e6b5b2;hp=0000000000000000000000000000000000000000;hpb=f7cf9c19ecb0a589dd45ae0d2c91814bd3c2acc2;p=palacios.git diff --git a/kitten/kernel/linux_syscalls/gettimeofday.c b/kitten/kernel/linux_syscalls/gettimeofday.c new file mode 100644 index 0000000..064c003 --- /dev/null +++ b/kitten/kernel/linux_syscalls/gettimeofday.c @@ -0,0 +1,34 @@ +#include +#include +#include + +int +sys_gettimeofday( + struct timeval __user * tv, + struct timezone __user * tz +) +{ + struct timeval _tv; + struct timezone _tz; + + if (tv != NULL) { + uint64_t now = get_time(); /* nanoseconds */ + + _tv.tv_sec = now / NSEC_PER_SEC; + _tv.tv_usec = (now % NSEC_PER_SEC) / USEC_PER_NSEC; + + if (copy_to_user(tv, &_tv, sizeof(_tv))) + return -EFAULT; + } + + if (tz != NULL) { + _tz.tz_minuteswest = 0; + _tz.tz_dsttime = 0; + + if (copy_to_user(tz, &_tz, sizeof(_tz))) + return -EFAULT; + } + + return 0; +} +