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 if ((f.l_start >= COMPAT_OFF_T_MAX) ||
498 ((f.l_start + f.l_len) > COMPAT_OFF_T_MAX))
501 ret = put_compat_flock(&f, compat_ptr(arg));
508 ret = get_compat_flock64(&f, compat_ptr(arg));
513 ret = sys_fcntl(fd, (cmd == F_GETLK64) ? F_GETLK :
514 ((cmd == F_SETLK64) ? F_SETLK : F_SETLKW),
517 if (cmd == F_GETLK64 && ret == 0) {
518 if ((f.l_start >= COMPAT_LOFF_T_MAX) ||
519 ((f.l_start + f.l_len) > COMPAT_LOFF_T_MAX))
522 ret = put_compat_flock64(&f, compat_ptr(arg));
527 ret = sys_fcntl(fd, cmd, arg);
533 asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
536 if ((cmd == F_GETLK64) || (cmd == F_SETLK64) || (cmd == F_SETLKW64))
538 return compat_sys_fcntl64(fd, cmd, arg);
542 compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
547 mm_segment_t oldfs = get_fs();
548 if (unlikely(get_user(ctx64, ctx32p)))
552 /* The __user pointer cast is valid because of the set_fs() */
553 ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
555 /* truncating is ok because it's a user address */
557 ret = put_user((u32) ctx64, ctx32p);
562 compat_sys_io_getevents(aio_context_t ctx_id,
563 unsigned long min_nr,
565 struct io_event __user *events,
566 struct compat_timespec __user *timeout)
570 struct timespec __user *ut = NULL;
573 if (unlikely(!access_ok(VERIFY_WRITE, events,
574 nr * sizeof(struct io_event))))
577 if (get_compat_timespec(&t, timeout))
580 ut = compat_alloc_user_space(sizeof(*ut));
581 if (copy_to_user(ut, &t, sizeof(t)) )
584 ret = sys_io_getevents(ctx_id, min_nr, nr, events, ut);
590 copy_iocb(long nr, u32 __user *ptr32, struct iocb __user * __user *ptr64)
595 for (i = 0; i < nr; ++i) {
596 if (get_user(uptr, ptr32 + i))
598 if (put_user(compat_ptr(uptr), ptr64 + i))
604 #define MAX_AIO_SUBMITS (PAGE_SIZE/sizeof(struct iocb *))
607 compat_sys_io_submit(aio_context_t ctx_id, int nr, u32 __user *iocb)
609 struct iocb __user * __user *iocb64;
612 if (unlikely(nr < 0))
615 if (nr > MAX_AIO_SUBMITS)
616 nr = MAX_AIO_SUBMITS;
618 iocb64 = compat_alloc_user_space(nr * sizeof(*iocb64));
619 ret = copy_iocb(nr, iocb, iocb64);
621 ret = sys_io_submit(ctx_id, nr, iocb64);
625 struct compat_ncp_mount_data {
626 compat_int_t version;
627 compat_uint_t ncp_fd;
628 __compat_uid_t mounted_uid;
629 compat_pid_t wdog_pid;
630 unsigned char mounted_vol[NCP_VOLNAME_LEN + 1];
631 compat_uint_t time_out;
632 compat_uint_t retry_count;
636 compat_mode_t file_mode;
637 compat_mode_t dir_mode;
640 struct compat_ncp_mount_data_v4 {
641 compat_int_t version;
642 compat_ulong_t flags;
643 compat_ulong_t mounted_uid;
644 compat_long_t wdog_pid;
645 compat_uint_t ncp_fd;
646 compat_uint_t time_out;
647 compat_uint_t retry_count;
650 compat_ulong_t file_mode;
651 compat_ulong_t dir_mode;
654 static void *do_ncp_super_data_conv(void *raw_data)
656 int version = *(unsigned int *)raw_data;
659 struct compat_ncp_mount_data *c_n = raw_data;
660 struct ncp_mount_data *n = raw_data;
662 n->dir_mode = c_n->dir_mode;
663 n->file_mode = c_n->file_mode;
666 memmove (n->mounted_vol, c_n->mounted_vol, (sizeof (c_n->mounted_vol) + 3 * sizeof (unsigned int)));
667 n->wdog_pid = c_n->wdog_pid;
668 n->mounted_uid = c_n->mounted_uid;
669 } else if (version == 4) {
670 struct compat_ncp_mount_data_v4 *c_n = raw_data;
671 struct ncp_mount_data_v4 *n = raw_data;
673 n->dir_mode = c_n->dir_mode;
674 n->file_mode = c_n->file_mode;
677 n->retry_count = c_n->retry_count;
678 n->time_out = c_n->time_out;
679 n->ncp_fd = c_n->ncp_fd;
680 n->wdog_pid = c_n->wdog_pid;
681 n->mounted_uid = c_n->mounted_uid;
682 n->flags = c_n->flags;
683 } else if (version != 5) {
690 struct compat_smb_mount_data {
691 compat_int_t version;
692 __compat_uid_t mounted_uid;
695 compat_mode_t file_mode;
696 compat_mode_t dir_mode;
699 static void *do_smb_super_data_conv(void *raw_data)
701 struct smb_mount_data *s = raw_data;
702 struct compat_smb_mount_data *c_s = raw_data;
704 if (c_s->version != SMB_MOUNT_OLDVERSION)
706 s->dir_mode = c_s->dir_mode;
707 s->file_mode = c_s->file_mode;
710 s->mounted_uid = c_s->mounted_uid;
715 struct compat_nfs_string {
720 static inline void compat_nfs_string(struct nfs_string *dst,
721 struct compat_nfs_string *src)
723 dst->data = compat_ptr(src->data);
727 struct compat_nfs4_mount_data_v1 {
728 compat_int_t version;
733 compat_int_t retrans;
734 compat_int_t acregmin;
735 compat_int_t acregmax;
736 compat_int_t acdirmin;
737 compat_int_t acdirmax;
738 struct compat_nfs_string client_addr;
739 struct compat_nfs_string mnt_path;
740 struct compat_nfs_string hostname;
741 compat_uint_t host_addrlen;
742 compat_uptr_t host_addr;
744 compat_int_t auth_flavourlen;
745 compat_uptr_t auth_flavours;
748 static int do_nfs4_super_data_conv(void *raw_data)
750 int version = *(compat_uint_t *) raw_data;
753 struct compat_nfs4_mount_data_v1 *raw = raw_data;
754 struct nfs4_mount_data *real = raw_data;
756 /* copy the fields backwards */
757 real->auth_flavours = compat_ptr(raw->auth_flavours);
758 real->auth_flavourlen = raw->auth_flavourlen;
759 real->proto = raw->proto;
760 real->host_addr = compat_ptr(raw->host_addr);
761 real->host_addrlen = raw->host_addrlen;
762 compat_nfs_string(&real->hostname, &raw->hostname);
763 compat_nfs_string(&real->mnt_path, &raw->mnt_path);
764 compat_nfs_string(&real->client_addr, &raw->client_addr);
765 real->acdirmax = raw->acdirmax;
766 real->acdirmin = raw->acdirmin;
767 real->acregmax = raw->acregmax;
768 real->acregmin = raw->acregmin;
769 real->retrans = raw->retrans;
770 real->timeo = raw->timeo;
771 real->wsize = raw->wsize;
772 real->rsize = raw->rsize;
773 real->flags = raw->flags;
774 real->version = raw->version;
783 extern int copy_mount_options (const void __user *, unsigned long *);
785 #define SMBFS_NAME "smbfs"
786 #define NCPFS_NAME "ncpfs"
787 #define NFS4_NAME "nfs4"
789 asmlinkage long compat_sys_mount(char __user * dev_name, char __user * dir_name,
790 char __user * type, unsigned long flags,
793 unsigned long type_page;
794 unsigned long data_page;
795 unsigned long dev_page;
799 retval = copy_mount_options (type, &type_page);
803 dir_page = getname(dir_name);
804 retval = PTR_ERR(dir_page);
805 if (IS_ERR(dir_page))
808 retval = copy_mount_options (dev_name, &dev_page);
812 retval = copy_mount_options (data, &data_page);
819 if (!strcmp((char *)type_page, SMBFS_NAME)) {
820 do_smb_super_data_conv((void *)data_page);
821 } else if (!strcmp((char *)type_page, NCPFS_NAME)) {
822 do_ncp_super_data_conv((void *)data_page);
823 } else if (!strcmp((char *)type_page, NFS4_NAME)) {
824 if (do_nfs4_super_data_conv((void *) data_page))
830 retval = do_mount((char*)dev_page, dir_page, (char*)type_page,
831 flags, (void*)data_page);
835 free_page(data_page);
841 free_page(type_page);
846 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
847 #define COMPAT_ROUND_UP(x) (((x)+sizeof(compat_long_t)-1) & \
848 ~(sizeof(compat_long_t)-1))
850 struct compat_old_linux_dirent {
851 compat_ulong_t d_ino;
852 compat_ulong_t d_offset;
853 unsigned short d_namlen;
857 struct compat_readdir_callback {
858 struct compat_old_linux_dirent __user *dirent;
862 static int compat_fillonedir(void *__buf, const char *name, int namlen,
863 loff_t offset, ino_t ino, unsigned int d_type)
865 struct compat_readdir_callback *buf = __buf;
866 struct compat_old_linux_dirent __user *dirent;
871 dirent = buf->dirent;
872 if (!access_ok(VERIFY_WRITE, dirent,
873 (unsigned long)(dirent->d_name + namlen + 1) -
874 (unsigned long)dirent))
876 if ( __put_user(ino, &dirent->d_ino) ||
877 __put_user(offset, &dirent->d_offset) ||
878 __put_user(namlen, &dirent->d_namlen) ||
879 __copy_to_user(dirent->d_name, name, namlen) ||
880 __put_user(0, dirent->d_name + namlen))
884 buf->result = -EFAULT;
888 asmlinkage long compat_sys_old_readdir(unsigned int fd,
889 struct compat_old_linux_dirent __user *dirent, unsigned int count)
893 struct compat_readdir_callback buf;
903 error = vfs_readdir(file, compat_fillonedir, &buf);
912 struct compat_linux_dirent {
913 compat_ulong_t d_ino;
914 compat_ulong_t d_off;
915 unsigned short d_reclen;
919 struct compat_getdents_callback {
920 struct compat_linux_dirent __user *current_dir;
921 struct compat_linux_dirent __user *previous;
926 static int compat_filldir(void *__buf, const char *name, int namlen,
927 loff_t offset, ino_t ino, unsigned int d_type)
929 struct compat_linux_dirent __user * dirent;
930 struct compat_getdents_callback *buf = __buf;
931 int reclen = COMPAT_ROUND_UP(NAME_OFFSET(dirent) + namlen + 2);
933 buf->error = -EINVAL; /* only used if we fail.. */
934 if (reclen > buf->count)
936 dirent = buf->previous;
938 if (__put_user(offset, &dirent->d_off))
941 dirent = buf->current_dir;
942 if (__put_user(ino, &dirent->d_ino))
944 if (__put_user(reclen, &dirent->d_reclen))
946 if (copy_to_user(dirent->d_name, name, namlen))
948 if (__put_user(0, dirent->d_name + namlen))
950 if (__put_user(d_type, (char __user *) dirent + reclen - 1))
952 buf->previous = dirent;
953 dirent = (void __user *)dirent + reclen;
954 buf->current_dir = dirent;
955 buf->count -= reclen;
958 buf->error = -EFAULT;
962 asmlinkage long compat_sys_getdents(unsigned int fd,
963 struct compat_linux_dirent __user *dirent, unsigned int count)
966 struct compat_linux_dirent __user * lastdirent;
967 struct compat_getdents_callback buf;
971 if (!access_ok(VERIFY_WRITE, dirent, count))
979 buf.current_dir = dirent;
984 error = vfs_readdir(file, compat_filldir, &buf);
988 lastdirent = buf.previous;
990 if (put_user(file->f_pos, &lastdirent->d_off))
993 error = count - buf.count;
1002 #ifndef __ARCH_OMIT_COMPAT_SYS_GETDENTS64
1003 #define COMPAT_ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))
1005 struct compat_getdents_callback64 {
1006 struct linux_dirent64 __user *current_dir;
1007 struct linux_dirent64 __user *previous;
1012 static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t offset,
1013 ino_t ino, unsigned int d_type)
1015 struct linux_dirent64 __user *dirent;
1016 struct compat_getdents_callback64 *buf = __buf;
1017 int jj = NAME_OFFSET(dirent);
1018 int reclen = COMPAT_ROUND_UP64(jj + namlen + 1);
1021 buf->error = -EINVAL; /* only used if we fail.. */
1022 if (reclen > buf->count)
1024 dirent = buf->previous;
1027 if (__put_user_unaligned(offset, &dirent->d_off))
1030 dirent = buf->current_dir;
1031 if (__put_user_unaligned(ino, &dirent->d_ino))
1034 if (__put_user_unaligned(off, &dirent->d_off))
1036 if (__put_user(reclen, &dirent->d_reclen))
1038 if (__put_user(d_type, &dirent->d_type))
1040 if (copy_to_user(dirent->d_name, name, namlen))
1042 if (__put_user(0, dirent->d_name + namlen))
1044 buf->previous = dirent;
1045 dirent = (void __user *)dirent + reclen;
1046 buf->current_dir = dirent;
1047 buf->count -= reclen;
1050 buf->error = -EFAULT;
1054 asmlinkage long compat_sys_getdents64(unsigned int fd,
1055 struct linux_dirent64 __user * dirent, unsigned int count)
1058 struct linux_dirent64 __user * lastdirent;
1059 struct compat_getdents_callback64 buf;
1063 if (!access_ok(VERIFY_WRITE, dirent, count))
1071 buf.current_dir = dirent;
1072 buf.previous = NULL;
1076 error = vfs_readdir(file, compat_filldir64, &buf);
1080 lastdirent = buf.previous;
1082 typeof(lastdirent->d_off) d_off = file->f_pos;
1083 __put_user_unaligned(d_off, &lastdirent->d_off);
1084 error = count - buf.count;
1092 #endif /* ! __ARCH_OMIT_COMPAT_SYS_GETDENTS64 */
1094 static ssize_t compat_do_readv_writev(int type, struct file *file,
1095 const struct compat_iovec __user *uvector,
1096 unsigned long nr_segs, loff_t *pos)
1098 typedef ssize_t (*io_fn_t)(struct file *, char __user *, size_t, loff_t *);
1099 typedef ssize_t (*iov_fn_t)(struct file *, const struct iovec *, unsigned long, loff_t *);
1101 compat_ssize_t tot_len;
1102 struct iovec iovstack[UIO_FASTIOV];
1103 struct iovec *iov=iovstack, *vector;
1110 * SuS says "The readv() function *may* fail if the iovcnt argument
1111 * was less than or equal to 0, or greater than {IOV_MAX}. Linux has
1112 * traditionally returned zero for zero segments, so...
1119 * First get the "struct iovec" from user memory and
1120 * verify all the pointers
1123 if ((nr_segs > UIO_MAXIOV) || (nr_segs <= 0))
1127 if (nr_segs > UIO_FASTIOV) {
1129 iov = kmalloc(nr_segs*sizeof(struct iovec), GFP_KERNEL);
1134 if (!access_ok(VERIFY_READ, uvector, nr_segs*sizeof(*uvector)))
1138 * Single unix specification:
1139 * We should -EINVAL if an element length is not >= 0 and fitting an
1140 * ssize_t. The total length is fitting an ssize_t
1142 * Be careful here because iov_len is a size_t not an ssize_t
1147 for (seg = 0 ; seg < nr_segs; seg++) {
1148 compat_ssize_t tmp = tot_len;
1152 if (__get_user(len, &uvector->iov_len) ||
1153 __get_user(buf, &uvector->iov_base)) {
1157 if (len < 0) /* size_t not fitting an compat_ssize_t .. */
1160 if (tot_len < tmp) /* maths overflow on the compat_ssize_t */
1162 vector->iov_base = compat_ptr(buf);
1163 vector->iov_len = (compat_size_t) len;
1172 ret = rw_verify_area(type, file, pos, tot_len);
1178 fn = file->f_op->read;
1179 fnv = file->f_op->readv;
1181 fn = (io_fn_t)file->f_op->write;
1182 fnv = file->f_op->writev;
1185 ret = fnv(file, iov, nr_segs, pos);
1189 /* Do it by hand, with file-ops */
1192 while (nr_segs > 0) {
1197 base = vector->iov_base;
1198 len = vector->iov_len;
1202 nr = fn(file, base, len, pos);
1213 if (iov != iovstack)
1215 if ((ret + (type == READ)) > 0) {
1216 struct dentry *dentry = file->f_dentry;
1218 fsnotify_access(dentry);
1220 fsnotify_modify(dentry);
1226 compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec, unsigned long vlen)
1229 ssize_t ret = -EBADF;
1235 if (!(file->f_mode & FMODE_READ))
1239 if (!file->f_op || (!file->f_op->readv && !file->f_op->read))
1242 ret = compat_do_readv_writev(READ, file, vec, vlen, &file->f_pos);
1250 compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec, unsigned long vlen)
1253 ssize_t ret = -EBADF;
1258 if (!(file->f_mode & FMODE_WRITE))
1262 if (!file->f_op || (!file->f_op->writev && !file->f_op->write))
1265 ret = compat_do_readv_writev(WRITE, file, vec, vlen, &file->f_pos);
1273 * Exactly like fs/open.c:sys_open(), except that it doesn't set the
1277 compat_sys_open(const char __user *filename, int flags, int mode)
1279 return do_sys_open(filename, flags, mode);
1283 * compat_count() counts the number of arguments/envelopes. It is basically
1284 * a copy of count() from fs/exec.c, except that it works with 32 bit argv
1285 * and envp pointers.
1287 static int compat_count(compat_uptr_t __user *argv, int max)
1295 if (get_user(p, argv))
1308 * compat_copy_strings() is basically a copy of copy_strings() from fs/exec.c
1309 * except that it works with 32 bit argv and envp pointers.
1311 static int compat_copy_strings(int argc, compat_uptr_t __user *argv,
1312 struct linux_binprm *bprm)
1314 struct page *kmapped_page = NULL;
1318 while (argc-- > 0) {
1323 if (get_user(str, argv+argc) ||
1324 !(len = strnlen_user(compat_ptr(str), bprm->p))) {
1329 if (bprm->p < len) {
1335 /* XXX: add architecture specific overflow check here. */
1340 int offset, bytes_to_copy;
1343 offset = pos % PAGE_SIZE;
1345 page = bprm->page[i];
1348 page = alloc_page(GFP_HIGHUSER);
1349 bprm->page[i] = page;
1357 if (page != kmapped_page) {
1359 kunmap(kmapped_page);
1360 kmapped_page = page;
1361 kaddr = kmap(kmapped_page);
1364 memset(kaddr, 0, offset);
1365 bytes_to_copy = PAGE_SIZE - offset;
1366 if (bytes_to_copy > len) {
1367 bytes_to_copy = len;
1369 memset(kaddr+offset+len, 0,
1370 PAGE_SIZE-offset-len);
1372 err = copy_from_user(kaddr+offset, compat_ptr(str),
1379 pos += bytes_to_copy;
1380 str += bytes_to_copy;
1381 len -= bytes_to_copy;
1387 kunmap(kmapped_page);
1393 #define free_arg_pages(bprm) do { } while (0)
1397 static inline void free_arg_pages(struct linux_binprm *bprm)
1401 for (i = 0; i < MAX_ARG_PAGES; i++) {
1403 __free_page(bprm->page[i]);
1404 bprm->page[i] = NULL;
1408 #endif /* CONFIG_MMU */
1411 * compat_do_execve() is mostly a copy of do_execve(), with the exception
1412 * that it processes 32 bit argv and envp pointers.
1414 int compat_do_execve(char * filename,
1415 compat_uptr_t __user *argv,
1416 compat_uptr_t __user *envp,
1417 struct pt_regs * regs)
1419 struct linux_binprm *bprm;
1425 bprm = kmalloc(sizeof(*bprm), GFP_KERNEL);
1428 memset(bprm, 0, sizeof(*bprm));
1430 file = open_exec(filename);
1431 retval = PTR_ERR(file);
1437 bprm->p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
1439 bprm->filename = filename;
1440 bprm->interp = filename;
1441 bprm->mm = mm_alloc();
1446 retval = init_new_context(current, bprm->mm);
1450 bprm->argc = compat_count(argv, bprm->p / sizeof(compat_uptr_t));
1451 if ((retval = bprm->argc) < 0)
1454 bprm->envc = compat_count(envp, bprm->p / sizeof(compat_uptr_t));
1455 if ((retval = bprm->envc) < 0)
1458 retval = security_bprm_alloc(bprm);
1462 retval = prepare_binprm(bprm);
1466 retval = copy_strings_kernel(1, &bprm->filename, bprm);
1470 bprm->exec = bprm->p;
1471 retval = compat_copy_strings(bprm->envc, envp, bprm);
1475 retval = compat_copy_strings(bprm->argc, argv, bprm);
1479 retval = search_binary_handler(bprm, regs);
1481 free_arg_pages(bprm);
1483 /* execve success */
1484 security_bprm_free(bprm);
1485 acct_update_integrals(current);
1491 /* Something went wrong, return the inode and free the argument pages*/
1492 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
1493 struct page * page = bprm->page[i];
1499 security_bprm_free(bprm);
1507 allow_write_access(bprm->file);
1518 #define __COMPAT_NFDBITS (8 * sizeof(compat_ulong_t))
1520 #define ROUND_UP(x,y) (((x)+(y)-1)/(y))
1523 * Ooo, nasty. We need here to frob 32-bit unsigned longs to
1524 * 64-bit unsigned longs.
1527 int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1528 unsigned long *fdset)
1530 nr = ROUND_UP(nr, __COMPAT_NFDBITS);
1534 if (!access_ok(VERIFY_WRITE, ufdset, nr*sizeof(compat_ulong_t)))
1541 __get_user(l, ufdset);
1542 __get_user(h, ufdset+1);
1544 *fdset++ = h << 32 | l;
1548 __get_user(*fdset, ufdset);
1550 /* Tricky, must clear full unsigned long in the
1551 * kernel fdset at the end, this makes sure that
1554 memset(fdset, 0, ((nr + 1) & ~1)*sizeof(compat_ulong_t));
1560 void compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1561 unsigned long *fdset)
1564 nr = ROUND_UP(nr, __COMPAT_NFDBITS);
1575 __put_user(l, ufdset);
1576 __put_user(h, ufdset+1);
1581 __put_user(*fdset, ufdset);
1586 * This is a virtual copy of sys_select from fs/select.c and probably
1587 * should be compared to it from time to time
1589 static void *select_bits_alloc(int size)
1591 return kmalloc(6 * size, GFP_KERNEL);
1594 static void select_bits_free(void *bits, int size)
1600 * We can actually return ERESTARTSYS instead of EINTR, but I'd
1601 * like to be certain this leads to no problems. So I return
1602 * EINTR just for safety.
1604 * Update: ERESTARTSYS breaks at least the xview clock binary, so
1605 * I'm trying ERESTARTNOHAND which restart only when you want to.
1607 #define MAX_SELECT_SECONDS \
1608 ((unsigned long) (MAX_SCHEDULE_TIMEOUT / HZ)-1)
1611 compat_sys_select(int n, compat_ulong_t __user *inp, compat_ulong_t __user *outp,
1612 compat_ulong_t __user *exp, struct compat_timeval __user *tvp)
1617 int size, max_fdset, ret = -EINVAL;
1618 struct fdtable *fdt;
1620 timeout = MAX_SCHEDULE_TIMEOUT;
1624 if (!access_ok(VERIFY_READ, tvp, sizeof(*tvp))
1625 || __get_user(sec, &tvp->tv_sec)
1626 || __get_user(usec, &tvp->tv_usec)) {
1631 if (sec < 0 || usec < 0)
1634 if ((unsigned long) sec < MAX_SELECT_SECONDS) {
1635 timeout = ROUND_UP(usec, 1000000/HZ);
1636 timeout += sec * (unsigned long) HZ;
1643 /* max_fdset can increase, so grab it once to avoid race */
1645 fdt = files_fdtable(current->files);
1646 max_fdset = fdt->max_fdset;
1652 * We need 6 bitmaps (in/out/ex for both incoming and outgoing),
1653 * since we used fdset we need to allocate memory in units of
1657 size = FDS_BYTES(n);
1658 bits = select_bits_alloc(size);
1661 fds.in = (unsigned long *) bits;
1662 fds.out = (unsigned long *) (bits + size);
1663 fds.ex = (unsigned long *) (bits + 2*size);
1664 fds.res_in = (unsigned long *) (bits + 3*size);
1665 fds.res_out = (unsigned long *) (bits + 4*size);
1666 fds.res_ex = (unsigned long *) (bits + 5*size);
1668 if ((ret = compat_get_fd_set(n, inp, fds.in)) ||
1669 (ret = compat_get_fd_set(n, outp, fds.out)) ||
1670 (ret = compat_get_fd_set(n, exp, fds.ex)))
1672 zero_fd_set(n, fds.res_in);
1673 zero_fd_set(n, fds.res_out);
1674 zero_fd_set(n, fds.res_ex);
1676 ret = do_select(n, &fds, &timeout);
1678 if (tvp && !(current->personality & STICKY_TIMEOUTS)) {
1679 time_t sec = 0, usec = 0;
1682 usec = timeout % HZ;
1683 usec *= (1000000/HZ);
1685 if (put_user(sec, &tvp->tv_sec) ||
1686 put_user(usec, &tvp->tv_usec))
1693 ret = -ERESTARTNOHAND;
1694 if (signal_pending(current))
1699 compat_set_fd_set(n, inp, fds.res_in);
1700 compat_set_fd_set(n, outp, fds.res_out);
1701 compat_set_fd_set(n, exp, fds.res_ex);
1704 select_bits_free(bits, size);
1709 #if defined(CONFIG_NFSD) || defined(CONFIG_NFSD_MODULE)
1710 /* Stuff for NFS server syscalls... */
1711 struct compat_nfsctl_svc {
1716 struct compat_nfsctl_client {
1717 s8 cl32_ident[NFSCLNT_IDMAX+1];
1719 struct in_addr cl32_addrlist[NFSCLNT_ADDRMAX];
1722 u8 cl32_fhkey[NFSCLNT_KEYMAX];
1725 struct compat_nfsctl_export {
1726 char ex32_client[NFSCLNT_IDMAX+1];
1727 char ex32_path[NFS_MAXPATHLEN+1];
1728 compat_dev_t ex32_dev;
1729 compat_ino_t ex32_ino;
1730 compat_int_t ex32_flags;
1731 __compat_uid_t ex32_anon_uid;
1732 __compat_gid_t ex32_anon_gid;
1735 struct compat_nfsctl_fdparm {
1736 struct sockaddr gd32_addr;
1737 s8 gd32_path[NFS_MAXPATHLEN+1];
1738 compat_int_t gd32_version;
1741 struct compat_nfsctl_fsparm {
1742 struct sockaddr gd32_addr;
1743 s8 gd32_path[NFS_MAXPATHLEN+1];
1744 compat_int_t gd32_maxlen;
1747 struct compat_nfsctl_arg {
1748 compat_int_t ca32_version; /* safeguard */
1750 struct compat_nfsctl_svc u32_svc;
1751 struct compat_nfsctl_client u32_client;
1752 struct compat_nfsctl_export u32_export;
1753 struct compat_nfsctl_fdparm u32_getfd;
1754 struct compat_nfsctl_fsparm u32_getfs;
1756 #define ca32_svc u.u32_svc
1757 #define ca32_client u.u32_client
1758 #define ca32_export u.u32_export
1759 #define ca32_getfd u.u32_getfd
1760 #define ca32_getfs u.u32_getfs
1763 union compat_nfsctl_res {
1764 __u8 cr32_getfh[NFS_FHSIZE];
1765 struct knfsd_fh cr32_getfs;
1768 static int compat_nfs_svc_trans(struct nfsctl_arg *karg, struct compat_nfsctl_arg __user *arg)
1772 err = access_ok(VERIFY_READ, &arg->ca32_svc, sizeof(arg->ca32_svc));
1773 err |= get_user(karg->ca_version, &arg->ca32_version);
1774 err |= __get_user(karg->ca_svc.svc_port, &arg->ca32_svc.svc32_port);
1775 err |= __get_user(karg->ca_svc.svc_nthreads, &arg->ca32_svc.svc32_nthreads);
1776 return (err) ? -EFAULT : 0;
1779 static int compat_nfs_clnt_trans(struct nfsctl_arg *karg, struct compat_nfsctl_arg __user *arg)
1783 err = access_ok(VERIFY_READ, &arg->ca32_client, sizeof(arg->ca32_client));
1784 err |= get_user(karg->ca_version, &arg->ca32_version);
1785 err |= __copy_from_user(&karg->ca_client.cl_ident[0],
1786 &arg->ca32_client.cl32_ident[0],
1788 err |= __get_user(karg->ca_client.cl_naddr, &arg->ca32_client.cl32_naddr);
1789 err |= __copy_from_user(&karg->ca_client.cl_addrlist[0],
1790 &arg->ca32_client.cl32_addrlist[0],
1791 (sizeof(struct in_addr) * NFSCLNT_ADDRMAX));
1792 err |= __get_user(karg->ca_client.cl_fhkeytype,
1793 &arg->ca32_client.cl32_fhkeytype);
1794 err |= __get_user(karg->ca_client.cl_fhkeylen,
1795 &arg->ca32_client.cl32_fhkeylen);
1796 err |= __copy_from_user(&karg->ca_client.cl_fhkey[0],
1797 &arg->ca32_client.cl32_fhkey[0],
1800 return (err) ? -EFAULT : 0;
1803 static int compat_nfs_exp_trans(struct nfsctl_arg *karg, struct compat_nfsctl_arg __user *arg)
1807 err = access_ok(VERIFY_READ, &arg->ca32_export, sizeof(arg->ca32_export));
1808 err |= get_user(karg->ca_version, &arg->ca32_version);
1809 err |= __copy_from_user(&karg->ca_export.ex_client[0],
1810 &arg->ca32_export.ex32_client[0],
1812 err |= __copy_from_user(&karg->ca_export.ex_path[0],
1813 &arg->ca32_export.ex32_path[0],
1815 err |= __get_user(karg->ca_export.ex_dev,
1816 &arg->ca32_export.ex32_dev);
1817 err |= __get_user(karg->ca_export.ex_ino,
1818 &arg->ca32_export.ex32_ino);
1819 err |= __get_user(karg->ca_export.ex_flags,
1820 &arg->ca32_export.ex32_flags);
1821 err |= __get_user(karg->ca_export.ex_anon_uid,
1822 &arg->ca32_export.ex32_anon_uid);
1823 err |= __get_user(karg->ca_export.ex_anon_gid,
1824 &arg->ca32_export.ex32_anon_gid);
1825 SET_UID(karg->ca_export.ex_anon_uid, karg->ca_export.ex_anon_uid);
1826 SET_GID(karg->ca_export.ex_anon_gid, karg->ca_export.ex_anon_gid);
1828 return (err) ? -EFAULT : 0;
1831 static int compat_nfs_getfd_trans(struct nfsctl_arg *karg, struct compat_nfsctl_arg __user *arg)
1835 err = access_ok(VERIFY_READ, &arg->ca32_getfd, sizeof(arg->ca32_getfd));
1836 err |= get_user(karg->ca_version, &arg->ca32_version);
1837 err |= __copy_from_user(&karg->ca_getfd.gd_addr,
1838 &arg->ca32_getfd.gd32_addr,
1839 (sizeof(struct sockaddr)));
1840 err |= __copy_from_user(&karg->ca_getfd.gd_path,
1841 &arg->ca32_getfd.gd32_path,
1842 (NFS_MAXPATHLEN+1));
1843 err |= __get_user(karg->ca_getfd.gd_version,
1844 &arg->ca32_getfd.gd32_version);
1846 return (err) ? -EFAULT : 0;
1849 static int compat_nfs_getfs_trans(struct nfsctl_arg *karg, struct compat_nfsctl_arg __user *arg)
1853 err = access_ok(VERIFY_READ, &arg->ca32_getfs, sizeof(arg->ca32_getfs));
1854 err |= get_user(karg->ca_version, &arg->ca32_version);
1855 err |= __copy_from_user(&karg->ca_getfs.gd_addr,
1856 &arg->ca32_getfs.gd32_addr,
1857 (sizeof(struct sockaddr)));
1858 err |= __copy_from_user(&karg->ca_getfs.gd_path,
1859 &arg->ca32_getfs.gd32_path,
1860 (NFS_MAXPATHLEN+1));
1861 err |= __get_user(karg->ca_getfs.gd_maxlen,
1862 &arg->ca32_getfs.gd32_maxlen);
1864 return (err) ? -EFAULT : 0;
1867 /* This really doesn't need translations, we are only passing
1868 * back a union which contains opaque nfs file handle data.
1870 static int compat_nfs_getfh_res_trans(union nfsctl_res *kres, union compat_nfsctl_res __user *res)
1874 err = copy_to_user(res, kres, sizeof(*res));
1876 return (err) ? -EFAULT : 0;
1879 asmlinkage long compat_sys_nfsservctl(int cmd, struct compat_nfsctl_arg __user *arg,
1880 union compat_nfsctl_res __user *res)
1882 struct nfsctl_arg *karg;
1883 union nfsctl_res *kres;
1887 karg = kmalloc(sizeof(*karg), GFP_USER);
1888 kres = kmalloc(sizeof(*kres), GFP_USER);
1889 if(!karg || !kres) {
1896 err = compat_nfs_svc_trans(karg, arg);
1899 case NFSCTL_ADDCLIENT:
1900 err = compat_nfs_clnt_trans(karg, arg);
1903 case NFSCTL_DELCLIENT:
1904 err = compat_nfs_clnt_trans(karg, arg);
1908 case NFSCTL_UNEXPORT:
1909 err = compat_nfs_exp_trans(karg, arg);
1913 err = compat_nfs_getfd_trans(karg, arg);
1917 err = compat_nfs_getfs_trans(karg, arg);
1927 /* The __user pointer casts are valid because of the set_fs() */
1928 err = sys_nfsservctl(cmd, (void __user *) karg, (void __user *) kres);
1934 if((cmd == NFSCTL_GETFD) ||
1935 (cmd == NFSCTL_GETFS))
1936 err = compat_nfs_getfh_res_trans(kres, res);
1944 long asmlinkage compat_sys_nfsservctl(int cmd, void *notused, void *notused2)
1946 return sys_ni_syscall();