This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / fs / open.c
index 6c81173..2f25b14 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -44,8 +44,6 @@ int vfs_statfs(struct super_block *sb, struct kstatfs *buf)
                        if (retval == 0 && buf->f_frsize == 0)
                                buf->f_frsize = buf->f_bsize;
                }
-               if (!vx_check(0, VX_ADMIN|VX_WATCH))
-                       vx_vsi_statfs(sb, buf);
        }
        return retval;
 }
@@ -245,7 +243,7 @@ static inline long do_sys_truncate(const char __user * path, loff_t length)
                goto dput_and_out;
 
        error = -EROFS;
-       if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
+       if (IS_RDONLY(inode))
                goto dput_and_out;
 
        error = -EPERM;
@@ -369,7 +367,7 @@ asmlinkage long sys_utime(char __user * filename, struct utimbuf __user * times)
        inode = nd.dentry->d_inode;
 
        error = -EROFS;
-       if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
+       if (IS_RDONLY(inode))
                goto dput_and_out;
 
        /* Don't worry, the checks are done in inode_change_ok() */
@@ -426,7 +424,7 @@ long do_utimes(char __user * filename, struct timeval * times)
        inode = nd.dentry->d_inode;
 
        error = -EROFS;
-       if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
+       if (IS_RDONLY(inode))
                goto dput_and_out;
 
        /* Don't worry, the checks are done in inode_change_ok() */
@@ -508,8 +506,7 @@ asmlinkage long sys_access(const char __user * filename, int mode)
        if (!res) {
                res = permission(nd.dentry->d_inode, mode, &nd);
                /* SuS v2 requires we report a read only fs too */
-               if(!res && (mode & S_IWOTH)
-                  && (IS_RDONLY(nd.dentry->d_inode) || MNT_IS_RDONLY(nd.mnt))
+               if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
                   && !special_file(nd.dentry->d_inode->i_mode))
                        res = -EROFS;
                path_release(&nd);
@@ -614,8 +611,11 @@ asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
        dentry = file->f_dentry;
        inode = dentry->d_inode;
 
+       err = -EPERM;
+       if (IS_BARRIER(inode) && !vx_check(0, VX_ADMIN))
+               goto out_putf;
        err = -EROFS;
-       if (IS_RDONLY(inode) || (file && MNT_IS_RDONLY(file->f_vfsmnt)))
+       if (IS_RDONLY(inode))
                goto out_putf;
        err = -EPERM;
        if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
@@ -646,8 +646,12 @@ asmlinkage long sys_chmod(const char __user * filename, mode_t mode)
                goto out;
        inode = nd.dentry->d_inode;
 
+       error = -EPERM;
+       if (IS_BARRIER(inode) && !vx_check(0, VX_ADMIN))
+               goto dput_and_out;
+
        error = -EROFS;
-       if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
+       if (IS_RDONLY(inode))
                goto dput_and_out;
 
        error = -EPERM;
@@ -668,8 +672,7 @@ out:
        return error;
 }
 
-static int chown_common(struct dentry *dentry, struct vfsmount *mnt,
-       uid_t user, gid_t group)
+static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
 {
        struct inode * inode;
        int error;
@@ -681,7 +684,7 @@ static int chown_common(struct dentry *dentry, struct vfsmount *mnt,
                goto out;
        }
        error = -EROFS;
-       if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
+       if (IS_RDONLY(inode))
                goto out;
        error = -EPERM;
        if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
@@ -712,7 +715,7 @@ asmlinkage long sys_chown(const char __user * filename, uid_t user, gid_t group)
 
        error = user_path_walk(filename, &nd);
        if (!error) {
-               error = chown_common(nd.dentry, nd.mnt, user, group);
+               error = chown_common(nd.dentry, user, group);
                path_release(&nd);
        }
        return error;
@@ -725,7 +728,7 @@ asmlinkage long sys_lchown(const char __user * filename, uid_t user, gid_t group
 
        error = user_path_walk_link(filename, &nd);
        if (!error) {
-               error = chown_common(nd.dentry, nd.mnt, user, group);
+               error = chown_common(nd.dentry, user, group);
                path_release(&nd);
        }
        return error;
@@ -739,7 +742,7 @@ asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group)
 
        file = fget(fd);
        if (file) {
-               error = chown_common(file->f_dentry, file->f_vfsmnt, user, group);
+               error = chown_common(file->f_dentry, user, group);
                fput(file);
        }
        return error;
@@ -790,7 +793,7 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
        if (!f)
                goto cleanup_dentry;
        f->f_flags = flags;
-       f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE;
+       f->f_mode = (flags+1) & O_ACCMODE;
        inode = dentry->d_inode;
        if (f->f_mode & FMODE_WRITE) {
                error = get_write_access(inode);
@@ -889,7 +892,7 @@ repeat:
        FD_SET(fd, files->open_fds);
        FD_CLR(fd, files->close_on_exec);
        files->next_fd = fd + 1;
-       // vx_openfd_inc(fd);
+       vx_openfd_inc(fd);
 #if 1
        /* Sanity check */
        if (files->fd[fd] != NULL) {
@@ -911,7 +914,6 @@ static inline void __put_unused_fd(struct files_struct *files, unsigned int fd)
        __FD_CLR(fd, files->open_fds);
        if (fd < files->next_fd)
                files->next_fd = fd;
-       // vx_openfd_dec(fd);
 }
 
 void fastcall put_unused_fd(unsigned int fd)
@@ -1044,6 +1046,7 @@ asmlinkage long sys_close(unsigned int fd)
        FD_CLR(fd, files->close_on_exec);
        __put_unused_fd(files, fd);
        spin_unlock(&files->file_lock);
+       vx_openfd_dec(fd);
        return filp_close(filp, files);
 
 out_unlock:
@@ -1079,15 +1082,3 @@ int generic_file_open(struct inode * inode, struct file * filp)
 }
 
 EXPORT_SYMBOL(generic_file_open);
-
-/*
- * This is used by subsystems that don't want seekable
- * file descriptors
- */
-int nonseekable_open(struct inode *inode, struct file *filp)
-{
-       filp->f_mode &= ~(FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE);
-       return 0;
-}
-
-EXPORT_SYMBOL(nonseekable_open);