compat: generic compat get/settimeofday
PATCH 1/1 compat: generic compat get/settimeofday
Nothing arch specific in get/settimeofday. The details of the timeval conversion varied a little from arch to arch, but all with the same results.
Also add an extern declaration for sys_tz to linux/time.h because externs in .c files are fowned upon. I'll kill the externs in various other files in a sparate patch.
arch/powerpc/kernel/sys_ppc32.c +0 -63
@@ -71,69 +71,6 @@ asmlinkage long compat_sys_sysfs(u32 optreturn sys_sysfs ((int )option, arg1, arg2); } -static inline long get_ts32 (struct timespec *o,struct compat_timeval __user *i) -{ -long usec; - -if (!access_ok (VERIFY_READ , i,sizeof (*i))) -return -EFAULT ; -if (__get_user (o->tv_sec, &i->tv_sec)) -return -EFAULT ; -if (__get_user (usec, &i->tv_usec)) -return -EFAULT ; - o->tv_nsec = usec *1000 ; -return 0 ; -} - -static inline long put_tv32 (struct compat_timeval __user *o,struct timeval *i) -{ -return (!access_ok (VERIFY_WRITE , o,sizeof (*o)) || - (__put_user (i->tv_sec, &o->tv_sec) | -__put_user (i->tv_usec, &o->tv_usec))); -} - - - - -/* Translations due to time_t size differences. Which affects all -sorts of things, like timeval and itimerval. */ -extern struct timezone sys_tz; - -asmlinkage long compat_sys_gettimeofday (struct compat_timeval __user *tv,struct timezone __user *tz) -{ -if (tv) { -struct timeval ktv; -do_gettimeofday (&ktv); -if (put_tv32 (tv, &ktv)) -return -EFAULT ; - } -if (tz) { -if (copy_to_user (tz, &sys_tz,sizeof (sys_tz))) -return -EFAULT ; - } - -return 0 ; -} - - - -asmlinkage long compat_sys_settimeofday (struct compat_timeval __user *tv,struct timezone __user *tz) -{ -struct timespec kts; -struct timezone ktz; - -if (tv) { -if (get_ts32 (&kts, tv)) -return -EFAULT ; - } -if (tz) { -if (copy_from_user (&ktz, tz,sizeof (ktz))) -return -EFAULT ; - } - -return do_sys_settimeofday (tv ? &kts :NULL , tz ? &ktz :NULL ); -} -#ifdef CONFIG_SYSVIPC long compat_sys_ipc (u32 call,u32 first,u32 second,u32 third,compat_uptr_t ptr,u32 fifth)
kernel/compat.c +58 -0
64 lines not on this page · raw message
arch/s390/kernel/compat_linux.c +0 -67
79 lines not on this page · raw message
include/linux/time.h +2 -0
@@ -29,6 +29,8 @@ struct timezone {#ifdef __KERNEL__ +extern struct timezone sys_tz; +/* Parameters used to convert the timespec values: */ #define MSEC_PER_SEC 1000L#define USEC_PER_MSEC 1000L
arch/sparc64/kernel/sys_sparc32.c +0 -62
74 lines not on this page · raw message
arch/s390/kernel/compat_linux.h +0 -4
@@ -202,10 +202,6 @@ long sys32_execve(void);long sys32_init_module (void __user *umod,unsigned long len,const char __user *uargs);long sys32_delete_module (const char __user *name_user,unsigned int flags); -long sys32_gettimeofday (struct compat_timeval __user *tv, -struct timezone __user *tz); -long sys32_settimeofday (struct compat_timeval __user *tv, -struct timezone __user *tz);long sys32_pread64 (unsigned int fd,char __user *ubuf,size_t count,u32 poshi,u32 poslo); long sys32_pwrite64(unsigned int fd, const char __user *ubuf,
arch/sparc64/kernel/systbls.S +2 -2
@@ -41,8 +41,8 @@ sys_call_table32: /*100*/ .word sys32_getpriority, sys32_rt_sigreturn, sys32_rt_sigaction, sys32_rt_sigprocmask, sys32_rt_sigpending .word compat_sys_rt_sigtimedwait, sys32_rt_sigqueueinfo, compat_sys_rt_sigsuspend, sys_setresuid, sys_getresuid /*110*/ .word sys_setresgid, sys_getresgid, sys_setregid, sys_nis_syscall, sys_nis_syscall - .word sys32_getgroups, sys32_gettimeofday, sys32_getrusage, sys_nis_syscall, sys_getcwd -/*120*/ .word compat_sys_readv, compat_sys_writev, sys32_settimeofday, sys_fchown16, sys_fchmod + .word sys32_getgroups, compat_sys_gettimeofday, sys32_getrusage, sys_nis_syscall, sys_getcwd +/*120*/ .word compat_sys_readv, compat_sys_writev, compat_sys_settimeofday, sys_fchown16, sys_fchmod .word sys_nis_syscall, sys_setreuid16, sys_setregid16, sys_rename, sys_truncate /*130*/ .word sys_ftruncate, sys_flock, compat_sys_lstat64, sys_nis_syscall, sys_nis_syscall .word sys_nis_syscall, sys32_mkdir, sys_rmdir, compat_sys_utimes, compat_sys_stat64
arch/s390/kernel/syscalls.S +2 -2
@@ -86,8 +86,8 @@ SYSCALL(sys_sethostname,sys_sethostname, SYSCALL(sys_setrlimit,sys_setrlimit,compat_sys_setrlimit_wrapper) /* 75 */ SYSCALL(sys_old_getrlimit,sys_getrlimit,compat_sys_old_getrlimit_wrapper) SYSCALL(sys_getrusage,sys_getrusage,compat_sys_getrusage_wrapper) -SYSCALL(sys_gettimeofday,sys_gettimeofday,sys32_gettimeofday_wrapper) -SYSCALL(sys_settimeofday,sys_settimeofday,sys32_settimeofday_wrapper) +SYSCALL(sys_gettimeofday,sys_gettimeofday,compat_sys_gettimeofday_wrapper) +SYSCALL(sys_settimeofday,sys_settimeofday,compat_sys_settimeofday_wrapper) SYSCALL(sys_getgroups16,sys_ni_syscall,sys32_getgroups16_wrapper) /* 80 old getgroups16 syscall */ SYSCALL(sys_setgroups16,sys_ni_syscall,sys32_setgroups16_wrapper) /* old setgroups16 syscall */ NI_SYSCALL /* old select syscall */
arch/s390/kernel/compat_wrapper.S +6 -6
@@ -332,17 +332,17 @@ compat_sys_getrusage_wrapper: llgtr %r3,%r3 # struct rusage_emu31 * jg compat_sys_getrusage # branch to system call - .globl sys32_gettimeofday_wrapper -sys32_gettimeofday_wrapper: + .globl compat_sys_gettimeofday_wrapper +compat_sys_gettimeofday_wrapper: llgtr %r2,%r2 # struct timeval_emu31 * llgtr %r3,%r3 # struct timezone * - jg sys32_gettimeofday # branch to system call + jg compat_sys_gettimeofday # branch to system call - .globl sys32_settimeofday_wrapper -sys32_settimeofday_wrapper: + .globl compat_sys_settimeofday_wrapper +compat_sys_settimeofday_wrapper: llgtr %r2,%r2 # struct timeval_emu31 * llgtr %r3,%r3 # struct timezone * - jg sys32_settimeofday # branch to system call + jg compat_sys_settimeofday # branch to system call .globl sys32_getgroups16_wrapper sys32_getgroups16_wrapper:
arch/ia64/ia32/ia32_entry.S +2 -2
@@ -251,8 +251,8 @@ ia32_syscall_table: data8 compat_sys_setrlimit /* 75 */ data8 compat_sys_old_getrlimit data8 compat_sys_getrusage - data8 sys32_gettimeofday - data8 sys32_settimeofday + data8 compat_sys_gettimeofday + data8 compat_sys_settimeofday data8 sys32_getgroups16 /* 80 */ data8 sys32_setgroups16 data8 sys32_old_select
arch/ia64/ia32/sys_ia32.c +0 -56
68 lines not on this page · raw message
arch/parisc/kernel/sys_parisc32.c +0 -58
64 lines not on this page · raw message
arch/x86/ia32/ia32entry.S +2 -2
@@ -577,8 +577,8 @@ ia32_sys_call_table: .quad compat_sys_setrlimit /* 75 */ .quad compat_sys_old_getrlimit /* old_getrlimit */ .quad compat_sys_getrusage - .quad sys32_gettimeofday - .quad sys32_settimeofday + .quad compat_sys_gettimeofday + .quad compat_sys_settimeofday .quad sys_getgroups16 /* 80 */ .quad sys_setgroups16 .quad sys32_old_select
arch/x86/ia32/sys_ia32.c +0 -64
75 lines not on this page · raw message
arch/mips/kernel/linux32.c +0 -66
72 lines not on this page · raw message
arch/mips/kernel/scall64-n32.S +2 -2
@@ -214,7 +214,7 @@ EXPORT(sysn32_call_table) PTR sys_fchown PTR sys_lchown PTR sys_umask - PTR sys32_gettimeofday + PTR compat_sys_gettimeofday PTR compat_sys_getrlimit /* 6095 */ PTR compat_sys_getrusage PTR compat_sys_sysinfo
@@ -279,7 +279,7 @@ EXPORT(sysn32_call_table) PTR sys_chroot PTR sys_sync PTR sys_acct - PTR sys32_settimeofday + PTR compat_sys_settimeofday PTR compat_sys_mount /* 6160 */ PTR sys_umount PTR sys_swapon
arch/mips/kernel/scall64-o32.S +2 -2
@@ -283,8 +283,8 @@ sys_call_table: PTR compat_sys_setrlimit /* 4075 */ PTR compat_sys_getrlimit PTR compat_sys_getrusage - PTR sys32_gettimeofday - PTR sys32_settimeofday + PTR compat_sys_gettimeofday + PTR compat_sys_settimeofday PTR sys_getgroups /* 4080 */ PTR sys_setgroups PTR sys_ni_syscall /* old_select */
arch/parisc/kernel/syscall_table.S +2 -2
@@ -149,8 +149,8 @@ ENTRY_COMP(getrlimit) ENTRY_COMP(getrusage) /* struct timeval and timezone are maybe?? consistent wide and narrow */ - ENTRY_DIFF(gettimeofday) - ENTRY_DIFF(settimeofday) + ENTRY_COMP(gettimeofday) + ENTRY_COMP(settimeofday) ENTRY_SAME(getgroups) /* 80 */ ENTRY_SAME(setgroups) /* struct socketaddr... */
include/linux/compat.h +5 -0
@@ -234,6 +234,11 @@ extern int get_compat_itimerspec(structextern int put_compat_itimerspec (struct compat_itimerspec __user *dst,const struct itimerspec *src); +asmlinkage long compat_sys_gettimeofday (struct compat_timeval __user *tv, +struct timezone __user *tz); +asmlinkage long compat_sys_settimeofday (struct compat_timeval __user *tv, +struct timezone __user *tz); +asmlinkage long compat_sys_adjtimex (struct compat_timex __user *utp);extern int compat_printk (const char *fmt, ...);
Quoted 10 lines · Christoph Hellwig
Nothing arch specific in get/settimeofday. The details of the timeval conversion varied a little from arch to arch, but all with the same results.
Also add an extern declaration for
sys_tztolinux/time.hbecause externs in .c files are fowned upon. I'll kill the externs in various other files in a sparate patch.Signed-off-by Christoph Hellwig <[email protected]>
[ small nit: please include diffstats in future patches. ]
Quoted 2 lines
Index:
linux-2.6/arch/x86/ia32/ia32entry.S
Index:linux-2.6/arch/x86/ia32/sys_ia32.c
Ingo