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:
@@ -354,9 +354,7 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
|
||||
return PTR_ERR(acl);
|
||||
|
||||
if (acl) {
|
||||
struct posix_acl *acl_copy;
|
||||
mode_t mode = inode->i_mode;
|
||||
int need_acl;
|
||||
|
||||
/* Copy the default ACL to the default ACL of a new directory */
|
||||
if (S_ISDIR(inode->i_mode)) {
|
||||
@@ -368,29 +366,15 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
|
||||
|
||||
/* Now we reconcile the new ACL and the mode,
|
||||
potentially modifying both */
|
||||
acl_copy = posix_acl_clone(acl, GFP_NOFS);
|
||||
if (!acl_copy) {
|
||||
err = -ENOMEM;
|
||||
goto cleanup;
|
||||
}
|
||||
err = posix_acl_create(&acl, GFP_NOFS, &mode);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
need_acl = posix_acl_create_masq(acl_copy, &mode);
|
||||
if (need_acl >= 0) {
|
||||
if (mode != inode->i_mode) {
|
||||
inode->i_mode = mode;
|
||||
}
|
||||
inode->i_mode = mode;
|
||||
|
||||
/* If we need an ACL.. */
|
||||
if (need_acl > 0) {
|
||||
err = reiserfs_set_acl(th, inode,
|
||||
ACL_TYPE_ACCESS,
|
||||
acl_copy);
|
||||
if (err)
|
||||
goto cleanup_copy;
|
||||
}
|
||||
}
|
||||
cleanup_copy:
|
||||
posix_acl_release(acl_copy);
|
||||
/* If we need an ACL.. */
|
||||
if (err > 0)
|
||||
err = reiserfs_set_acl(th, inode, ACL_TYPE_ACCESS, acl);
|
||||
cleanup:
|
||||
posix_acl_release(acl);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user