aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64/ia32/sys_ia32.c
diff options
context:
space:
mode:
authorKyle McMartin <kyle@parisc-linux.org>2007-02-10 04:46:00 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-11 13:51:32 -0500
commitd4d23add3abcd18d8021b99f230df608ccb2f007 (patch)
tree756c5a7d21a9f5a25f10bfcec40c01aecc596c2f /arch/ia64/ia32/sys_ia32.c
parent72fd4a35a824331d7a0f4168d7576502d95d34b3 (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/ia64/ia32/sys_ia32.c')
-rw-r--r--arch/ia64/ia32/sys_ia32.c68
1 files changed, 0 insertions, 68 deletions
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
index 957681c39ad9..d430d36ae49d 100644
--- a/arch/ia64/ia32/sys_ia32.c
+++ b/arch/ia64/ia32/sys_ia32.c
@@ -2209,74 +2209,6 @@ sys32_fstat64 (unsigned int fd, struct stat64 __user *statbuf)
2209 return ret; 2209 return ret;
2210} 2210}
2211 2211
2212struct sysinfo32 {
2213 s32 uptime;
2214 u32 loads[3];
2215 u32 totalram;
2216 u32 freeram;
2217 u32 sharedram;
2218 u32 bufferram;
2219 u32 totalswap;
2220 u32 freeswap;
2221 u16 procs;
2222 u16 pad;
2223 u32 totalhigh;
2224 u32 freehigh;
2225 u32 mem_unit;
2226 char _f[8];
2227};
2228
2229asmlinkage long
2230sys32_sysinfo (struct sysinfo32 __user *info)
2231{
2232 struct sysinfo s;
2233 long ret, err;
2234 int bitcount = 0;
2235 mm_segment_t old_fs = get_fs();
2236
2237 set_fs(KERNEL_DS);
2238 ret = sys_sysinfo((struct sysinfo __user *) &s);
2239 set_fs(old_fs);
2240 /* Check to see if any memory value is too large for 32-bit and
2241 * scale down if needed.
2242 */
2243 if ((s.totalram >> 32) || (s.totalswap >> 32)) {
2244 while (s.mem_unit < PAGE_SIZE) {
2245 s.mem_unit <<= 1;
2246 bitcount++;
2247 }
2248 s.totalram >>= bitcount;
2249 s.freeram >>= bitcount;
2250 s.sharedram >>= bitcount;
2251 s.bufferram >>= bitcount;
2252 s.totalswap >>= bitcount;
2253 s.freeswap >>= bitcount;
2254 s.totalhigh >>= bitcount;
2255 s.freehigh >>= bitcount;
2256 }
2257
2258 if (!access_ok(VERIFY_WRITE, info, sizeof(*info)))
2259 return -EFAULT;
2260
2261 err = __put_user(s.uptime, &info->uptime);
2262 err |= __put_user(s.loads[0], &info->loads[0]);
2263 err |= __put_user(s.loads[1], &info->loads[1]);
2264 err |= __put_user(s.loads[2], &info->loads[2]);
2265 err |= __put_user(s.totalram, &info->totalram);
2266 err |= __put_user(s.freeram, &info->freeram);
2267 err |= __put_user(s.sharedram, &info->sharedram);
2268 err |= __put_user(s.bufferram, &info->bufferram);
2269 err |= __put_user(s.totalswap, &info->totalswap);
2270 err |= __put_user(s.freeswap, &info->freeswap);
2271 err |= __put_user(s.procs, &info->procs);
2272 err |= __put_user (s.totalhigh, &info->totalhigh);
2273 err |= __put_user (s.freehigh, &info->freehigh);
2274 err |= __put_user (s.mem_unit, &info->mem_unit);
2275 if (err)
2276 return -EFAULT;
2277 return ret;
2278}
2279
2280asmlinkage long 2212asmlinkage long
2281sys32_sched_rr_get_interval (pid_t pid, struct compat_timespec __user *interval) 2213sys32_sched_rr_get_interval (pid_t pid, struct compat_timespec __user *interval)
2282{ 2214{