diff options
author | Kyle McMartin <kyle@parisc-linux.org> | 2007-02-10 04:46:00 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-11 13:51:32 -0500 |
commit | d4d23add3abcd18d8021b99f230df608ccb2f007 (patch) | |
tree | 756c5a7d21a9f5a25f10bfcec40c01aecc596c2f /arch/sparc64/kernel/sys_sparc32.c | |
parent | 72fd4a35a824331d7a0f4168d7576502d95d34b3 (diff) |
[PATCH] Common compat_sys_sysinfo
I noticed that almost all architectures implemented exactly the same
sys32_sysinfo... except parisc, where a bug was to be found in handling of
the uptime. So let's remove a whole whack of code for fun and profit.
Cribbed compat_sys_sysinfo from x86_64's implementation, since I figured it
would be the best tested.
This patch incorporates Arnd's suggestion of not using set_fs/get_fs, but
instead extracting out the common code from sys_sysinfo.
Cc: Christoph Hellwig <hch@infradead.org>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/sparc64/kernel/sys_sparc32.c')
-rw-r--r-- | arch/sparc64/kernel/sys_sparc32.c | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c index e27cb71bd8e2..7876a0226285 100644 --- a/arch/sparc64/kernel/sys_sparc32.c +++ b/arch/sparc64/kernel/sys_sparc32.c | |||
@@ -459,70 +459,6 @@ asmlinkage long compat_sys_sysfs(int option, u32 arg1, u32 arg2) | |||
459 | return sys_sysfs(option, arg1, arg2); | 459 | return sys_sysfs(option, arg1, arg2); |
460 | } | 460 | } |
461 | 461 | ||
462 | struct sysinfo32 { | ||
463 | s32 uptime; | ||
464 | u32 loads[3]; | ||
465 | u32 totalram; | ||
466 | u32 freeram; | ||
467 | u32 sharedram; | ||
468 | u32 bufferram; | ||
469 | u32 totalswap; | ||
470 | u32 freeswap; | ||
471 | unsigned short procs; | ||
472 | unsigned short pad; | ||
473 | u32 totalhigh; | ||
474 | u32 freehigh; | ||
475 | u32 mem_unit; | ||
476 | char _f[20-2*sizeof(int)-sizeof(int)]; | ||
477 | }; | ||
478 | |||
479 | asmlinkage long sys32_sysinfo(struct sysinfo32 __user *info) | ||
480 | { | ||
481 | struct sysinfo s; | ||
482 | int ret, err; | ||
483 | int bitcount = 0; | ||
484 | mm_segment_t old_fs = get_fs (); | ||
485 | |||
486 | set_fs(KERNEL_DS); | ||
487 | ret = sys_sysinfo((struct sysinfo __user *) &s); | ||
488 | set_fs(old_fs); | ||
489 | /* Check to see if any memory value is too large for 32-bit and | ||
490 | * scale down if needed. | ||
491 | */ | ||
492 | if ((s.totalram >> 32) || (s.totalswap >> 32)) { | ||
493 | while (s.mem_unit < PAGE_SIZE) { | ||
494 | s.mem_unit <<= 1; | ||
495 | bitcount++; | ||
496 | } | ||
497 | s.totalram >>= bitcount; | ||
498 | s.freeram >>= bitcount; | ||
499 | s.sharedram >>= bitcount; | ||
500 | s.bufferram >>= bitcount; | ||
501 | s.totalswap >>= bitcount; | ||
502 | s.freeswap >>= bitcount; | ||
503 | s.totalhigh >>= bitcount; | ||
504 | s.freehigh >>= bitcount; | ||
505 | } | ||
506 | |||
507 | err = put_user (s.uptime, &info->uptime); | ||
508 | err |= __put_user (s.loads[0], &info->loads[0]); | ||
509 | err |= __put_user (s.loads[1], &info->loads[1]); | ||
510 | err |= __put_user (s.loads[2], &info->loads[2]); | ||
511 | err |= __put_user (s.totalram, &info->totalram); | ||
512 | err |= __put_user (s.freeram, &info->freeram); | ||
513 | err |= __put_user (s.sharedram, &info->sharedram); | ||
514 | err |= __put_user (s.bufferram, &info->bufferram); | ||
515 | err |= __put_user (s.totalswap, &info->totalswap); | ||
516 | err |= __put_user (s.freeswap, &info->freeswap); | ||
517 | err |= __put_user (s.procs, &info->procs); | ||
518 | err |= __put_user (s.totalhigh, &info->totalhigh); | ||
519 | err |= __put_user (s.freehigh, &info->freehigh); | ||
520 | err |= __put_user (s.mem_unit, &info->mem_unit); | ||
521 | if (err) | ||
522 | return -EFAULT; | ||
523 | return ret; | ||
524 | } | ||
525 | |||
526 | asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec __user *interval) | 462 | asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec __user *interval) |
527 | { | 463 | { |
528 | struct timespec t; | 464 | struct timespec t; |