Merge branch 'master' into upstream
[sfrench/cifs-2.6.git] / fs / compat.c
index b1f64786a613e598b5b5a06684f58d5cea8c0d5c..122b4e3992b54b322d40ef84814c95048ca00472 100644 (file)
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
 #include <asm/ioctls.h>
+#include "internal.h"
+
+int compat_log = 1;
 
 extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
 
+int compat_printk(const char *fmt, ...)
+{
+       va_list ap;
+       int ret;
+       if (!compat_log)
+               return 0;
+       va_start(ap, fmt);
+       ret = vprintk(fmt, ap);
+       va_end(ap);
+       return ret;
+}
+
 /*
  * Not all architectures have sys_utime, so implement this in terms
  * of sys_utimes.
@@ -197,7 +212,7 @@ asmlinkage long compat_sys_statfs(const char __user *path, struct compat_statfs
        error = user_path_walk(path, &nd);
        if (!error) {
                struct kstatfs tmp;
-               error = vfs_statfs(nd.dentry->d_inode->i_sb, &tmp);
+               error = vfs_statfs(nd.dentry, &tmp);
                if (!error)
                        error = put_compat_statfs(buf, &tmp);
                path_release(&nd);
@@ -215,7 +230,7 @@ asmlinkage long compat_sys_fstatfs(unsigned int fd, struct compat_statfs __user
        file = fget(fd);
        if (!file)
                goto out;
-       error = vfs_statfs(file->f_dentry->d_inode->i_sb, &tmp);
+       error = vfs_statfs(file->f_dentry, &tmp);
        if (!error)
                error = put_compat_statfs(buf, &tmp);
        fput(file);
@@ -265,7 +280,7 @@ asmlinkage long compat_sys_statfs64(const char __user *path, compat_size_t sz, s
        error = user_path_walk(path, &nd);
        if (!error) {
                struct kstatfs tmp;
-               error = vfs_statfs(nd.dentry->d_inode->i_sb, &tmp);
+               error = vfs_statfs(nd.dentry, &tmp);
                if (!error)
                        error = put_compat_statfs64(buf, &tmp);
                path_release(&nd);
@@ -286,7 +301,7 @@ asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct c
        file = fget(fd);
        if (!file)
                goto out;
-       error = vfs_statfs(file->f_dentry->d_inode->i_sb, &tmp);
+       error = vfs_statfs(file->f_dentry, &tmp);
        if (!error)
                error = put_compat_statfs64(buf, &tmp);
        fput(file);
@@ -299,9 +314,6 @@ out:
 #define IOCTL_HASHSIZE 256
 static struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE];
 
-extern struct ioctl_trans ioctl_start[];
-extern int ioctl_table_size;
-
 static inline unsigned long ioctl32_hash(unsigned long cmd)
 {
        return (((cmd >> 6) ^ (cmd >> 4) ^ cmd)) % IOCTL_HASHSIZE;
@@ -359,7 +371,7 @@ static void compat_ioctl_error(struct file *filp, unsigned int fd,
        sprintf(buf,"'%c'", (cmd>>24) & 0x3f);
        if (!isprint(buf[1]))
                sprintf(buf, "%02x", buf[1]);
-       printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
+       compat_printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
                        "cmd(%08x){%s} arg(%08x) on %s\n",
                        current->comm, current->pid,
                        (int)fd, (unsigned int)cmd, buf,
@@ -824,8 +836,6 @@ static int do_nfs4_super_data_conv(void *raw_data)
        return 0;
 }
 
-extern int copy_mount_options (const void __user *, unsigned long *);
-
 #define SMBFS_NAME      "smbfs"
 #define NCPFS_NAME      "ncpfs"
 #define NFS4_NAME      "nfs4"
@@ -1841,7 +1851,7 @@ asmlinkage long compat_sys_pselect7(int n, compat_ulong_t __user *inp,
 
        } while (!ret && !timeout && tsp && (ts.tv_sec || ts.tv_nsec));
 
-       if (tsp && !(current->personality & STICKY_TIMEOUTS)) {
+       if (ret == 0 && tsp && !(current->personality & STICKY_TIMEOUTS)) {
                struct compat_timespec rts;
 
                rts.tv_sec = timeout / HZ;
@@ -1852,7 +1862,8 @@ asmlinkage long compat_sys_pselect7(int n, compat_ulong_t __user *inp,
                }
                if (compat_timespec_compare(&rts, &ts) >= 0)
                        rts = ts;
-               copy_to_user(tsp, &rts, sizeof(rts));
+               if (copy_to_user(tsp, &rts, sizeof(rts)))
+                       ret = -EFAULT;
        }
 
        if (ret == -ERESTARTNOHAND) {