kill boilerplates around posix_acl_create_masq()

new helper: posix_acl_create(&acl, gfp, mode_p).  Replaces acl with
modified clone, on failure releases acl and replaces with NULL.
Returns 0 or -ve on error.  All callers of posix_acl_create_masq()
switched.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro
2011-07-23 03:10:32 -04:00
parent 95203befa8
commit 826cae2f2b
16 changed files with 114 additions and 202 deletions

View File

@@ -282,29 +282,23 @@ posix_acl_default_exists(struct inode *inode)
* No need for i_mutex because the inode is not yet exposed to the VFS.
*/
int
xfs_inherit_acl(struct inode *inode, struct posix_acl *default_acl)
xfs_inherit_acl(struct inode *inode, struct posix_acl *acl)
{
struct posix_acl *clone;
mode_t mode;
mode_t mode = inode->i_mode;
int error = 0, inherit = 0;
if (S_ISDIR(inode->i_mode)) {
error = xfs_set_acl(inode, ACL_TYPE_DEFAULT, default_acl);
error = xfs_set_acl(inode, ACL_TYPE_DEFAULT, acl);
if (error)
return error;
goto out;
}
clone = posix_acl_clone(default_acl, GFP_KERNEL);
if (!clone)
return -ENOMEM;
mode = inode->i_mode;
error = posix_acl_create_masq(clone, &mode);
error = posix_acl_create(&acl, GFP_KERNEL, &mode);
if (error < 0)
goto out_release_clone;
return error;
/*
* If posix_acl_create_masq returns a positive value we need to
* If posix_acl_create returns a positive value we need to
* inherit a permission that can't be represented using the Unix
* mode bits and we actually need to set an ACL.
*/
@@ -313,13 +307,13 @@ xfs_inherit_acl(struct inode *inode, struct posix_acl *default_acl)
error = xfs_set_mode(inode, mode);
if (error)
goto out_release_clone;
goto out;
if (inherit)
error = xfs_set_acl(inode, ACL_TYPE_ACCESS, clone);
error = xfs_set_acl(inode, ACL_TYPE_ACCESS, acl);
out_release_clone:
posix_acl_release(clone);
out:
posix_acl_release(acl);
return error;
}