diff options
author | Christoph Hellwig <hch@lst.de> | 2008-10-16 01:02:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-16 14:21:33 -0400 |
commit | b418da16dd44810e5d5a22bba377cca80512a524 (patch) | |
tree | 20ac32ea027bb8d978a22fbfaf6580fd34518aa5 /arch/x86/ia32 | |
parent | f7a5000f7a8924e9c5fad1801616601d6dc65a17 (diff) |
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.
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: David S. Miller <davem@davemloft.net> [ sparc bits ]
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Acked-by: Kyle McMartin <kyle@mcmartin.ca>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Grant Grundler <grundler@parisc-linux.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86/ia32')
-rw-r--r-- | arch/x86/ia32/ia32entry.S | 4 | ||||
-rw-r--r-- | arch/x86/ia32/sys_ia32.c | 64 |
2 files changed, 2 insertions, 66 deletions
diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S index eb4314768bf7..256b00b61892 100644 --- a/arch/x86/ia32/ia32entry.S +++ b/arch/x86/ia32/ia32entry.S | |||
@@ -571,8 +571,8 @@ ia32_sys_call_table: | |||
571 | .quad compat_sys_setrlimit /* 75 */ | 571 | .quad compat_sys_setrlimit /* 75 */ |
572 | .quad compat_sys_old_getrlimit /* old_getrlimit */ | 572 | .quad compat_sys_old_getrlimit /* old_getrlimit */ |
573 | .quad compat_sys_getrusage | 573 | .quad compat_sys_getrusage |
574 | .quad sys32_gettimeofday | 574 | .quad compat_sys_gettimeofday |
575 | .quad sys32_settimeofday | 575 | .quad compat_sys_settimeofday |
576 | .quad sys_getgroups16 /* 80 */ | 576 | .quad sys_getgroups16 /* 80 */ |
577 | .quad sys_setgroups16 | 577 | .quad sys_setgroups16 |
578 | .quad sys32_old_select | 578 | .quad sys32_old_select |
diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c index 4d3ad8d78a4d..2e09dcd3c0a6 100644 --- a/arch/x86/ia32/sys_ia32.c +++ b/arch/x86/ia32/sys_ia32.c | |||
@@ -367,75 +367,11 @@ asmlinkage long sys32_rt_sigprocmask(int how, compat_sigset_t __user *set, | |||
367 | return 0; | 367 | return 0; |
368 | } | 368 | } |
369 | 369 | ||
370 | static inline long get_tv32(struct timeval *o, struct compat_timeval __user *i) | ||
371 | { | ||
372 | int err = -EFAULT; | ||
373 | |||
374 | if (access_ok(VERIFY_READ, i, sizeof(*i))) { | ||
375 | err = __get_user(o->tv_sec, &i->tv_sec); | ||
376 | err |= __get_user(o->tv_usec, &i->tv_usec); | ||
377 | } | ||
378 | return err; | ||
379 | } | ||
380 | |||
381 | static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i) | ||
382 | { | ||
383 | int err = -EFAULT; | ||
384 | |||
385 | if (access_ok(VERIFY_WRITE, o, sizeof(*o))) { | ||
386 | err = __put_user(i->tv_sec, &o->tv_sec); | ||
387 | err |= __put_user(i->tv_usec, &o->tv_usec); | ||
388 | } | ||
389 | return err; | ||
390 | } | ||
391 | |||
392 | asmlinkage long sys32_alarm(unsigned int seconds) | 370 | asmlinkage long sys32_alarm(unsigned int seconds) |
393 | { | 371 | { |
394 | return alarm_setitimer(seconds); | 372 | return alarm_setitimer(seconds); |
395 | } | 373 | } |
396 | 374 | ||
397 | /* | ||
398 | * Translations due to time_t size differences. Which affects all | ||
399 | * sorts of things, like timeval and itimerval. | ||
400 | */ | ||
401 | asmlinkage long sys32_gettimeofday(struct compat_timeval __user *tv, | ||
402 | struct timezone __user *tz) | ||
403 | { | ||
404 | if (tv) { | ||
405 | struct timeval ktv; | ||
406 | |||
407 | do_gettimeofday(&ktv); | ||
408 | if (put_tv32(tv, &ktv)) | ||
409 | return -EFAULT; | ||
410 | } | ||
411 | if (tz) { | ||
412 | if (copy_to_user(tz, &sys_tz, sizeof(sys_tz))) | ||
413 | return -EFAULT; | ||
414 | } | ||
415 | return 0; | ||
416 | } | ||
417 | |||
418 | asmlinkage long sys32_settimeofday(struct compat_timeval __user *tv, | ||
419 | struct timezone __user *tz) | ||
420 | { | ||
421 | struct timeval ktv; | ||
422 | struct timespec kts; | ||
423 | struct timezone ktz; | ||
424 | |||
425 | if (tv) { | ||
426 | if (get_tv32(&ktv, tv)) | ||
427 | return -EFAULT; | ||
428 | kts.tv_sec = ktv.tv_sec; | ||
429 | kts.tv_nsec = ktv.tv_usec * NSEC_PER_USEC; | ||
430 | } | ||
431 | if (tz) { | ||
432 | if (copy_from_user(&ktz, tz, sizeof(ktz))) | ||
433 | return -EFAULT; | ||
434 | } | ||
435 | |||
436 | return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL); | ||
437 | } | ||
438 | |||
439 | struct sel_arg_struct { | 375 | struct sel_arg_struct { |
440 | unsigned int n; | 376 | unsigned int n; |
441 | unsigned int inp; | 377 | unsigned int inp; |