mlx4_core: CQ resizing should pass a 0 opcode modifier to MODIFY_CQ
[safe/jmp/linux-2.6] / fs / xattr.c
index f7c8f87..f7062da 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/slab.h>
 #include <linux/file.h>
 #include <linux/xattr.h>
+#include <linux/mount.h>
 #include <linux/namei.h>
 #include <linux/security.h>
 #include <linux/syscalls.h>
@@ -32,8 +33,6 @@ xattr_permission(struct inode *inode, const char *name, int mask)
         * filesystem  or on an immutable / append-only inode.
         */
        if (mask & MAY_WRITE) {
-               if (IS_RDONLY(inode))
-                       return -EROFS;
                if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
                        return -EPERM;
        }
@@ -262,8 +261,12 @@ sys_setxattr(char __user *path, char __user *name, void __user *value,
        error = user_path_walk(path, &nd);
        if (error)
                return error;
-       error = setxattr(nd.dentry, name, value, size, flags);
-       path_release(&nd);
+       error = mnt_want_write(nd.path.mnt);
+       if (!error) {
+               error = setxattr(nd.path.dentry, name, value, size, flags);
+               mnt_drop_write(nd.path.mnt);
+       }
+       path_put(&nd.path);
        return error;
 }
 
@@ -277,8 +280,12 @@ sys_lsetxattr(char __user *path, char __user *name, void __user *value,
        error = user_path_walk_link(path, &nd);
        if (error)
                return error;
-       error = setxattr(nd.dentry, name, value, size, flags);
-       path_release(&nd);
+       error = mnt_want_write(nd.path.mnt);
+       if (!error) {
+               error = setxattr(nd.path.dentry, name, value, size, flags);
+               mnt_drop_write(nd.path.mnt);
+       }
+       path_put(&nd.path);
        return error;
 }
 
@@ -295,7 +302,12 @@ sys_fsetxattr(int fd, char __user *name, void __user *value,
                return error;
        dentry = f->f_path.dentry;
        audit_inode(NULL, dentry);
-       error = setxattr(dentry, name, value, size, flags);
+       error = mnt_want_write(f->f_path.mnt);
+       if (!error) {
+               error = setxattr(dentry, name, value, size, flags);
+               mnt_drop_write(f->f_path.mnt);
+       }
+out_fput:
        fput(f);
        return error;
 }
@@ -347,8 +359,8 @@ sys_getxattr(char __user *path, char __user *name, void __user *value,
        error = user_path_walk(path, &nd);
        if (error)
                return error;
-       error = getxattr(nd.dentry, name, value, size);
-       path_release(&nd);
+       error = getxattr(nd.path.dentry, name, value, size);
+       path_put(&nd.path);
        return error;
 }
 
@@ -362,8 +374,8 @@ sys_lgetxattr(char __user *path, char __user *name, void __user *value,
        error = user_path_walk_link(path, &nd);
        if (error)
                return error;
-       error = getxattr(nd.dentry, name, value, size);
-       path_release(&nd);
+       error = getxattr(nd.path.dentry, name, value, size);
+       path_put(&nd.path);
        return error;
 }
 
@@ -421,8 +433,8 @@ sys_listxattr(char __user *path, char __user *list, size_t size)
        error = user_path_walk(path, &nd);
        if (error)
                return error;
-       error = listxattr(nd.dentry, list, size);
-       path_release(&nd);
+       error = listxattr(nd.path.dentry, list, size);
+       path_put(&nd.path);
        return error;
 }
 
@@ -435,8 +447,8 @@ sys_llistxattr(char __user *path, char __user *list, size_t size)
        error = user_path_walk_link(path, &nd);
        if (error)
                return error;
-       error = listxattr(nd.dentry, list, size);
-       path_release(&nd);
+       error = listxattr(nd.path.dentry, list, size);
+       path_put(&nd.path);
        return error;
 }
 
@@ -482,8 +494,12 @@ sys_removexattr(char __user *path, char __user *name)
        error = user_path_walk(path, &nd);
        if (error)
                return error;
-       error = removexattr(nd.dentry, name);
-       path_release(&nd);
+       error = mnt_want_write(nd.path.mnt);
+       if (!error) {
+               error = removexattr(nd.path.dentry, name);
+               mnt_drop_write(nd.path.mnt);
+       }
+       path_put(&nd.path);
        return error;
 }
 
@@ -496,8 +512,12 @@ sys_lremovexattr(char __user *path, char __user *name)
        error = user_path_walk_link(path, &nd);
        if (error)
                return error;
-       error = removexattr(nd.dentry, name);
-       path_release(&nd);
+       error = mnt_want_write(nd.path.mnt);
+       if (!error) {
+               error = removexattr(nd.path.dentry, name);
+               mnt_drop_write(nd.path.mnt);
+       }
+       path_put(&nd.path);
        return error;
 }
 
@@ -513,7 +533,11 @@ sys_fremovexattr(int fd, char __user *name)
                return error;
        dentry = f->f_path.dentry;
        audit_inode(NULL, dentry);
-       error = removexattr(dentry, name);
+       error = mnt_want_write(f->f_path.mnt);
+       if (!error) {
+               error = removexattr(dentry, name);
+               mnt_drop_write(f->f_path.mnt);
+       }
        fput(f);
        return error;
 }