4 * Kernel compatibililty routines for e.g. 32 bit syscall support
7 * Copyright (C) 2002 Stephen Rothwell, IBM Corporation
8 * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
9 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
10 * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs
11 * Copyright (C) 2003 Pavel Machek (pavel@suse.cz)
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
18 #include <linux/linkage.h>
19 #include <linux/compat.h>
20 #include <linux/errno.h>
21 #include <linux/time.h>
23 #include <linux/fcntl.h>
24 #include <linux/namei.h>
25 #include <linux/file.h>
26 #include <linux/vfs.h>
27 #include <linux/ioctl32.h>
28 #include <linux/ioctl.h>
29 #include <linux/init.h>
30 #include <linux/sockios.h> /* for SIOCDEVPRIVATE */
31 #include <linux/smb.h>
32 #include <linux/smb_mount.h>
33 #include <linux/ncp_mount.h>
34 #include <linux/nfs4_mount.h>
35 #include <linux/smp_lock.h>
36 #include <linux/syscalls.h>
37 #include <linux/ctype.h>
38 #include <linux/module.h>
39 #include <linux/dirent.h>
40 #include <linux/fsnotify.h>
41 #include <linux/highuid.h>
42 #include <linux/sunrpc/svc.h>
43 #include <linux/nfsd/nfsd.h>
44 #include <linux/nfsd/syscall.h>
45 #include <linux/personality.h>
46 #include <linux/rwsem.h>
47 #include <linux/acct.h>
50 #include <net/sock.h> /* siocdevprivate_ioctl */
52 #include <asm/uaccess.h>
53 #include <asm/mmu_context.h>
54 #include <asm/ioctls.h>
57 * Not all architectures have sys_utime, so implement this in terms
60 asmlinkage long compat_sys_utime(char __user *filename, struct compat_utimbuf __user *t)
65 if (get_user(tv[0].tv_sec, &t->actime) ||
66 get_user(tv[1].tv_sec, &t->modtime))
71 return do_utimes(filename, t ? tv : NULL);
74 asmlinkage long compat_sys_utimes(char __user *filename, struct compat_timeval __user *t)
79 if (get_user(tv[0].tv_sec, &t[0].tv_sec) ||
80 get_user(tv[0].tv_usec, &t[0].tv_usec) ||
81 get_user(tv[1].tv_sec, &t[1].tv_sec) ||
82 get_user(tv[1].tv_usec, &t[1].tv_usec))
85 return do_utimes(filename, t ? tv : NULL);
88 asmlinkage long compat_sys_newstat(char __user * filename,
89 struct compat_stat __user *statbuf)
92 int error = vfs_stat(filename, &stat);
95 error = cp_compat_stat(&stat, statbuf);
99 asmlinkage long compat_sys_newlstat(char __user * filename,
100 struct compat_stat __user *statbuf)
103 int error = vfs_lstat(filename, &stat);
106 error = cp_compat_stat(&stat, statbuf);
110 asmlinkage long compat_sys_newfstat(unsigned int fd,
111 struct compat_stat __user * statbuf)
114 int error = vfs_fstat(fd, &stat);
117 error = cp_compat_stat(&stat, statbuf);
121 static int put_compat_statfs(struct compat_statfs __user *ubuf, struct kstatfs *kbuf)
124 if (sizeof ubuf->f_blocks == 4) {
125 if ((kbuf->f_blocks | kbuf->f_bfree | kbuf->f_bavail) &
126 0xffffffff00000000ULL)
128 /* f_files and f_ffree may be -1; it's okay
129 * to stuff that into 32 bits */
130 if (kbuf->f_files != 0xffffffffffffffffULL
131 && (kbuf->f_files & 0xffffffff00000000ULL))
133 if (kbuf->f_ffree != 0xffffffffffffffffULL
134 && (kbuf->f_ffree & 0xffffffff00000000ULL))
137 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(*ubuf)) ||
138 __put_user(kbuf->f_type, &ubuf->f_type) ||
139 __put_user(kbuf->f_bsize, &ubuf->f_bsize) ||
140 __put_user(kbuf->f_blocks, &ubuf->f_blocks) ||
141 __put_user(kbuf->f_bfree, &ubuf->f_bfree) ||
142 __put_user(kbuf->f_bavail, &ubuf->f_bavail) ||
143 __put_user(kbuf->f_files, &ubuf->f_files) ||
144 __put_user(kbuf->f_ffree, &ubuf->f_ffree) ||
145 __put_user(kbuf->f_namelen, &ubuf->f_namelen) ||
146 __put_user(kbuf->f_fsid.val[0], &ubuf->f_fsid.val[0]) ||
147 __put_user(kbuf->f_fsid.val[1], &ubuf->f_fsid.val[1]) ||
148 __put_user(kbuf->f_frsize, &ubuf->f_frsize) ||
149 __put_user(0, &ubuf->f_spare[0]) ||
150 __put_user(0, &ubuf->f_spare[1]) ||
151 __put_user(0, &ubuf->f_spare[2]) ||
152 __put_user(0, &ubuf->f_spare[3]) ||
153 __put_user(0, &ubuf->f_spare[4]))
159 * The following statfs calls are copies of code from fs/open.c and
160 * should be checked against those from time to time
162 asmlinkage long compat_sys_statfs(const char __user *path, struct compat_statfs __user *buf)
167 error = user_path_walk(path, &nd);
170 error = vfs_statfs(nd.dentry->d_inode->i_sb, &tmp);
172 error = put_compat_statfs(buf, &tmp);
178 asmlinkage long compat_sys_fstatfs(unsigned int fd, struct compat_statfs __user *buf)
188 error = vfs_statfs(file->f_dentry->d_inode->i_sb, &tmp);
190 error = put_compat_statfs(buf, &tmp);
196 static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstatfs *kbuf)
198 if (sizeof ubuf->f_blocks == 4) {
199 if ((kbuf->f_blocks | kbuf->f_bfree | kbuf->f_bavail) &
200 0xffffffff00000000ULL)
202 /* f_files and f_ffree may be -1; it's okay
203 * to stuff that into 32 bits */
204 if (kbuf->f_files != 0xffffffffffffffffULL
205 && (kbuf->f_files & 0xffffffff00000000ULL))
207 if (kbuf->f_ffree != 0xffffffffffffffffULL
208 && (kbuf->f_ffree & 0xffffffff00000000ULL))
211 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(*ubuf)) ||
212 __put_user(kbuf->f_type, &ubuf->f_type) ||
213 __put_user(kbuf->f_bsize, &ubuf->f_bsize) ||
214 __put_user(kbuf->f_blocks, &ubuf->f_blocks) ||
215 __put_user(kbuf->f_bfree, &ubuf->f_bfree) ||
216 __put_user(kbuf->f_bavail, &ubuf->f_bavail) ||
217 __put_user(kbuf->f_files, &ubuf->f_files) ||
218 __put_user(kbuf->f_ffree, &ubuf->f_ffree) ||
219 __put_user(kbuf->f_namelen, &ubuf->f_namelen) ||
220 __put_user(kbuf->f_fsid.val[0], &ubuf->f_fsid.val[0]) ||
221 __put_user(kbuf->f_fsid.val[1], &ubuf->f_fsid.val[1]) ||
222 __put_user(kbuf->f_frsize, &ubuf->f_frsize))
227 asmlinkage long compat_sys_statfs64(const char __user *path, compat_size_t sz, struct compat_statfs64 __user *buf)
232 if (sz != sizeof(*buf))
235 error = user_path_walk(path, &nd);
238 error = vfs_statfs(nd.dentry->d_inode->i_sb, &tmp);
240 error = put_compat_statfs64(buf, &tmp);
246 asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct compat_statfs64 __user *buf)
252 if (sz != sizeof(*buf))
259 error = vfs_statfs(file->f_dentry->d_inode->i_sb, &tmp);
261 error = put_compat_statfs64(buf, &tmp);
267 /* ioctl32 stuff, used by sparc64, parisc, s390x, ppc64, x86_64, MIPS */
269 #define IOCTL_HASHSIZE 256
270 static struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE];
272 extern struct ioctl_trans ioctl_start[];
273 extern int ioctl_table_size;
275 static inline unsigned long ioctl32_hash(unsigned long cmd)
277 return (((cmd >> 6) ^ (cmd >> 4) ^ cmd)) % IOCTL_HASHSIZE;
280 static void ioctl32_insert_translation(struct ioctl_trans *trans)
283 struct ioctl_trans *t;
285 hash = ioctl32_hash (trans->cmd);
286 if (!ioctl32_hash_table[hash])
287 ioctl32_hash_table[hash] = trans;
289 t = ioctl32_hash_table[hash];
297 static int __init init_sys32_ioctl(void)
301 for (i = 0; i < ioctl_table_size; i++) {
302 if (ioctl_start[i].next != 0) {
303 printk("ioctl translation %d bad\n",i);
307 ioctl32_insert_translation(&ioctl_start[i]);
312 __initcall(init_sys32_ioctl);
314 static void compat_ioctl_error(struct file *filp, unsigned int fd,
315 unsigned int cmd, unsigned long arg)
321 /* find the name of the device. */
322 path = (char *)__get_free_page(GFP_KERNEL);
324 fn = d_path(filp->f_dentry, filp->f_vfsmnt, path, PAGE_SIZE);
329 sprintf(buf,"'%c'", (cmd>>24) & 0x3f);
330 if (!isprint(buf[1]))
331 sprintf(buf, "%02x", buf[1]);
332 printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
333 "cmd(%08x){%s} arg(%08x) on %s\n",
334 current->comm, current->pid,
335 (int)fd, (unsigned int)cmd, buf,
336 (unsigned int)arg, fn);
339 free_page((unsigned long)path);
342 asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
347 struct ioctl_trans *t;
350 filp = fget_light(fd, &fput_needed);
354 /* RED-PEN how should LSM module know it's handling 32bit? */
355 error = security_file_ioctl(filp, cmd, arg);
360 * To allow the compat_ioctl handlers to be self contained
361 * we need to check the common ioctls here first.
362 * Just handle them with the standard handlers below.
375 if (S_ISREG(filp->f_dentry->d_inode->i_mode))
380 if (filp->f_op && filp->f_op->compat_ioctl) {
381 error = filp->f_op->compat_ioctl(filp, cmd, arg);
382 if (error != -ENOIOCTLCMD)
387 (!filp->f_op->ioctl && !filp->f_op->unlocked_ioctl))
392 for (t = ioctl32_hash_table[ioctl32_hash(cmd)]; t; t = t->next) {
397 if (S_ISSOCK(filp->f_dentry->d_inode->i_mode) &&
398 cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) {
399 error = siocdevprivate_ioctl(fd, cmd, arg);
404 compat_ioctl_error(filp, fd, cmd, arg);
413 error = t->handler(fd, cmd, arg, filp);
419 error = vfs_ioctl(filp, fd, cmd, arg);
421 fput_light(filp, fput_needed);
426 static int get_compat_flock(struct flock *kfl, struct compat_flock __user *ufl)
428 if (!access_ok(VERIFY_READ, ufl, sizeof(*ufl)) ||
429 __get_user(kfl->l_type, &ufl->l_type) ||
430 __get_user(kfl->l_whence, &ufl->l_whence) ||
431 __get_user(kfl->l_start, &ufl->l_start) ||
432 __get_user(kfl->l_len, &ufl->l_len) ||
433 __get_user(kfl->l_pid, &ufl->l_pid))
438 static int put_compat_flock(struct flock *kfl, struct compat_flock __user *ufl)
440 if (!access_ok(VERIFY_WRITE, ufl, sizeof(*ufl)) ||
441 __put_user(kfl->l_type, &ufl->l_type) ||
442 __put_user(kfl->l_whence, &ufl->l_whence) ||
443 __put_user(kfl->l_start, &ufl->l_start) ||
444 __put_user(kfl->l_len, &ufl->l_len) ||
445 __put_user(kfl->l_pid, &ufl->l_pid))
450 #ifndef HAVE_ARCH_GET_COMPAT_FLOCK64
451 static int get_compat_flock64(struct flock *kfl, struct compat_flock64 __user *ufl)
453 if (!access_ok(VERIFY_READ, ufl, sizeof(*ufl)) ||
454 __get_user(kfl->l_type, &ufl->l_type) ||
455 __get_user(kfl->l_whence, &ufl->l_whence) ||
456 __get_user(kfl->l_start, &ufl->l_start) ||
457 __get_user(kfl->l_len, &ufl->l_len) ||
458 __get_user(kfl->l_pid, &ufl->l_pid))
464 #ifndef HAVE_ARCH_PUT_COMPAT_FLOCK64
465 static int put_compat_flock64(struct flock *kfl, struct compat_flock64 __user *ufl)
467 if (!access_ok(VERIFY_WRITE, ufl, sizeof(*ufl)) ||
468 __put_user(kfl->l_type, &ufl->l_type) ||
469 __put_user(kfl->l_whence, &ufl->l_whence) ||
470 __put_user(kfl->l_start, &ufl->l_start) ||
471 __put_user(kfl->l_len, &ufl->l_len) ||
472 __put_user(kfl->l_pid, &ufl->l_pid))
478 asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
489 ret = get_compat_flock(&f, compat_ptr(arg));
494 ret = sys_fcntl(fd, cmd, (unsigned long)&f);
496 if (cmd == F_GETLK && ret == 0) {
497 /* GETLK was successfule and we need to return the data...
498 * but it needs to fit in the compat structure.
499 * l_start shouldn't be too big, unless the original
500 * start + end is greater than COMPAT_OFF_T_MAX, in which
501 * case the app was asking for trouble, so we return
502 * -EOVERFLOW in that case.
503 * l_len could be too big, in which case we just truncate it,
504 * and only allow the app to see that part of the conflicting
505 * lock that might make sense to it anyway
508 if (f.l_start > COMPAT_OFF_T_MAX)
510 if (f.l_len > COMPAT_OFF_T_MAX)
511 f.l_len = COMPAT_OFF_T_MAX;
513 ret = put_compat_flock(&f, compat_ptr(arg));
520 ret = get_compat_flock64(&f, compat_ptr(arg));
525 ret = sys_fcntl(fd, (cmd == F_GETLK64) ? F_GETLK :
526 ((cmd == F_SETLK64) ? F_SETLK : F_SETLKW),
529 if (cmd == F_GETLK64 && ret == 0) {
530 /* need to return lock information - see above for commentary */
531 if (f.l_start > COMPAT_LOFF_T_MAX)
533 if (f.l_len > COMPAT_LOFF_T_MAX)
534 f.l_len = COMPAT_LOFF_T_MAX;
536 ret = put_compat_flock64(&f, compat_ptr(arg));
541 ret = sys_fcntl(fd, cmd, arg);
547 asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
550 if ((cmd == F_GETLK64) || (cmd == F_SETLK64) || (cmd == F_SETLKW64))
552 return compat_sys_fcntl64(fd, cmd, arg);
556 compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
561 mm_segment_t oldfs = get_fs();
562 if (unlikely(get_user(ctx64, ctx32p)))
566 /* The __user pointer cast is valid because of the set_fs() */
567 ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
569 /* truncating is ok because it's a user address */
571 ret = put_user((u32) ctx64, ctx32p);
576 compat_sys_io_getevents(aio_context_t ctx_id,
577 unsigned long min_nr,
579 struct io_event __user *events,
580 struct compat_timespec __user *timeout)
584 struct timespec __user *ut = NULL;
587 if (unlikely(!access_ok(VERIFY_WRITE, events,
588 nr * sizeof(struct io_event))))
591 if (get_compat_timespec(&t, timeout))
594 ut = compat_alloc_user_space(sizeof(*ut));
595 if (copy_to_user(ut, &t, sizeof(t)) )
598 ret = sys_io_getevents(ctx_id, min_nr, nr, events, ut);
604 copy_iocb(long nr, u32 __user *ptr32, struct iocb __user * __user *ptr64)
609 for (i = 0; i < nr; ++i) {
610 if (get_user(uptr, ptr32 + i))
612 if (put_user(compat_ptr(uptr), ptr64 + i))
618 #define MAX_AIO_SUBMITS (PAGE_SIZE/sizeof(struct iocb *))
621 compat_sys_io_submit(aio_context_t ctx_id, int nr, u32 __user *iocb)
623 struct iocb __user * __user *iocb64;
626 if (unlikely(nr < 0))
629 if (nr > MAX_AIO_SUBMITS)
630 nr = MAX_AIO_SUBMITS;
632 iocb64 = compat_alloc_user_space(nr * sizeof(*iocb64));
633 ret = copy_iocb(nr, iocb, iocb64);
635 ret = sys_io_submit(ctx_id, nr, iocb64);
639 struct compat_ncp_mount_data {
640 compat_int_t version;
641 compat_uint_t ncp_fd;
642 __compat_uid_t mounted_uid;
643 compat_pid_t wdog_pid;
644 unsigned char mounted_vol[NCP_VOLNAME_LEN + 1];
645 compat_uint_t time_out;
646 compat_uint_t retry_count;
650 compat_mode_t file_mode;
651 compat_mode_t dir_mode;
654 struct compat_ncp_mount_data_v4 {
655 compat_int_t version;
656 compat_ulong_t flags;
657 compat_ulong_t mounted_uid;
658 compat_long_t wdog_pid;
659 compat_uint_t ncp_fd;
660 compat_uint_t time_out;
661 compat_uint_t retry_count;
664 compat_ulong_t file_mode;
665 compat_ulong_t dir_mode;
668 static void *do_ncp_super_data_conv(void *raw_data)
670 int version = *(unsigned int *)raw_data;
673 struct compat_ncp_mount_data *c_n = raw_data;
674 struct ncp_mount_data *n = raw_data;
676 n->dir_mode = c_n->dir_mode;
677 n->file_mode = c_n->file_mode;
680 memmove (n->mounted_vol, c_n->mounted_vol, (sizeof (c_n->mounted_vol) + 3 * sizeof (unsigned int)));
681 n->wdog_pid = c_n->wdog_pid;
682 n->mounted_uid = c_n->mounted_uid;
683 } else if (version == 4) {
684 struct compat_ncp_mount_data_v4 *c_n = raw_data;
685 struct ncp_mount_data_v4 *n = raw_data;
687 n->dir_mode = c_n->dir_mode;
688 n->file_mode = c_n->file_mode;
691 n->retry_count = c_n->retry_count;
692 n->time_out = c_n->time_out;
693 n->ncp_fd = c_n->ncp_fd;
694 n->wdog_pid = c_n->wdog_pid;
695 n->mounted_uid = c_n->mounted_uid;
696 n->flags = c_n->flags;
697 } else if (version != 5) {
704 struct compat_smb_mount_data {
705 compat_int_t version;
706 __compat_uid_t mounted_uid;
709 compat_mode_t file_mode;
710 compat_mode_t dir_mode;
713 static void *do_smb_super_data_conv(void *raw_data)
715 struct smb_mount_data *s = raw_data;
716 struct compat_smb_mount_data *c_s = raw_data;
718 if (c_s->version != SMB_MOUNT_OLDVERSION)
720 s->dir_mode = c_s->dir_mode;
721 s->file_mode = c_s->file_mode;
724 s->mounted_uid = c_s->mounted_uid;
729 struct compat_nfs_string {
734 static inline void compat_nfs_string(struct nfs_string *dst,
735 struct compat_nfs_string *src)
737 dst->data = compat_ptr(src->data);
741 struct compat_nfs4_mount_data_v1 {
742 compat_int_t version;
747 compat_int_t retrans;
748 compat_int_t acregmin;
749 compat_int_t acregmax;
750 compat_int_t acdirmin;
751 compat_int_t acdirmax;
752 struct compat_nfs_string client_addr;
753 struct compat_nfs_string mnt_path;
754 struct compat_nfs_string hostname;
755 compat_uint_t host_addrlen;
756 compat_uptr_t host_addr;
758 compat_int_t auth_flavourlen;
759 compat_uptr_t auth_flavours;
762 static int do_nfs4_super_data_conv(void *raw_data)
764 int version = *(compat_uint_t *) raw_data;
767 struct compat_nfs4_mount_data_v1 *raw = raw_data;
768 struct nfs4_mount_data *real = raw_data;
770 /* copy the fields backwards */
771 real->auth_flavours = compat_ptr(raw->auth_flavours);
772 real->auth_flavourlen = raw->auth_flavourlen;
773 real->proto = raw->proto;
774 real->host_addr = compat_ptr(raw->host_addr);
775 real->host_addrlen = raw->host_addrlen;
776 compat_nfs_string(&real->hostname, &raw->hostname);
777 compat_nfs_string(&real->mnt_path, &raw->mnt_path);
778 compat_nfs_string(&real->client_addr, &raw->client_addr);
779 real->acdirmax = raw->acdirmax;
780 real->acdirmin = raw->acdirmin;
781 real->acregmax = raw->acregmax;
782 real->acregmin = raw->acregmin;
783 real->retrans = raw->retrans;
784 real->timeo = raw->timeo;
785 real->wsize = raw->wsize;
786 real->rsize = raw->rsize;
787 real->flags = raw->flags;
788 real->version = raw->version;
797 extern int copy_mount_options (const void __user *, unsigned long *);
799 #define SMBFS_NAME "smbfs"
800 #define NCPFS_NAME "ncpfs"
801 #define NFS4_NAME "nfs4"
803 asmlinkage long compat_sys_mount(char __user * dev_name, char __user * dir_name,
804 char __user * type, unsigned long flags,
807 unsigned long type_page;
808 unsigned long data_page;
809 unsigned long dev_page;
813 retval = copy_mount_options (type, &type_page);
817 dir_page = getname(dir_name);
818 retval = PTR_ERR(dir_page);
819 if (IS_ERR(dir_page))
822 retval = copy_mount_options (dev_name, &dev_page);
826 retval = copy_mount_options (data, &data_page);
833 if (!strcmp((char *)type_page, SMBFS_NAME)) {
834 do_smb_super_data_conv((void *)data_page);
835 } else if (!strcmp((char *)type_page, NCPFS_NAME)) {
836 do_ncp_super_data_conv((void *)data_page);
837 } else if (!strcmp((char *)type_page, NFS4_NAME)) {
838 if (do_nfs4_super_data_conv((void *) data_page))
844 retval = do_mount((char*)dev_page, dir_page, (char*)type_page,
845 flags, (void*)data_page);
849 free_page(data_page);
855 free_page(type_page);
860 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
861 #define COMPAT_ROUND_UP(x) (((x)+sizeof(compat_long_t)-1) & \
862 ~(sizeof(compat_long_t)-1))
864 struct compat_old_linux_dirent {
865 compat_ulong_t d_ino;
866 compat_ulong_t d_offset;
867 unsigned short d_namlen;
871 struct compat_readdir_callback {
872 struct compat_old_linux_dirent __user *dirent;
876 static int compat_fillonedir(void *__buf, const char *name, int namlen,
877 loff_t offset, ino_t ino, unsigned int d_type)
879 struct compat_readdir_callback *buf = __buf;
880 struct compat_old_linux_dirent __user *dirent;
885 dirent = buf->dirent;
886 if (!access_ok(VERIFY_WRITE, dirent,
887 (unsigned long)(dirent->d_name + namlen + 1) -
888 (unsigned long)dirent))
890 if ( __put_user(ino, &dirent->d_ino) ||
891 __put_user(offset, &dirent->d_offset) ||
892 __put_user(namlen, &dirent->d_namlen) ||
893 __copy_to_user(dirent->d_name, name, namlen) ||
894 __put_user(0, dirent->d_name + namlen))
898 buf->result = -EFAULT;
902 asmlinkage long compat_sys_old_readdir(unsigned int fd,
903 struct compat_old_linux_dirent __user *dirent, unsigned int count)
907 struct compat_readdir_callback buf;
917 error = vfs_readdir(file, compat_fillonedir, &buf);
926 struct compat_linux_dirent {
927 compat_ulong_t d_ino;
928 compat_ulong_t d_off;
929 unsigned short d_reclen;
933 struct compat_getdents_callback {
934 struct compat_linux_dirent __user *current_dir;
935 struct compat_linux_dirent __user *previous;
940 static int compat_filldir(void *__buf, const char *name, int namlen,
941 loff_t offset, ino_t ino, unsigned int d_type)
943 struct compat_linux_dirent __user * dirent;
944 struct compat_getdents_callback *buf = __buf;
945 int reclen = COMPAT_ROUND_UP(NAME_OFFSET(dirent) + namlen + 2);
947 buf->error = -EINVAL; /* only used if we fail.. */
948 if (reclen > buf->count)
950 dirent = buf->previous;
952 if (__put_user(offset, &dirent->d_off))
955 dirent = buf->current_dir;
956 if (__put_user(ino, &dirent->d_ino))
958 if (__put_user(reclen, &dirent->d_reclen))
960 if (copy_to_user(dirent->d_name, name, namlen))
962 if (__put_user(0, dirent->d_name + namlen))
964 if (__put_user(d_type, (char __user *) dirent + reclen - 1))
966 buf->previous = dirent;
967 dirent = (void __user *)dirent + reclen;
968 buf->current_dir = dirent;
969 buf->count -= reclen;
972 buf->error = -EFAULT;
976 asmlinkage long compat_sys_getdents(unsigned int fd,
977 struct compat_linux_dirent __user *dirent, unsigned int count)
980 struct compat_linux_dirent __user * lastdirent;
981 struct compat_getdents_callback buf;
985 if (!access_ok(VERIFY_WRITE, dirent, count))
993 buf.current_dir = dirent;
998 error = vfs_readdir(file, compat_filldir, &buf);
1002 lastdirent = buf.previous;
1004 if (put_user(file->f_pos, &lastdirent->d_off))
1007 error = count - buf.count;
1016 #ifndef __ARCH_OMIT_COMPAT_SYS_GETDENTS64
1017 #define COMPAT_ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))
1019 struct compat_getdents_callback64 {
1020 struct linux_dirent64 __user *current_dir;
1021 struct linux_dirent64 __user *previous;
1026 static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t offset,
1027 ino_t ino, unsigned int d_type)
1029 struct linux_dirent64 __user *dirent;
1030 struct compat_getdents_callback64 *buf = __buf;
1031 int jj = NAME_OFFSET(dirent);
1032 int reclen = COMPAT_ROUND_UP64(jj + namlen + 1);
1035 buf->error = -EINVAL; /* only used if we fail.. */
1036 if (reclen > buf->count)
1038 dirent = buf->previous;
1041 if (__put_user_unaligned(offset, &dirent->d_off))
1044 dirent = buf->current_dir;
1045 if (__put_user_unaligned(ino, &dirent->d_ino))
1048 if (__put_user_unaligned(off, &dirent->d_off))
1050 if (__put_user(reclen, &dirent->d_reclen))
1052 if (__put_user(d_type, &dirent->d_type))
1054 if (copy_to_user(dirent->d_name, name, namlen))
1056 if (__put_user(0, dirent->d_name + namlen))
1058 buf->previous = dirent;
1059 dirent = (void __user *)dirent + reclen;
1060 buf->current_dir = dirent;
1061 buf->count -= reclen;
1064 buf->error = -EFAULT;
1068 asmlinkage long compat_sys_getdents64(unsigned int fd,
1069 struct linux_dirent64 __user * dirent, unsigned int count)
1072 struct linux_dirent64 __user * lastdirent;
1073 struct compat_getdents_callback64 buf;
1077 if (!access_ok(VERIFY_WRITE, dirent, count))
1085 buf.current_dir = dirent;
1086 buf.previous = NULL;
1090 error = vfs_readdir(file, compat_filldir64, &buf);
1094 lastdirent = buf.previous;
1096 typeof(lastdirent->d_off) d_off = file->f_pos;
1097 __put_user_unaligned(d_off, &lastdirent->d_off);
1098 error = count - buf.count;
1106 #endif /* ! __ARCH_OMIT_COMPAT_SYS_GETDENTS64 */
1108 static ssize_t compat_do_readv_writev(int type, struct file *file,
1109 const struct compat_iovec __user *uvector,
1110 unsigned long nr_segs, loff_t *pos)
1112 typedef ssize_t (*io_fn_t)(struct file *, char __user *, size_t, loff_t *);
1113 typedef ssize_t (*iov_fn_t)(struct file *, const struct iovec *, unsigned long, loff_t *);
1115 compat_ssize_t tot_len;
1116 struct iovec iovstack[UIO_FASTIOV];
1117 struct iovec *iov=iovstack, *vector;
1124 * SuS says "The readv() function *may* fail if the iovcnt argument
1125 * was less than or equal to 0, or greater than {IOV_MAX}. Linux has
1126 * traditionally returned zero for zero segments, so...
1133 * First get the "struct iovec" from user memory and
1134 * verify all the pointers
1137 if ((nr_segs > UIO_MAXIOV) || (nr_segs <= 0))
1141 if (nr_segs > UIO_FASTIOV) {
1143 iov = kmalloc(nr_segs*sizeof(struct iovec), GFP_KERNEL);
1148 if (!access_ok(VERIFY_READ, uvector, nr_segs*sizeof(*uvector)))
1152 * Single unix specification:
1153 * We should -EINVAL if an element length is not >= 0 and fitting an
1154 * ssize_t. The total length is fitting an ssize_t
1156 * Be careful here because iov_len is a size_t not an ssize_t
1161 for (seg = 0 ; seg < nr_segs; seg++) {
1162 compat_ssize_t tmp = tot_len;
1166 if (__get_user(len, &uvector->iov_len) ||
1167 __get_user(buf, &uvector->iov_base)) {
1171 if (len < 0) /* size_t not fitting an compat_ssize_t .. */
1174 if (tot_len < tmp) /* maths overflow on the compat_ssize_t */
1176 vector->iov_base = compat_ptr(buf);
1177 vector->iov_len = (compat_size_t) len;
1186 ret = rw_verify_area(type, file, pos, tot_len);
1192 fn = file->f_op->read;
1193 fnv = file->f_op->readv;
1195 fn = (io_fn_t)file->f_op->write;
1196 fnv = file->f_op->writev;
1199 ret = fnv(file, iov, nr_segs, pos);
1203 /* Do it by hand, with file-ops */
1206 while (nr_segs > 0) {
1211 base = vector->iov_base;
1212 len = vector->iov_len;
1216 nr = fn(file, base, len, pos);
1227 if (iov != iovstack)
1229 if ((ret + (type == READ)) > 0) {
1230 struct dentry *dentry = file->f_dentry;
1232 fsnotify_access(dentry);
1234 fsnotify_modify(dentry);
1240 compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec, unsigned long vlen)
1243 ssize_t ret = -EBADF;
1249 if (!(file->f_mode & FMODE_READ))
1253 if (!file->f_op || (!file->f_op->readv && !file->f_op->read))
1256 ret = compat_do_readv_writev(READ, file, vec, vlen, &file->f_pos);
1264 compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec, unsigned long vlen)
1267 ssize_t ret = -EBADF;
1272 if (!(file->f_mode & FMODE_WRITE))
1276 if (!file->f_op || (!file->f_op->writev && !file->f_op->write))
1279 ret = compat_do_readv_writev(WRITE, file, vec, vlen, &file->f_pos);
1287 * Exactly like fs/open.c:sys_open(), except that it doesn't set the
1291 compat_sys_open(const char __user *filename, int flags, int mode)
1293 return do_sys_open(filename, flags, mode);
1297 * compat_count() counts the number of arguments/envelopes. It is basically
1298 * a copy of count() from fs/exec.c, except that it works with 32 bit argv
1299 * and envp pointers.
1301 static int compat_count(compat_uptr_t __user *argv, int max)
1309 if (get_user(p, argv))
1322 * compat_copy_strings() is basically a copy of copy_strings() from fs/exec.c
1323 * except that it works with 32 bit argv and envp pointers.
1325 static int compat_copy_strings(int argc, compat_uptr_t __user *argv,
1326 struct linux_binprm *bprm)
1328 struct page *kmapped_page = NULL;
1332 while (argc-- > 0) {
1337 if (get_user(str, argv+argc) ||
1338 !(len = strnlen_user(compat_ptr(str), bprm->p))) {
1343 if (bprm->p < len) {
1349 /* XXX: add architecture specific overflow check here. */
1354 int offset, bytes_to_copy;
1357 offset = pos % PAGE_SIZE;
1359 page = bprm->page[i];
1362 page = alloc_page(GFP_HIGHUSER);
1363 bprm->page[i] = page;
1371 if (page != kmapped_page) {
1373 kunmap(kmapped_page);
1374 kmapped_page = page;
1375 kaddr = kmap(kmapped_page);
1378 memset(kaddr, 0, offset);
1379 bytes_to_copy = PAGE_SIZE - offset;
1380 if (bytes_to_copy > len) {
1381 bytes_to_copy = len;
1383 memset(kaddr+offset+len, 0,
1384 PAGE_SIZE-offset-len);
1386 err = copy_from_user(kaddr+offset, compat_ptr(str),
1393 pos += bytes_to_copy;
1394 str += bytes_to_copy;
1395 len -= bytes_to_copy;
1401 kunmap(kmapped_page);
1407 #define free_arg_pages(bprm) do { } while (0)
1411 static inline void free_arg_pages(struct linux_binprm *bprm)
1415 for (i = 0; i < MAX_ARG_PAGES; i++) {
1417 __free_page(bprm->page[i]);
1418 bprm->page[i] = NULL;
1422 #endif /* CONFIG_MMU */
1425 * compat_do_execve() is mostly a copy of do_execve(), with the exception
1426 * that it processes 32 bit argv and envp pointers.
1428 int compat_do_execve(char * filename,
1429 compat_uptr_t __user *argv,
1430 compat_uptr_t __user *envp,
1431 struct pt_regs * regs)
1433 struct linux_binprm *bprm;
1439 bprm = kmalloc(sizeof(*bprm), GFP_KERNEL);
1442 memset(bprm, 0, sizeof(*bprm));
1444 file = open_exec(filename);
1445 retval = PTR_ERR(file);
1451 bprm->p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
1453 bprm->filename = filename;
1454 bprm->interp = filename;
1455 bprm->mm = mm_alloc();
1460 retval = init_new_context(current, bprm->mm);
1464 bprm->argc = compat_count(argv, bprm->p / sizeof(compat_uptr_t));
1465 if ((retval = bprm->argc) < 0)
1468 bprm->envc = compat_count(envp, bprm->p / sizeof(compat_uptr_t));
1469 if ((retval = bprm->envc) < 0)
1472 retval = security_bprm_alloc(bprm);
1476 retval = prepare_binprm(bprm);
1480 retval = copy_strings_kernel(1, &bprm->filename, bprm);
1484 bprm->exec = bprm->p;
1485 retval = compat_copy_strings(bprm->envc, envp, bprm);
1489 retval = compat_copy_strings(bprm->argc, argv, bprm);
1493 retval = search_binary_handler(bprm, regs);
1495 free_arg_pages(bprm);
1497 /* execve success */
1498 security_bprm_free(bprm);
1499 acct_update_integrals(current);
1505 /* Something went wrong, return the inode and free the argument pages*/
1506 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
1507 struct page * page = bprm->page[i];
1513 security_bprm_free(bprm);
1521 allow_write_access(bprm->file);
1532 #define __COMPAT_NFDBITS (8 * sizeof(compat_ulong_t))
1534 #define ROUND_UP(x,y) (((x)+(y)-1)/(y))
1537 * Ooo, nasty. We need here to frob 32-bit unsigned longs to
1538 * 64-bit unsigned longs.
1541 int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1542 unsigned long *fdset)
1544 nr = ROUND_UP(nr, __COMPAT_NFDBITS);
1548 if (!access_ok(VERIFY_WRITE, ufdset, nr*sizeof(compat_ulong_t)))
1555 __get_user(l, ufdset);
1556 __get_user(h, ufdset+1);
1558 *fdset++ = h << 32 | l;
1562 __get_user(*fdset, ufdset);
1564 /* Tricky, must clear full unsigned long in the
1565 * kernel fdset at the end, this makes sure that
1568 memset(fdset, 0, ((nr + 1) & ~1)*sizeof(compat_ulong_t));
1574 void compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1575 unsigned long *fdset)
1578 nr = ROUND_UP(nr, __COMPAT_NFDBITS);
1589 __put_user(l, ufdset);
1590 __put_user(h, ufdset+1);
1595 __put_user(*fdset, ufdset);
1600 * This is a virtual copy of sys_select from fs/select.c and probably
1601 * should be compared to it from time to time
1603 static void *select_bits_alloc(int size)
1605 return kmalloc(6 * size, GFP_KERNEL);
1608 static void select_bits_free(void *bits, int size)
1614 * We can actually return ERESTARTSYS instead of EINTR, but I'd
1615 * like to be certain this leads to no problems. So I return
1616 * EINTR just for safety.
1618 * Update: ERESTARTSYS breaks at least the xview clock binary, so
1619 * I'm trying ERESTARTNOHAND which restart only when you want to.
1621 #define MAX_SELECT_SECONDS \
1622 ((unsigned long) (MAX_SCHEDULE_TIMEOUT / HZ)-1)
1625 compat_sys_select(int n, compat_ulong_t __user *inp, compat_ulong_t __user *outp,
1626 compat_ulong_t __user *exp, struct compat_timeval __user *tvp)
1631 int size, max_fdset, ret = -EINVAL;
1632 struct fdtable *fdt;
1634 timeout = MAX_SCHEDULE_TIMEOUT;
1638 if (!access_ok(VERIFY_READ, tvp, sizeof(*tvp))
1639 || __get_user(sec, &tvp->tv_sec)
1640 || __get_user(usec, &tvp->tv_usec)) {
1645 if (sec < 0 || usec < 0)
1648 if ((unsigned long) sec < MAX_SELECT_SECONDS) {
1649 timeout = ROUND_UP(usec, 1000000/HZ);
1650 timeout += sec * (unsigned long) HZ;
1657 /* max_fdset can increase, so grab it once to avoid race */
1659 fdt = files_fdtable(current->files);
1660 max_fdset = fdt->max_fdset;
1666 * We need 6 bitmaps (in/out/ex for both incoming and outgoing),
1667 * since we used fdset we need to allocate memory in units of
1671 size = FDS_BYTES(n);
1672 bits = select_bits_alloc(size);
1675 fds.in = (unsigned long *) bits;
1676 fds.out = (unsigned long *) (bits + size);
1677 fds.ex = (unsigned long *) (bits + 2*size);
1678 fds.res_in = (unsigned long *) (bits + 3*size);
1679 fds.res_out = (unsigned long *) (bits + 4*size);
1680 fds.res_ex = (unsigned long *) (bits + 5*size);
1682 if ((ret = compat_get_fd_set(n, inp, fds.in)) ||
1683 (ret = compat_get_fd_set(n, outp, fds.out)) ||
1684 (ret = compat_get_fd_set(n, exp, fds.ex)))
1686 zero_fd_set(n, fds.res_in);
1687 zero_fd_set(n, fds.res_out);
1688 zero_fd_set(n, fds.res_ex);
1690 ret = do_select(n, &fds, &timeout);
1692 if (tvp && !(current->personality & STICKY_TIMEOUTS)) {
1693 time_t sec = 0, usec = 0;
1696 usec = timeout % HZ;
1697 usec *= (1000000/HZ);
1699 if (put_user(sec, &tvp->tv_sec) ||
1700 put_user(usec, &tvp->tv_usec))
1707 ret = -ERESTARTNOHAND;
1708 if (signal_pending(current))
1713 compat_set_fd_set(n, inp, fds.res_in);
1714 compat_set_fd_set(n, outp, fds.res_out);
1715 compat_set_fd_set(n, exp, fds.res_ex);
1718 select_bits_free(bits, size);
1723 #if defined(CONFIG_NFSD) || defined(CONFIG_NFSD_MODULE)
1724 /* Stuff for NFS server syscalls... */
1725 struct compat_nfsctl_svc {
1730 struct compat_nfsctl_client {
1731 s8 cl32_ident[NFSCLNT_IDMAX+1];
1733 struct in_addr cl32_addrlist[NFSCLNT_ADDRMAX];
1736 u8 cl32_fhkey[NFSCLNT_KEYMAX];
1739 struct compat_nfsctl_export {
1740 char ex32_client[NFSCLNT_IDMAX+1];
1741 char ex32_path[NFS_MAXPATHLEN+1];
1742 compat_dev_t ex32_dev;
1743 compat_ino_t ex32_ino;
1744 compat_int_t ex32_flags;
1745 __compat_uid_t ex32_anon_uid;
1746 __compat_gid_t ex32_anon_gid;
1749 struct compat_nfsctl_fdparm {
1750 struct sockaddr gd32_addr;
1751 s8 gd32_path[NFS_MAXPATHLEN+1];
1752 compat_int_t gd32_version;
1755 struct compat_nfsctl_fsparm {
1756 struct sockaddr gd32_addr;
1757 s8 gd32_path[NFS_MAXPATHLEN+1];
1758 compat_int_t gd32_maxlen;
1761 struct compat_nfsctl_arg {
1762 compat_int_t ca32_version; /* safeguard */
1764 struct compat_nfsctl_svc u32_svc;
1765 struct compat_nfsctl_client u32_client;
1766 struct compat_nfsctl_export u32_export;
1767 struct compat_nfsctl_fdparm u32_getfd;
1768 struct compat_nfsctl_fsparm u32_getfs;
1770 #define ca32_svc u.u32_svc
1771 #define ca32_client u.u32_client
1772 #define ca32_export u.u32_export
1773 #define ca32_getfd u.u32_getfd
1774 #define ca32_getfs u.u32_getfs
1777 union compat_nfsctl_res {
1778 __u8 cr32_getfh[NFS_FHSIZE];
1779 struct knfsd_fh cr32_getfs;
1782 static int compat_nfs_svc_trans(struct nfsctl_arg *karg, struct compat_nfsctl_arg __user *arg)
1786 err = access_ok(VERIFY_READ, &arg->ca32_svc, sizeof(arg->ca32_svc));
1787 err |= get_user(karg->ca_version, &arg->ca32_version);
1788 err |= __get_user(karg->ca_svc.svc_port, &arg->ca32_svc.svc32_port);
1789 err |= __get_user(karg->ca_svc.svc_nthreads, &arg->ca32_svc.svc32_nthreads);
1790 return (err) ? -EFAULT : 0;
1793 static int compat_nfs_clnt_trans(struct nfsctl_arg *karg, struct compat_nfsctl_arg __user *arg)
1797 err = access_ok(VERIFY_READ, &arg->ca32_client, sizeof(arg->ca32_client));
1798 err |= get_user(karg->ca_version, &arg->ca32_version);
1799 err |= __copy_from_user(&karg->ca_client.cl_ident[0],
1800 &arg->ca32_client.cl32_ident[0],
1802 err |= __get_user(karg->ca_client.cl_naddr, &arg->ca32_client.cl32_naddr);
1803 err |= __copy_from_user(&karg->ca_client.cl_addrlist[0],
1804 &arg->ca32_client.cl32_addrlist[0],
1805 (sizeof(struct in_addr) * NFSCLNT_ADDRMAX));
1806 err |= __get_user(karg->ca_client.cl_fhkeytype,
1807 &arg->ca32_client.cl32_fhkeytype);
1808 err |= __get_user(karg->ca_client.cl_fhkeylen,
1809 &arg->ca32_client.cl32_fhkeylen);
1810 err |= __copy_from_user(&karg->ca_client.cl_fhkey[0],
1811 &arg->ca32_client.cl32_fhkey[0],
1814 return (err) ? -EFAULT : 0;
1817 static int compat_nfs_exp_trans(struct nfsctl_arg *karg, struct compat_nfsctl_arg __user *arg)
1821 err = access_ok(VERIFY_READ, &arg->ca32_export, sizeof(arg->ca32_export));
1822 err |= get_user(karg->ca_version, &arg->ca32_version);
1823 err |= __copy_from_user(&karg->ca_export.ex_client[0],
1824 &arg->ca32_export.ex32_client[0],
1826 err |= __copy_from_user(&karg->ca_export.ex_path[0],
1827 &arg->ca32_export.ex32_path[0],
1829 err |= __get_user(karg->ca_export.ex_dev,
1830 &arg->ca32_export.ex32_dev);
1831 err |= __get_user(karg->ca_export.ex_ino,
1832 &arg->ca32_export.ex32_ino);
1833 err |= __get_user(karg->ca_export.ex_flags,
1834 &arg->ca32_export.ex32_flags);
1835 err |= __get_user(karg->ca_export.ex_anon_uid,
1836 &arg->ca32_export.ex32_anon_uid);
1837 err |= __get_user(karg->ca_export.ex_anon_gid,
1838 &arg->ca32_export.ex32_anon_gid);
1839 SET_UID(karg->ca_export.ex_anon_uid, karg->ca_export.ex_anon_uid);
1840 SET_GID(karg->ca_export.ex_anon_gid, karg->ca_export.ex_anon_gid);
1842 return (err) ? -EFAULT : 0;
1845 static int compat_nfs_getfd_trans(struct nfsctl_arg *karg, struct compat_nfsctl_arg __user *arg)
1849 err = access_ok(VERIFY_READ, &arg->ca32_getfd, sizeof(arg->ca32_getfd));
1850 err |= get_user(karg->ca_version, &arg->ca32_version);
1851 err |= __copy_from_user(&karg->ca_getfd.gd_addr,
1852 &arg->ca32_getfd.gd32_addr,
1853 (sizeof(struct sockaddr)));
1854 err |= __copy_from_user(&karg->ca_getfd.gd_path,
1855 &arg->ca32_getfd.gd32_path,
1856 (NFS_MAXPATHLEN+1));
1857 err |= __get_user(karg->ca_getfd.gd_version,
1858 &arg->ca32_getfd.gd32_version);
1860 return (err) ? -EFAULT : 0;
1863 static int compat_nfs_getfs_trans(struct nfsctl_arg *karg, struct compat_nfsctl_arg __user *arg)
1867 err = access_ok(VERIFY_READ, &arg->ca32_getfs, sizeof(arg->ca32_getfs));
1868 err |= get_user(karg->ca_version, &arg->ca32_version);
1869 err |= __copy_from_user(&karg->ca_getfs.gd_addr,
1870 &arg->ca32_getfs.gd32_addr,
1871 (sizeof(struct sockaddr)));
1872 err |= __copy_from_user(&karg->ca_getfs.gd_path,
1873 &arg->ca32_getfs.gd32_path,
1874 (NFS_MAXPATHLEN+1));
1875 err |= __get_user(karg->ca_getfs.gd_maxlen,
1876 &arg->ca32_getfs.gd32_maxlen);
1878 return (err) ? -EFAULT : 0;
1881 /* This really doesn't need translations, we are only passing
1882 * back a union which contains opaque nfs file handle data.
1884 static int compat_nfs_getfh_res_trans(union nfsctl_res *kres, union compat_nfsctl_res __user *res)
1888 err = copy_to_user(res, kres, sizeof(*res));
1890 return (err) ? -EFAULT : 0;
1893 asmlinkage long compat_sys_nfsservctl(int cmd, struct compat_nfsctl_arg __user *arg,
1894 union compat_nfsctl_res __user *res)
1896 struct nfsctl_arg *karg;
1897 union nfsctl_res *kres;
1901 karg = kmalloc(sizeof(*karg), GFP_USER);
1902 kres = kmalloc(sizeof(*kres), GFP_USER);
1903 if(!karg || !kres) {
1910 err = compat_nfs_svc_trans(karg, arg);
1913 case NFSCTL_ADDCLIENT:
1914 err = compat_nfs_clnt_trans(karg, arg);
1917 case NFSCTL_DELCLIENT:
1918 err = compat_nfs_clnt_trans(karg, arg);
1922 case NFSCTL_UNEXPORT:
1923 err = compat_nfs_exp_trans(karg, arg);
1927 err = compat_nfs_getfd_trans(karg, arg);
1931 err = compat_nfs_getfs_trans(karg, arg);
1941 /* The __user pointer casts are valid because of the set_fs() */
1942 err = sys_nfsservctl(cmd, (void __user *) karg, (void __user *) kres);
1948 if((cmd == NFSCTL_GETFD) ||
1949 (cmd == NFSCTL_GETFS))
1950 err = compat_nfs_getfh_res_trans(kres, res);
1958 long asmlinkage compat_sys_nfsservctl(int cmd, void *notused, void *notused2)
1960 return sys_ni_syscall();