[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>
This commit is contained in:
committed by
Linus Torvalds
parent
72fd4a35a8
commit
d4d23add3a
@@ -193,50 +193,6 @@ sysn32_waitid(int which, compat_pid_t pid,
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct sysinfo32 {
|
||||
s32 uptime;
|
||||
u32 loads[3];
|
||||
u32 totalram;
|
||||
u32 freeram;
|
||||
u32 sharedram;
|
||||
u32 bufferram;
|
||||
u32 totalswap;
|
||||
u32 freeswap;
|
||||
u16 procs;
|
||||
u32 totalhigh;
|
||||
u32 freehigh;
|
||||
u32 mem_unit;
|
||||
char _f[8];
|
||||
};
|
||||
|
||||
asmlinkage int sys32_sysinfo(struct sysinfo32 __user *info)
|
||||
{
|
||||
struct sysinfo s;
|
||||
int ret, err;
|
||||
mm_segment_t old_fs = get_fs ();
|
||||
|
||||
set_fs (KERNEL_DS);
|
||||
ret = sys_sysinfo((struct sysinfo __user *)&s);
|
||||
set_fs (old_fs);
|
||||
err = put_user (s.uptime, &info->uptime);
|
||||
err |= __put_user (s.loads[0], &info->loads[0]);
|
||||
err |= __put_user (s.loads[1], &info->loads[1]);
|
||||
err |= __put_user (s.loads[2], &info->loads[2]);
|
||||
err |= __put_user (s.totalram, &info->totalram);
|
||||
err |= __put_user (s.freeram, &info->freeram);
|
||||
err |= __put_user (s.sharedram, &info->sharedram);
|
||||
err |= __put_user (s.bufferram, &info->bufferram);
|
||||
err |= __put_user (s.totalswap, &info->totalswap);
|
||||
err |= __put_user (s.freeswap, &info->freeswap);
|
||||
err |= __put_user (s.procs, &info->procs);
|
||||
err |= __put_user (s.totalhigh, &info->totalhigh);
|
||||
err |= __put_user (s.freehigh, &info->freehigh);
|
||||
err |= __put_user (s.mem_unit, &info->mem_unit);
|
||||
if (err)
|
||||
return -EFAULT;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define RLIM_INFINITY32 0x7fffffff
|
||||
#define RESOURCE32(x) ((x > RLIM_INFINITY32) ? RLIM_INFINITY32 : x)
|
||||
|
||||
|
@@ -217,7 +217,7 @@ EXPORT(sysn32_call_table)
|
||||
PTR sys32_gettimeofday
|
||||
PTR compat_sys_getrlimit /* 6095 */
|
||||
PTR compat_sys_getrusage
|
||||
PTR sys32_sysinfo
|
||||
PTR compat_sys_sysinfo
|
||||
PTR compat_sys_times
|
||||
PTR sys32_ptrace
|
||||
PTR sys_getuid /* 6100 */
|
||||
|
@@ -321,7 +321,7 @@ sys_call_table:
|
||||
PTR sys_ni_syscall /* sys_vm86 */
|
||||
PTR compat_sys_wait4
|
||||
PTR sys_swapoff /* 4115 */
|
||||
PTR sys32_sysinfo
|
||||
PTR compat_sys_sysinfo
|
||||
PTR sys32_ipc
|
||||
PTR sys_fsync
|
||||
PTR sys32_sigreturn
|
||||
|
Reference in New Issue
Block a user