2 * arch/s390x/kernel/linux32.c
5 * Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 * Gerhard Tonn (ton@de.ibm.com)
8 * Thomas Spatzier (tspat@de.ibm.com)
10 * Conversion between 31bit and 64bit native syscalls.
12 * Heavily inspired by the 32-bit Sparc compat code which is
13 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
14 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
19 #include <linux/config.h>
20 #include <linux/kernel.h>
21 #include <linux/sched.h>
24 #include <linux/file.h>
25 #include <linux/signal.h>
26 #include <linux/resource.h>
27 #include <linux/times.h>
28 #include <linux/utsname.h>
29 #include <linux/timex.h>
30 #include <linux/smp.h>
31 #include <linux/smp_lock.h>
32 #include <linux/sem.h>
33 #include <linux/msg.h>
34 #include <linux/shm.h>
35 #include <linux/slab.h>
36 #include <linux/uio.h>
37 #include <linux/nfs_fs.h>
38 #include <linux/quota.h>
39 #include <linux/module.h>
40 #include <linux/sunrpc/svc.h>
41 #include <linux/nfsd/nfsd.h>
42 #include <linux/nfsd/cache.h>
43 #include <linux/nfsd/xdr.h>
44 #include <linux/nfsd/syscall.h>
45 #include <linux/poll.h>
46 #include <linux/personality.h>
47 #include <linux/stat.h>
48 #include <linux/filter.h>
49 #include <linux/highmem.h>
50 #include <linux/highuid.h>
51 #include <linux/mman.h>
52 #include <linux/ipv6.h>
54 #include <linux/icmpv6.h>
55 #include <linux/syscalls.h>
56 #include <linux/sysctl.h>
57 #include <linux/binfmts.h>
58 #include <linux/capability.h>
59 #include <linux/compat.h>
60 #include <linux/vfs.h>
61 #include <linux/ptrace.h>
62 #include <linux/fadvise.h>
64 #include <asm/types.h>
66 #include <asm/uaccess.h>
67 #include <asm/semaphore.h>
72 #include "compat_linux.h"
75 /* For this source file, we want overflow handling. */
85 #undef SET_OLDSTAT_UID
86 #undef SET_OLDSTAT_GID
90 #define high2lowuid(uid) ((uid) > 65535) ? (u16)overflowuid : (u16)(uid)
91 #define high2lowgid(gid) ((gid) > 65535) ? (u16)overflowgid : (u16)(gid)
92 #define low2highuid(uid) ((uid) == (u16)-1) ? (uid_t)-1 : (uid_t)(uid)
93 #define low2highgid(gid) ((gid) == (u16)-1) ? (gid_t)-1 : (gid_t)(gid)
94 #define SET_UID16(var, uid) var = high2lowuid(uid)
95 #define SET_GID16(var, gid) var = high2lowgid(gid)
96 #define NEW_TO_OLD_UID(uid) high2lowuid(uid)
97 #define NEW_TO_OLD_GID(gid) high2lowgid(gid)
98 #define SET_OLDSTAT_UID(stat, uid) (stat).st_uid = high2lowuid(uid)
99 #define SET_OLDSTAT_GID(stat, gid) (stat).st_gid = high2lowgid(gid)
100 #define SET_STAT_UID(stat, uid) (stat).st_uid = high2lowuid(uid)
101 #define SET_STAT_GID(stat, gid) (stat).st_gid = high2lowgid(gid)
103 asmlinkage long sys32_chown16(const char * filename, u16 user, u16 group)
105 return sys_chown(filename, low2highuid(user), low2highgid(group));
108 asmlinkage long sys32_lchown16(const char * filename, u16 user, u16 group)
110 return sys_lchown(filename, low2highuid(user), low2highgid(group));
113 asmlinkage long sys32_fchown16(unsigned int fd, u16 user, u16 group)
115 return sys_fchown(fd, low2highuid(user), low2highgid(group));
118 asmlinkage long sys32_setregid16(u16 rgid, u16 egid)
120 return sys_setregid(low2highgid(rgid), low2highgid(egid));
123 asmlinkage long sys32_setgid16(u16 gid)
125 return sys_setgid((gid_t)gid);
128 asmlinkage long sys32_setreuid16(u16 ruid, u16 euid)
130 return sys_setreuid(low2highuid(ruid), low2highuid(euid));
133 asmlinkage long sys32_setuid16(u16 uid)
135 return sys_setuid((uid_t)uid);
138 asmlinkage long sys32_setresuid16(u16 ruid, u16 euid, u16 suid)
140 return sys_setresuid(low2highuid(ruid), low2highuid(euid),
144 asmlinkage long sys32_getresuid16(u16 *ruid, u16 *euid, u16 *suid)
148 if (!(retval = put_user(high2lowuid(current->uid), ruid)) &&
149 !(retval = put_user(high2lowuid(current->euid), euid)))
150 retval = put_user(high2lowuid(current->suid), suid);
155 asmlinkage long sys32_setresgid16(u16 rgid, u16 egid, u16 sgid)
157 return sys_setresgid(low2highgid(rgid), low2highgid(egid),
161 asmlinkage long sys32_getresgid16(u16 *rgid, u16 *egid, u16 *sgid)
165 if (!(retval = put_user(high2lowgid(current->gid), rgid)) &&
166 !(retval = put_user(high2lowgid(current->egid), egid)))
167 retval = put_user(high2lowgid(current->sgid), sgid);
172 asmlinkage long sys32_setfsuid16(u16 uid)
174 return sys_setfsuid((uid_t)uid);
177 asmlinkage long sys32_setfsgid16(u16 gid)
179 return sys_setfsgid((gid_t)gid);
182 static int groups16_to_user(u16 *grouplist, struct group_info *group_info)
187 for (i = 0; i < group_info->ngroups; i++) {
188 group = (u16)GROUP_AT(group_info, i);
189 if (put_user(group, grouplist+i))
196 static int groups16_from_user(struct group_info *group_info, u16 *grouplist)
201 for (i = 0; i < group_info->ngroups; i++) {
202 if (get_user(group, grouplist+i))
204 GROUP_AT(group_info, i) = (gid_t)group;
210 asmlinkage long sys32_getgroups16(int gidsetsize, u16 *grouplist)
217 get_group_info(current->group_info);
218 i = current->group_info->ngroups;
220 if (i > gidsetsize) {
224 if (groups16_to_user(grouplist, current->group_info)) {
230 put_group_info(current->group_info);
234 asmlinkage long sys32_setgroups16(int gidsetsize, u16 *grouplist)
236 struct group_info *group_info;
239 if (!capable(CAP_SETGID))
241 if ((unsigned)gidsetsize > NGROUPS_MAX)
244 group_info = groups_alloc(gidsetsize);
247 retval = groups16_from_user(group_info, grouplist);
249 put_group_info(group_info);
253 retval = set_current_groups(group_info);
254 put_group_info(group_info);
259 asmlinkage long sys32_getuid16(void)
261 return high2lowuid(current->uid);
264 asmlinkage long sys32_geteuid16(void)
266 return high2lowuid(current->euid);
269 asmlinkage long sys32_getgid16(void)
271 return high2lowgid(current->gid);
274 asmlinkage long sys32_getegid16(void)
276 return high2lowgid(current->egid);
279 /* 32-bit timeval and related flotsam. */
281 static inline long get_tv32(struct timeval *o, struct compat_timeval *i)
283 return (!access_ok(VERIFY_READ, o, sizeof(*o)) ||
284 (__get_user(o->tv_sec, &i->tv_sec) ||
285 __get_user(o->tv_usec, &i->tv_usec)));
288 static inline long put_tv32(struct compat_timeval *o, struct timeval *i)
290 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
291 (__put_user(i->tv_sec, &o->tv_sec) ||
292 __put_user(i->tv_usec, &o->tv_usec)));
296 * sys32_ipc() is the de-multiplexer for the SysV IPC calls in 32bit emulation.
298 * This is really horribly ugly.
300 asmlinkage long sys32_ipc(u32 call, int first, int second, int third, u32 ptr)
302 if (call >> 16) /* hack for backward compatibility */
309 return compat_sys_semtimedop(first, compat_ptr(ptr),
310 second, compat_ptr(third));
312 /* struct sembuf is the same on 32 and 64bit :)) */
313 return sys_semtimedop(first, compat_ptr(ptr),
316 return sys_semget(first, second, third);
318 return compat_sys_semctl(first, second, third,
321 return compat_sys_msgsnd(first, second, third,
324 return compat_sys_msgrcv(first, second, 0, third,
327 return sys_msgget((key_t) first, second);
329 return compat_sys_msgctl(first, second, compat_ptr(ptr));
331 return compat_sys_shmat(first, second, third,
334 return sys_shmdt(compat_ptr(ptr));
336 return sys_shmget(first, (unsigned)second, third);
338 return compat_sys_shmctl(first, second, compat_ptr(ptr));
344 asmlinkage long sys32_truncate64(const char * path, unsigned long high, unsigned long low)
349 return sys_truncate(path, (high << 32) | low);
352 asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long high, unsigned long low)
357 return sys_ftruncate(fd, (high << 32) | low);
360 int cp_compat_stat(struct kstat *stat, struct compat_stat *statbuf)
364 if (!old_valid_dev(stat->dev) || !old_valid_dev(stat->rdev))
367 err = put_user(old_encode_dev(stat->dev), &statbuf->st_dev);
368 err |= put_user(stat->ino, &statbuf->st_ino);
369 err |= put_user(stat->mode, &statbuf->st_mode);
370 err |= put_user(stat->nlink, &statbuf->st_nlink);
371 err |= put_user(high2lowuid(stat->uid), &statbuf->st_uid);
372 err |= put_user(high2lowgid(stat->gid), &statbuf->st_gid);
373 err |= put_user(old_encode_dev(stat->rdev), &statbuf->st_rdev);
374 err |= put_user(stat->size, &statbuf->st_size);
375 err |= put_user(stat->atime.tv_sec, &statbuf->st_atime);
376 err |= put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec);
377 err |= put_user(stat->mtime.tv_sec, &statbuf->st_mtime);
378 err |= put_user(stat->mtime.tv_nsec, &statbuf->st_mtime_nsec);
379 err |= put_user(stat->ctime.tv_sec, &statbuf->st_ctime);
380 err |= put_user(stat->ctime.tv_nsec, &statbuf->st_ctime_nsec);
381 err |= put_user(stat->blksize, &statbuf->st_blksize);
382 err |= put_user(stat->blocks, &statbuf->st_blocks);
384 err |= put_user(0, &statbuf->__unused4[0]);
385 err |= put_user(0, &statbuf->__unused4[1]);
399 unsigned short procs;
403 unsigned int mem_unit;
407 asmlinkage long sys32_sysinfo(struct sysinfo32 __user *info)
411 mm_segment_t old_fs = get_fs ();
414 ret = sys_sysinfo(&s);
416 err = put_user (s.uptime, &info->uptime);
417 err |= __put_user (s.loads[0], &info->loads[0]);
418 err |= __put_user (s.loads[1], &info->loads[1]);
419 err |= __put_user (s.loads[2], &info->loads[2]);
420 err |= __put_user (s.totalram, &info->totalram);
421 err |= __put_user (s.freeram, &info->freeram);
422 err |= __put_user (s.sharedram, &info->sharedram);
423 err |= __put_user (s.bufferram, &info->bufferram);
424 err |= __put_user (s.totalswap, &info->totalswap);
425 err |= __put_user (s.freeswap, &info->freeswap);
426 err |= __put_user (s.procs, &info->procs);
427 err |= __put_user (s.totalhigh, &info->totalhigh);
428 err |= __put_user (s.freehigh, &info->freehigh);
429 err |= __put_user (s.mem_unit, &info->mem_unit);
435 asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
436 struct compat_timespec __user *interval)
440 mm_segment_t old_fs = get_fs ();
443 ret = sys_sched_rr_get_interval(pid, &t);
445 if (put_compat_timespec(&t, interval))
450 asmlinkage long sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,
451 compat_sigset_t __user *oset, size_t sigsetsize)
456 mm_segment_t old_fs = get_fs();
459 if (copy_from_user (&s32, set, sizeof(compat_sigset_t)))
461 switch (_NSIG_WORDS) {
462 case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32);
463 case 3: s.sig[2] = s32.sig[4] | (((long)s32.sig[5]) << 32);
464 case 2: s.sig[1] = s32.sig[2] | (((long)s32.sig[3]) << 32);
465 case 1: s.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32);
469 ret = sys_rt_sigprocmask(how, set ? &s : NULL, oset ? &s : NULL, sigsetsize);
473 switch (_NSIG_WORDS) {
474 case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
475 case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
476 case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
477 case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
479 if (copy_to_user (oset, &s32, sizeof(compat_sigset_t)))
485 asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
491 mm_segment_t old_fs = get_fs();
494 ret = sys_rt_sigpending(&s, sigsetsize);
497 switch (_NSIG_WORDS) {
498 case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
499 case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
500 case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
501 case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
503 if (copy_to_user (set, &s32, sizeof(compat_sigset_t)))
510 sys32_rt_sigqueueinfo(int pid, int sig, compat_siginfo_t __user *uinfo)
514 mm_segment_t old_fs = get_fs();
516 if (copy_siginfo_from_user32(&info, uinfo))
519 ret = sys_rt_sigqueueinfo(pid, sig, &info);
525 * sys32_execve() executes a new program after the asm stub has set
526 * things up for us. This should basically do what I want it to.
529 sys32_execve(struct pt_regs regs)
534 filename = getname(compat_ptr(regs.orig_gpr2));
535 error = PTR_ERR(filename);
536 if (IS_ERR(filename))
538 error = compat_do_execve(filename, compat_ptr(regs.gprs[3]),
539 compat_ptr(regs.gprs[4]), ®s);
543 current->ptrace &= ~PT_DTRACE;
544 task_unlock(current);
545 current->thread.fp_regs.fpc=0;
557 #ifdef CONFIG_MODULES
560 sys32_init_module(void __user *umod, unsigned long len,
561 const char __user *uargs)
563 return sys_init_module(umod, len, uargs);
567 sys32_delete_module(const char __user *name_user, unsigned int flags)
569 return sys_delete_module(name_user, flags);
572 #else /* CONFIG_MODULES */
575 sys32_init_module(void __user *umod, unsigned long len,
576 const char __user *uargs)
582 sys32_delete_module(const char __user *name_user, unsigned int flags)
587 #endif /* CONFIG_MODULES */
589 /* Translations due to time_t size differences. Which affects all
590 sorts of things, like timeval and itimerval. */
592 extern struct timezone sys_tz;
594 asmlinkage long sys32_gettimeofday(struct compat_timeval *tv, struct timezone *tz)
598 do_gettimeofday(&ktv);
599 if (put_tv32(tv, &ktv))
603 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
609 static inline long get_ts32(struct timespec *o, struct compat_timeval *i)
613 if (!access_ok(VERIFY_READ, i, sizeof(*i)))
615 if (__get_user(o->tv_sec, &i->tv_sec))
617 if (__get_user(usec, &i->tv_usec))
619 o->tv_nsec = usec * 1000;
623 asmlinkage long sys32_settimeofday(struct compat_timeval *tv, struct timezone *tz)
629 if (get_ts32(&kts, tv))
633 if (copy_from_user(&ktz, tz, sizeof(ktz)))
637 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
640 /* These are here just in case some old sparc32 binary calls it. */
641 asmlinkage long sys32_pause(void)
643 current->state = TASK_INTERRUPTIBLE;
645 return -ERESTARTNOHAND;
648 asmlinkage long sys32_pread64(unsigned int fd, char *ubuf,
649 size_t count, u32 poshi, u32 poslo)
651 if ((compat_ssize_t) count < 0)
653 return sys_pread64(fd, ubuf, count, ((loff_t)AA(poshi) << 32) | AA(poslo));
656 asmlinkage long sys32_pwrite64(unsigned int fd, const char *ubuf,
657 size_t count, u32 poshi, u32 poslo)
659 if ((compat_ssize_t) count < 0)
661 return sys_pwrite64(fd, ubuf, count, ((loff_t)AA(poshi) << 32) | AA(poslo));
664 asmlinkage compat_ssize_t sys32_readahead(int fd, u32 offhi, u32 offlo, s32 count)
666 return sys_readahead(fd, ((loff_t)AA(offhi) << 32) | AA(offlo), count);
669 asmlinkage long sys32_sendfile(int out_fd, int in_fd, compat_off_t *offset, size_t count)
671 mm_segment_t old_fs = get_fs();
675 if (offset && get_user(of, offset))
679 ret = sys_sendfile(out_fd, in_fd, offset ? &of : NULL, count);
682 if (offset && put_user(of, offset))
688 asmlinkage long sys32_sendfile64(int out_fd, int in_fd,
689 compat_loff_t *offset, s32 count)
691 mm_segment_t old_fs = get_fs();
695 if (offset && get_user(lof, offset))
699 ret = sys_sendfile64(out_fd, in_fd, offset ? &lof : NULL, count);
702 if (offset && put_user(lof, offset))
708 /* Handle adjtimex compatibility. */
712 s32 offset, freq, maxerror, esterror;
713 s32 status, constant, precision, tolerance;
714 struct compat_timeval time;
716 s32 ppsfreq, jitter, shift, stabil;
717 s32 jitcnt, calcnt, errcnt, stbcnt;
718 s32 :32; s32 :32; s32 :32; s32 :32;
719 s32 :32; s32 :32; s32 :32; s32 :32;
720 s32 :32; s32 :32; s32 :32; s32 :32;
723 extern int do_adjtimex(struct timex *);
725 asmlinkage long sys32_adjtimex(struct timex32 *utp)
730 memset(&txc, 0, sizeof(struct timex));
732 if(get_user(txc.modes, &utp->modes) ||
733 __get_user(txc.offset, &utp->offset) ||
734 __get_user(txc.freq, &utp->freq) ||
735 __get_user(txc.maxerror, &utp->maxerror) ||
736 __get_user(txc.esterror, &utp->esterror) ||
737 __get_user(txc.status, &utp->status) ||
738 __get_user(txc.constant, &utp->constant) ||
739 __get_user(txc.precision, &utp->precision) ||
740 __get_user(txc.tolerance, &utp->tolerance) ||
741 __get_user(txc.time.tv_sec, &utp->time.tv_sec) ||
742 __get_user(txc.time.tv_usec, &utp->time.tv_usec) ||
743 __get_user(txc.tick, &utp->tick) ||
744 __get_user(txc.ppsfreq, &utp->ppsfreq) ||
745 __get_user(txc.jitter, &utp->jitter) ||
746 __get_user(txc.shift, &utp->shift) ||
747 __get_user(txc.stabil, &utp->stabil) ||
748 __get_user(txc.jitcnt, &utp->jitcnt) ||
749 __get_user(txc.calcnt, &utp->calcnt) ||
750 __get_user(txc.errcnt, &utp->errcnt) ||
751 __get_user(txc.stbcnt, &utp->stbcnt))
754 ret = do_adjtimex(&txc);
756 if(put_user(txc.modes, &utp->modes) ||
757 __put_user(txc.offset, &utp->offset) ||
758 __put_user(txc.freq, &utp->freq) ||
759 __put_user(txc.maxerror, &utp->maxerror) ||
760 __put_user(txc.esterror, &utp->esterror) ||
761 __put_user(txc.status, &utp->status) ||
762 __put_user(txc.constant, &utp->constant) ||
763 __put_user(txc.precision, &utp->precision) ||
764 __put_user(txc.tolerance, &utp->tolerance) ||
765 __put_user(txc.time.tv_sec, &utp->time.tv_sec) ||
766 __put_user(txc.time.tv_usec, &utp->time.tv_usec) ||
767 __put_user(txc.tick, &utp->tick) ||
768 __put_user(txc.ppsfreq, &utp->ppsfreq) ||
769 __put_user(txc.jitter, &utp->jitter) ||
770 __put_user(txc.shift, &utp->shift) ||
771 __put_user(txc.stabil, &utp->stabil) ||
772 __put_user(txc.jitcnt, &utp->jitcnt) ||
773 __put_user(txc.calcnt, &utp->calcnt) ||
774 __put_user(txc.errcnt, &utp->errcnt) ||
775 __put_user(txc.stbcnt, &utp->stbcnt))
782 struct __sysctl_args32 {
792 asmlinkage long sys32_sysctl(struct __sysctl_args32 *args)
794 struct __sysctl_args32 tmp;
796 size_t oldlen, *oldlenp = NULL;
797 unsigned long addr = (((long)&args->__unused[0]) + 7) & ~7;
799 if (copy_from_user(&tmp, args, sizeof(tmp)))
802 if (tmp.oldval && tmp.oldlenp) {
803 /* Duh, this is ugly and might not work if sysctl_args
804 is in read-only memory, but do_sysctl does indirectly
805 a lot of uaccess in both directions and we'd have to
806 basically copy the whole sysctl.c here, and
807 glibc's __sysctl uses rw memory for the structure
809 if (get_user(oldlen, (u32 *)A(tmp.oldlenp)) ||
810 put_user(oldlen, (size_t *)addr))
812 oldlenp = (size_t *)addr;
816 error = do_sysctl((int *)A(tmp.name), tmp.nlen, (void *)A(tmp.oldval),
817 oldlenp, (void *)A(tmp.newval), tmp.newlen);
821 if (get_user(oldlen, (size_t *)addr) ||
822 put_user(oldlen, (u32 *)A(tmp.oldlenp)))
825 copy_to_user(args->__unused, tmp.__unused, sizeof(tmp.__unused));
831 struct stat64_emu31 {
832 unsigned long long st_dev;
834 #define STAT64_HAS_BROKEN_ST_INO 1
836 unsigned int st_mode;
837 unsigned int st_nlink;
840 unsigned long long st_rdev;
844 unsigned char __pad4[4];
845 u32 __pad5; /* future possible st_blocks high bits */
846 u32 st_blocks; /* Number 512-byte blocks allocated. */
852 u32 __pad8; /* will be high 32 bits of ctime someday */
853 unsigned long st_ino;
856 static int cp_stat64(struct stat64_emu31 *ubuf, struct kstat *stat)
858 struct stat64_emu31 tmp;
860 memset(&tmp, 0, sizeof(tmp));
862 tmp.st_dev = huge_encode_dev(stat->dev);
863 tmp.st_ino = stat->ino;
864 tmp.__st_ino = (u32)stat->ino;
865 tmp.st_mode = stat->mode;
866 tmp.st_nlink = (unsigned int)stat->nlink;
867 tmp.st_uid = stat->uid;
868 tmp.st_gid = stat->gid;
869 tmp.st_rdev = huge_encode_dev(stat->rdev);
870 tmp.st_size = stat->size;
871 tmp.st_blksize = (u32)stat->blksize;
872 tmp.st_blocks = (u32)stat->blocks;
873 tmp.st_atime = (u32)stat->atime.tv_sec;
874 tmp.st_mtime = (u32)stat->mtime.tv_sec;
875 tmp.st_ctime = (u32)stat->ctime.tv_sec;
877 return copy_to_user(ubuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
880 asmlinkage long sys32_stat64(char * filename, struct stat64_emu31 * statbuf)
883 int ret = vfs_stat(filename, &stat);
885 ret = cp_stat64(statbuf, &stat);
889 asmlinkage long sys32_lstat64(char * filename, struct stat64_emu31 * statbuf)
892 int ret = vfs_lstat(filename, &stat);
894 ret = cp_stat64(statbuf, &stat);
898 asmlinkage long sys32_fstat64(unsigned long fd, struct stat64_emu31 * statbuf)
901 int ret = vfs_fstat(fd, &stat);
903 ret = cp_stat64(statbuf, &stat);
908 * Linux/i386 didn't use to be able to handle more than
909 * 4 system call parameters, so these system calls used a memory
910 * block for parameter passing..
913 struct mmap_arg_struct_emu31 {
922 /* common code for old and new mmaps */
923 static inline long do_mmap2(
924 unsigned long addr, unsigned long len,
925 unsigned long prot, unsigned long flags,
926 unsigned long fd, unsigned long pgoff)
928 struct file * file = NULL;
929 unsigned long error = -EBADF;
931 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
932 if (!(flags & MAP_ANONYMOUS)) {
938 down_write(¤t->mm->mmap_sem);
939 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
940 if (!IS_ERR((void *) error) && error + len >= 0x80000000ULL) {
941 /* Result is out of bounds. */
942 do_munmap(current->mm, addr, len);
945 up_write(¤t->mm->mmap_sem);
954 asmlinkage unsigned long
955 old32_mmap(struct mmap_arg_struct_emu31 *arg)
957 struct mmap_arg_struct_emu31 a;
960 if (copy_from_user(&a, arg, sizeof(a)))
964 if (a.offset & ~PAGE_MASK)
967 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
973 sys32_mmap2(struct mmap_arg_struct_emu31 *arg)
975 struct mmap_arg_struct_emu31 a;
978 if (copy_from_user(&a, arg, sizeof(a)))
980 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
985 asmlinkage long sys32_read(unsigned int fd, char * buf, size_t count)
987 if ((compat_ssize_t) count < 0)
990 return sys_read(fd, buf, count);
993 asmlinkage long sys32_write(unsigned int fd, char * buf, size_t count)
995 if ((compat_ssize_t) count < 0)
998 return sys_write(fd, buf, count);
1001 asmlinkage long sys32_clone(struct pt_regs regs)
1003 unsigned long clone_flags;
1004 unsigned long newsp;
1005 int *parent_tidptr, *child_tidptr;
1007 clone_flags = regs.gprs[3] & 0xffffffffUL;
1008 newsp = regs.orig_gpr2 & 0x7fffffffUL;
1009 parent_tidptr = (int *) (regs.gprs[4] & 0x7fffffffUL);
1010 child_tidptr = (int *) (regs.gprs[5] & 0x7fffffffUL);
1012 newsp = regs.gprs[15];
1013 return do_fork(clone_flags, newsp, ®s, 0,
1014 parent_tidptr, child_tidptr);
1018 * 31 bit emulation wrapper functions for sys_fadvise64/fadvise64_64.
1019 * These need to rewrite the advise values for POSIX_FADV_{DONTNEED,NOREUSE}
1020 * because the 31 bit values differ from the 64 bit values.
1024 sys32_fadvise64(int fd, loff_t offset, size_t len, int advise)
1027 advise = POSIX_FADV_DONTNEED;
1028 else if (advise == 5)
1029 advise = POSIX_FADV_NOREUSE;
1030 return sys_fadvise64(fd, offset, len, advise);
1033 struct fadvise64_64_args {
1041 sys32_fadvise64_64(struct fadvise64_64_args __user *args)
1043 struct fadvise64_64_args a;
1045 if ( copy_from_user(&a, args, sizeof(a)) )
1048 a.advice = POSIX_FADV_DONTNEED;
1049 else if (a.advice == 5)
1050 a.advice = POSIX_FADV_NOREUSE;
1051 return sys_fadvise64_64(a.fd, a.offset, a.len, a.advice);