linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / fs / open.c
index bda0a59..d92305b 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
 #include <linux/pagemap.h>
 #include <linux/syscalls.h>
 #include <linux/rcupdate.h>
-#include <linux/audit.h>
 #include <linux/vs_limit.h>
 #include <linux/vs_dlimit.h>
 #include <linux/vserver/xid.h>
 
 #include <asm/unistd.h>
 
-int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
+int vfs_statfs(struct super_block *sb, struct kstatfs *buf)
 {
        int retval = -ENODEV;
 
-       if (dentry) {
-               struct super_block *sb = dentry->d_sb;
-
+       if (sb) {
                retval = -ENOSYS;
                if (sb->s_op->statfs) {
                        memset(buf, 0, sizeof(*buf));
-                       retval = security_sb_statfs(dentry);
+                       retval = security_sb_statfs(sb);
                        if (retval)
                                return retval;
-                       retval = sb->s_op->statfs(dentry, buf);
+                       retval = sb->s_op->statfs(sb, buf);
                        if (retval == 0 && buf->f_frsize == 0)
                                buf->f_frsize = buf->f_bsize;
                }
@@ -59,12 +56,12 @@ int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 
 EXPORT_SYMBOL(vfs_statfs);
 
-static int vfs_statfs_native(struct dentry *dentry, struct statfs *buf)
+static int vfs_statfs_native(struct super_block *sb, struct statfs *buf)
 {
        struct kstatfs st;
        int retval;
 
-       retval = vfs_statfs(dentry, &st);
+       retval = vfs_statfs(sb, &st);
        if (retval)
                return retval;
 
@@ -102,12 +99,12 @@ static int vfs_statfs_native(struct dentry *dentry, struct statfs *buf)
        return 0;
 }
 
-static int vfs_statfs64(struct dentry *dentry, struct statfs64 *buf)
+static int vfs_statfs64(struct super_block *sb, struct statfs64 *buf)
 {
        struct kstatfs st;
        int retval;
 
-       retval = vfs_statfs(dentry, &st);
+       retval = vfs_statfs(sb, &st);
        if (retval)
                return retval;
 
@@ -137,7 +134,7 @@ asmlinkage long sys_statfs(const char __user * path, struct statfs __user * buf)
        error = user_path_walk(path, &nd);
        if (!error) {
                struct statfs tmp;
-               error = vfs_statfs_native(nd.dentry, &tmp);
+               error = vfs_statfs_native(nd.dentry->d_inode->i_sb, &tmp);
                if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
                        error = -EFAULT;
                path_release(&nd);
@@ -156,7 +153,7 @@ asmlinkage long sys_statfs64(const char __user *path, size_t sz, struct statfs64
        error = user_path_walk(path, &nd);
        if (!error) {
                struct statfs64 tmp;
-               error = vfs_statfs64(nd.dentry, &tmp);
+               error = vfs_statfs64(nd.dentry->d_inode->i_sb, &tmp);
                if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
                        error = -EFAULT;
                path_release(&nd);
@@ -175,7 +172,7 @@ asmlinkage long sys_fstatfs(unsigned int fd, struct statfs __user * buf)
        file = fget(fd);
        if (!file)
                goto out;
-       error = vfs_statfs_native(file->f_dentry, &tmp);
+       error = vfs_statfs_native(file->f_dentry->d_inode->i_sb, &tmp);
        if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
                error = -EFAULT;
        fput(file);
@@ -196,7 +193,7 @@ asmlinkage long sys_fstatfs64(unsigned int fd, size_t sz, struct statfs64 __user
        file = fget(fd);
        if (!file)
                goto out;
-       error = vfs_statfs64(file->f_dentry, &tmp);
+       error = vfs_statfs64(file->f_dentry->d_inode->i_sb, &tmp);
        if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
                error = -EFAULT;
        fput(file);
@@ -329,7 +326,7 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
 
        error = locks_verify_truncate(inode, file, length);
        if (!error)
-               error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
+               error = do_truncate(dentry, length, 0, file);
 out_putf:
        fput(file);
 out:
@@ -570,8 +567,6 @@ out:
        return error;
 }
 
-EXPORT_SYMBOL_GPL(sys_chdir);
-
 asmlinkage long sys_fchdir(unsigned int fd)
 {
        struct file *file;
@@ -628,8 +623,6 @@ out:
        return error;
 }
 
-EXPORT_SYMBOL_GPL(sys_chroot);
-
 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
 {
        struct inode * inode;
@@ -645,8 +638,6 @@ asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
        dentry = file->f_dentry;
        inode = dentry->d_inode;
 
-       audit_inode(NULL, inode);
-
        err = -EROFS;
        if (IS_RDONLY(inode) || MNT_IS_RDONLY(file->f_vfsmnt))
                goto out_putf;
@@ -797,10 +788,7 @@ asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group)
 
        file = fget(fd);
        if (file) {
-               struct dentry * dentry;
-               dentry = file->f_dentry;
-               audit_inode(NULL, dentry->d_inode);
-               error = chown_common(dentry, file->f_vfsmnt, user, group);
+               error = chown_common(file->f_dentry, file->f_vfsmnt, user, group);
                fput(file);
        }
        return error;
@@ -915,10 +903,6 @@ EXPORT_SYMBOL(filp_open);
  * a fully instantiated struct file to the caller.
  * This function is meant to be called from within a filesystem's
  * lookup method.
- * Beware of calling it for non-regular files! Those ->open methods might block
- * (e.g. in fifo_open), leaving you with parent locked (and in case of fifo,
- * leading to a deadlock, as nobody can open that fifo anymore, because
- * another process to open fifo will block on locked parent when doing lookup).
  * Note that in case of error, nd->intent.open.file is destroyed, but the
  * path information remains valid.
  * If the open callback is set to NULL, then the standard f_op->open()
@@ -1002,7 +986,7 @@ repeat:
        fdt = files_fdtable(files);
        fd = find_next_zero_bit(fdt->open_fds->fds_bits,
                                fdt->max_fdset,
-                               files->next_fd);
+                               fdt->next_fd);
 
        /*
         * N.B. For clone tasks sharing a files structure, this test
@@ -1027,7 +1011,7 @@ repeat:
 
        FD_SET(fd, fdt->open_fds);
        FD_CLR(fd, fdt->close_on_exec);
-       files->next_fd = fd + 1;
+       fdt->next_fd = fd + 1;
        vx_openfd_inc(fd);
 #if 1
        /* Sanity check */
@@ -1049,8 +1033,8 @@ static void __put_unused_fd(struct files_struct *files, unsigned int fd)
 {
        struct fdtable *fdt = files_fdtable(files);
        __FD_CLR(fd, fdt->open_fds);
-       if (fd < files->next_fd)
-               files->next_fd = fd;
+       if (fd < fdt->next_fd)
+               fdt->next_fd = fd;
        vx_openfd_dec(fd);
 }
 
@@ -1124,6 +1108,7 @@ asmlinkage long sys_open(const char __user *filename, int flags, int mode)
        prevent_tail_call(ret);
        return ret;
 }
+EXPORT_SYMBOL_GPL(sys_open);
 
 asmlinkage long sys_openat(int dfd, const char __user *filename, int flags,
                           int mode)
@@ -1138,6 +1123,7 @@ asmlinkage long sys_openat(int dfd, const char __user *filename, int flags,
        prevent_tail_call(ret);
        return ret;
 }
+EXPORT_SYMBOL_GPL(sys_openat);
 
 #ifndef __alpha__
 
@@ -1166,7 +1152,7 @@ int filp_close(struct file *filp, fl_owner_t id)
        }
 
        if (filp->f_op && filp->f_op->flush)
-               retval = filp->f_op->flush(filp, id);
+               retval = filp->f_op->flush(filp);
 
        dnotify_flush(filp, id);
        locks_remove_posix(filp, id);
@@ -1214,7 +1200,6 @@ EXPORT_SYMBOL(sys_close);
 asmlinkage long sys_vhangup(void)
 {
        if (capable(CAP_SYS_TTY_CONFIG)) {
-               /* XXX: this needs locking */
                tty_vhangup(current->signal->tty);
                return 0;
        }