kill boilerplates around posix_acl_create_masq()
[pandora-kernel.git] / fs / 9p / acl.c
index 535ab6e..075bc90 100644 (file)
@@ -96,14 +96,11 @@ static struct posix_acl *v9fs_get_cached_acl(struct inode *inode, int type)
        return acl;
 }
 
-int v9fs_check_acl(struct inode *inode, int mask, unsigned int flags)
+int v9fs_check_acl(struct inode *inode, int mask)
 {
        struct posix_acl *acl;
        struct v9fs_session_info *v9ses;
 
-       if (flags & IPERM_FLAG_RCU)
-               return -ECHILD;
-
        v9ses = v9fs_inode2v9ses(inode);
        if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) ||
                        ((v9ses->flags & V9FS_ACL_MASK) != V9FS_POSIX_ACL)) {
@@ -111,7 +108,7 @@ int v9fs_check_acl(struct inode *inode, int mask, unsigned int flags)
                 * On access = client  and acl = on mode get the acl
                 * values from the server
                 */
-               return 0;
+               return -EAGAIN;
        }
        acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS);
 
@@ -165,32 +162,32 @@ err_free_out:
 int v9fs_acl_chmod(struct dentry *dentry)
 {
        int retval = 0;
-       struct posix_acl *acl, *clone;
+       struct posix_acl *acl;
        struct inode *inode = dentry->d_inode;
 
        if (S_ISLNK(inode->i_mode))
                return -EOPNOTSUPP;
        acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS);
        if (acl) {
-               clone = posix_acl_clone(acl, GFP_KERNEL);
+               retval = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+               if (retval)
+                       return retval;
+               retval = v9fs_set_acl(dentry, ACL_TYPE_ACCESS, acl);
                posix_acl_release(acl);
-               if (!clone)
-                       return -ENOMEM;
-               retval = posix_acl_chmod_masq(clone, inode->i_mode);
-               if (!retval)
-                       retval = v9fs_set_acl(dentry, ACL_TYPE_ACCESS, clone);
-               posix_acl_release(clone);
        }
        return retval;
 }
 
 int v9fs_set_create_acl(struct dentry *dentry,
-                       struct posix_acl *dpacl, struct posix_acl *pacl)
+                       struct posix_acl **dpacl, struct posix_acl **pacl)
 {
-       v9fs_set_acl(dentry, ACL_TYPE_DEFAULT, dpacl);
-       v9fs_set_acl(dentry, ACL_TYPE_ACCESS, pacl);
-       posix_acl_release(dpacl);
-       posix_acl_release(pacl);
+       if (dentry) {
+               v9fs_set_acl(dentry, ACL_TYPE_DEFAULT, *dpacl);
+               v9fs_set_acl(dentry, ACL_TYPE_ACCESS, *pacl);
+       }
+       posix_acl_release(*dpacl);
+       posix_acl_release(*pacl);
+       *dpacl = *pacl = NULL;
        return 0;
 }
 
@@ -209,29 +206,18 @@ int v9fs_acl_mode(struct inode *dir, mode_t *modep,
                        mode &= ~current_umask();
        }
        if (acl) {
-               struct posix_acl *clone;
-
                if (S_ISDIR(mode))
-                       *dpacl = acl;
-               clone = posix_acl_clone(acl, GFP_NOFS);
-               retval = -ENOMEM;
-               if (!clone)
-                       goto cleanup;
-
-               retval = posix_acl_create_masq(clone, &mode);
-               if (retval < 0) {
-                       posix_acl_release(clone);
-                       goto cleanup;
-               }
+                       *dpacl = posix_acl_dup(acl);
+               retval = posix_acl_create(&acl, GFP_NOFS, &mode);
+               if (retval < 0)
+                       return retval;
                if (retval > 0)
-                       *pacl = clone;
+                       *pacl = acl;
+               else
+                       posix_acl_release(acl);
        }
        *modep  = mode;
        return 0;
-cleanup:
-       posix_acl_release(acl);
-       return retval;
-
 }
 
 static int v9fs_remote_get_acl(struct dentry *dentry, const char *name,