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:
parent
95203befa8
commit
826cae2f2b
22
fs/9p/acl.c
22
fs/9p/acl.c
|
@ -206,30 +206,18 @@ int v9fs_acl_mode(struct inode *dir, mode_t *modep,
|
||||||
mode &= ~current_umask();
|
mode &= ~current_umask();
|
||||||
}
|
}
|
||||||
if (acl) {
|
if (acl) {
|
||||||
struct posix_acl *clone;
|
|
||||||
|
|
||||||
if (S_ISDIR(mode))
|
if (S_ISDIR(mode))
|
||||||
*dpacl = posix_acl_dup(acl);
|
*dpacl = posix_acl_dup(acl);
|
||||||
clone = posix_acl_clone(acl, GFP_NOFS);
|
retval = posix_acl_create(&acl, GFP_NOFS, &mode);
|
||||||
posix_acl_release(acl);
|
if (retval < 0)
|
||||||
if (!clone)
|
return retval;
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
retval = posix_acl_create_masq(clone, &mode);
|
|
||||||
if (retval < 0) {
|
|
||||||
posix_acl_release(clone);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (retval > 0)
|
if (retval > 0)
|
||||||
*pacl = clone;
|
*pacl = acl;
|
||||||
else
|
else
|
||||||
posix_acl_release(clone);
|
posix_acl_release(acl);
|
||||||
}
|
}
|
||||||
*modep = mode;
|
*modep = mode;
|
||||||
return 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return retval;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int v9fs_remote_get_acl(struct dentry *dentry, const char *name,
|
static int v9fs_remote_get_acl(struct dentry *dentry, const char *name,
|
||||||
|
|
|
@ -238,8 +238,7 @@ int btrfs_init_acl(struct btrfs_trans_handle *trans,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_POSIXACL(dir) && acl) {
|
if (IS_POSIXACL(dir) && acl) {
|
||||||
struct posix_acl *clone;
|
mode_t mode = inode->i_mode;
|
||||||
mode_t mode;
|
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
if (S_ISDIR(inode->i_mode)) {
|
||||||
ret = btrfs_set_acl(trans, inode, acl,
|
ret = btrfs_set_acl(trans, inode, acl,
|
||||||
|
@ -247,22 +246,15 @@ int btrfs_init_acl(struct btrfs_trans_handle *trans,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
clone = posix_acl_clone(acl, GFP_NOFS);
|
ret = posix_acl_create(&acl, GFP_NOFS, &mode);
|
||||||
ret = -ENOMEM;
|
if (ret < 0)
|
||||||
if (!clone)
|
return ret;
|
||||||
goto failed;
|
|
||||||
|
|
||||||
mode = inode->i_mode;
|
inode->i_mode = mode;
|
||||||
ret = posix_acl_create_masq(clone, &mode);
|
if (ret > 0) {
|
||||||
if (ret >= 0) {
|
/* we need an acl */
|
||||||
inode->i_mode = mode;
|
ret = btrfs_set_acl(trans, inode, acl, ACL_TYPE_ACCESS);
|
||||||
if (ret > 0) {
|
|
||||||
/* we need an acl */
|
|
||||||
ret = btrfs_set_acl(trans, inode, clone,
|
|
||||||
ACL_TYPE_ACCESS);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
posix_acl_release(clone);
|
|
||||||
}
|
}
|
||||||
failed:
|
failed:
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
|
|
|
@ -270,29 +270,20 @@ ext2_init_acl(struct inode *inode, struct inode *dir)
|
||||||
inode->i_mode &= ~current_umask();
|
inode->i_mode &= ~current_umask();
|
||||||
}
|
}
|
||||||
if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
|
if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
|
||||||
struct posix_acl *clone;
|
mode_t mode = inode->i_mode;
|
||||||
mode_t mode;
|
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
if (S_ISDIR(inode->i_mode)) {
|
||||||
error = ext2_set_acl(inode, ACL_TYPE_DEFAULT, acl);
|
error = ext2_set_acl(inode, ACL_TYPE_DEFAULT, acl);
|
||||||
if (error)
|
if (error)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
clone = posix_acl_clone(acl, GFP_KERNEL);
|
error = posix_acl_create(&acl, GFP_KERNEL, &mode);
|
||||||
error = -ENOMEM;
|
if (error < 0)
|
||||||
if (!clone)
|
return error;
|
||||||
goto cleanup;
|
inode->i_mode = mode;
|
||||||
mode = inode->i_mode;
|
if (error > 0) {
|
||||||
error = posix_acl_create_masq(clone, &mode);
|
/* This is an extended ACL */
|
||||||
if (error >= 0) {
|
error = ext2_set_acl(inode, ACL_TYPE_ACCESS, acl);
|
||||||
inode->i_mode = mode;
|
|
||||||
if (error > 0) {
|
|
||||||
/* This is an extended ACL */
|
|
||||||
error = ext2_set_acl(inode,
|
|
||||||
ACL_TYPE_ACCESS, clone);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
posix_acl_release(clone);
|
|
||||||
}
|
}
|
||||||
cleanup:
|
cleanup:
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
|
|
|
@ -278,8 +278,7 @@ ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
|
||||||
inode->i_mode &= ~current_umask();
|
inode->i_mode &= ~current_umask();
|
||||||
}
|
}
|
||||||
if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
|
if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
|
||||||
struct posix_acl *clone;
|
mode_t mode = inode->i_mode;
|
||||||
mode_t mode;
|
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
if (S_ISDIR(inode->i_mode)) {
|
||||||
error = ext3_set_acl(handle, inode,
|
error = ext3_set_acl(handle, inode,
|
||||||
|
@ -287,22 +286,15 @@ ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
|
||||||
if (error)
|
if (error)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
clone = posix_acl_clone(acl, GFP_NOFS);
|
error = posix_acl_create(&acl, GFP_NOFS, &mode);
|
||||||
error = -ENOMEM;
|
if (error < 0)
|
||||||
if (!clone)
|
return error;
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
mode = inode->i_mode;
|
inode->i_mode = mode;
|
||||||
error = posix_acl_create_masq(clone, &mode);
|
if (error > 0) {
|
||||||
if (error >= 0) {
|
/* This is an extended ACL */
|
||||||
inode->i_mode = mode;
|
error = ext3_set_acl(handle, inode, ACL_TYPE_ACCESS, acl);
|
||||||
if (error > 0) {
|
|
||||||
/* This is an extended ACL */
|
|
||||||
error = ext3_set_acl(handle, inode,
|
|
||||||
ACL_TYPE_ACCESS, clone);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
posix_acl_release(clone);
|
|
||||||
}
|
}
|
||||||
cleanup:
|
cleanup:
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
|
|
|
@ -276,8 +276,7 @@ ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
|
||||||
inode->i_mode &= ~current_umask();
|
inode->i_mode &= ~current_umask();
|
||||||
}
|
}
|
||||||
if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
|
if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
|
||||||
struct posix_acl *clone;
|
mode_t mode = inode->i_mode;
|
||||||
mode_t mode;
|
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
if (S_ISDIR(inode->i_mode)) {
|
||||||
error = ext4_set_acl(handle, inode,
|
error = ext4_set_acl(handle, inode,
|
||||||
|
@ -285,22 +284,15 @@ ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
|
||||||
if (error)
|
if (error)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
clone = posix_acl_clone(acl, GFP_NOFS);
|
error = posix_acl_create(&acl, GFP_NOFS, &mode);
|
||||||
error = -ENOMEM;
|
if (error < 0)
|
||||||
if (!clone)
|
return error;
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
mode = inode->i_mode;
|
inode->i_mode = mode;
|
||||||
error = posix_acl_create_masq(clone, &mode);
|
if (error > 0) {
|
||||||
if (error >= 0) {
|
/* This is an extended ACL */
|
||||||
inode->i_mode = mode;
|
error = ext4_set_acl(handle, inode, ACL_TYPE_ACCESS, acl);
|
||||||
if (error > 0) {
|
|
||||||
/* This is an extended ACL */
|
|
||||||
error = ext4_set_acl(handle, inode,
|
|
||||||
ACL_TYPE_ACCESS, clone);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
posix_acl_release(clone);
|
|
||||||
}
|
}
|
||||||
cleanup:
|
cleanup:
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
|
|
|
@ -132,25 +132,17 @@ generic_acl_init(struct inode *inode, struct inode *dir)
|
||||||
if (!S_ISLNK(inode->i_mode))
|
if (!S_ISLNK(inode->i_mode))
|
||||||
acl = get_cached_acl(dir, ACL_TYPE_DEFAULT);
|
acl = get_cached_acl(dir, ACL_TYPE_DEFAULT);
|
||||||
if (acl) {
|
if (acl) {
|
||||||
struct posix_acl *clone;
|
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode))
|
if (S_ISDIR(inode->i_mode))
|
||||||
set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
|
set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
|
||||||
clone = posix_acl_clone(acl, GFP_KERNEL);
|
error = posix_acl_create(&acl, GFP_KERNEL, &mode);
|
||||||
error = -ENOMEM;
|
if (error < 0)
|
||||||
if (!clone)
|
return error;
|
||||||
goto cleanup;
|
inode->i_mode = mode;
|
||||||
error = posix_acl_create_masq(clone, &mode);
|
if (error > 0)
|
||||||
if (error >= 0) {
|
set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
|
||||||
inode->i_mode = mode;
|
|
||||||
if (error > 0)
|
|
||||||
set_cached_acl(inode, ACL_TYPE_ACCESS, clone);
|
|
||||||
}
|
|
||||||
posix_acl_release(clone);
|
|
||||||
}
|
}
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ out:
|
||||||
int gfs2_acl_create(struct gfs2_inode *dip, struct inode *inode)
|
int gfs2_acl_create(struct gfs2_inode *dip, struct inode *inode)
|
||||||
{
|
{
|
||||||
struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
|
struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
|
||||||
struct posix_acl *acl, *clone;
|
struct posix_acl *acl;
|
||||||
mode_t mode = inode->i_mode;
|
mode_t mode = inode->i_mode;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
|
@ -162,16 +162,10 @@ int gfs2_acl_create(struct gfs2_inode *dip, struct inode *inode)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
clone = posix_acl_clone(acl, GFP_NOFS);
|
error = posix_acl_create(&acl, GFP_NOFS, &mode);
|
||||||
error = -ENOMEM;
|
|
||||||
if (!clone)
|
|
||||||
goto out;
|
|
||||||
posix_acl_release(acl);
|
|
||||||
acl = clone;
|
|
||||||
|
|
||||||
error = posix_acl_create_masq(acl, &mode);
|
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
goto out;
|
return error;
|
||||||
|
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
goto munge;
|
goto munge;
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ int jffs2_check_acl(struct inode *inode, int mask)
|
||||||
|
|
||||||
int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, mode_t *i_mode)
|
int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, mode_t *i_mode)
|
||||||
{
|
{
|
||||||
struct posix_acl *acl, *clone;
|
struct posix_acl *acl;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
cache_no_acl(inode);
|
cache_no_acl(inode);
|
||||||
|
@ -295,18 +295,13 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, mode_t *i_mode)
|
||||||
if (S_ISDIR(*i_mode))
|
if (S_ISDIR(*i_mode))
|
||||||
set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
|
set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
|
||||||
|
|
||||||
clone = posix_acl_clone(acl, GFP_KERNEL);
|
rc = posix_acl_create(&acl, GFP_KERNEL, i_mode);
|
||||||
if (!clone)
|
if (rc < 0)
|
||||||
return -ENOMEM;
|
|
||||||
rc = posix_acl_create_masq(clone, i_mode);
|
|
||||||
if (rc < 0) {
|
|
||||||
posix_acl_release(clone);
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
|
||||||
if (rc > 0)
|
if (rc > 0)
|
||||||
set_cached_acl(inode, ACL_TYPE_ACCESS, clone);
|
set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
|
||||||
|
|
||||||
posix_acl_release(clone);
|
posix_acl_release(acl);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
23
fs/jfs/acl.c
23
fs/jfs/acl.c
|
@ -133,8 +133,6 @@ int jfs_check_acl(struct inode *inode, int mask)
|
||||||
int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir)
|
int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir)
|
||||||
{
|
{
|
||||||
struct posix_acl *acl = NULL;
|
struct posix_acl *acl = NULL;
|
||||||
struct posix_acl *clone;
|
|
||||||
mode_t mode;
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
if (S_ISLNK(inode->i_mode))
|
if (S_ISLNK(inode->i_mode))
|
||||||
|
@ -145,25 +143,18 @@ int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir)
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
|
|
||||||
if (acl) {
|
if (acl) {
|
||||||
|
mode_t mode = inode->i_mode;
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
if (S_ISDIR(inode->i_mode)) {
|
||||||
rc = jfs_set_acl(tid, inode, ACL_TYPE_DEFAULT, acl);
|
rc = jfs_set_acl(tid, inode, ACL_TYPE_DEFAULT, acl);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
clone = posix_acl_clone(acl, GFP_KERNEL);
|
rc = posix_acl_create(&acl, GFP_KERNEL, &mode);
|
||||||
if (!clone) {
|
if (rc < 0)
|
||||||
rc = -ENOMEM;
|
goto cleanup; /* posix_acl_release(NULL) is no-op */
|
||||||
goto cleanup;
|
inode->i_mode = mode;
|
||||||
}
|
if (rc > 0)
|
||||||
mode = inode->i_mode;
|
rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, acl);
|
||||||
rc = posix_acl_create_masq(clone, &mode);
|
|
||||||
if (rc >= 0) {
|
|
||||||
inode->i_mode = mode;
|
|
||||||
if (rc > 0)
|
|
||||||
rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS,
|
|
||||||
clone);
|
|
||||||
}
|
|
||||||
posix_acl_release(clone);
|
|
||||||
cleanup:
|
cleanup:
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -427,16 +427,12 @@ int nfs3_proc_set_default_acl(struct inode *dir, struct inode *inode,
|
||||||
}
|
}
|
||||||
if (!dfacl)
|
if (!dfacl)
|
||||||
return 0;
|
return 0;
|
||||||
acl = posix_acl_clone(dfacl, GFP_KERNEL);
|
acl = posix_acl_dup(dfacl);
|
||||||
error = -ENOMEM;
|
error = posix_acl_create(&acl, GFP_KERNEL, &mode);
|
||||||
if (!acl)
|
|
||||||
goto out_release_dfacl;
|
|
||||||
error = posix_acl_create_masq(acl, &mode);
|
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
goto out_release_acl;
|
goto out_release_dfacl;
|
||||||
error = nfs3_proc_setacls(inode, acl, S_ISDIR(inode->i_mode) ?
|
error = nfs3_proc_setacls(inode, acl, S_ISDIR(inode->i_mode) ?
|
||||||
dfacl : NULL);
|
dfacl : NULL);
|
||||||
out_release_acl:
|
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
out_release_dfacl:
|
out_release_dfacl:
|
||||||
posix_acl_release(dfacl);
|
posix_acl_release(dfacl);
|
||||||
|
|
|
@ -382,8 +382,6 @@ int ocfs2_init_acl(handle_t *handle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) {
|
if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) {
|
||||||
struct posix_acl *clone;
|
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
if (S_ISDIR(inode->i_mode)) {
|
||||||
ret = ocfs2_set_acl(handle, inode, di_bh,
|
ret = ocfs2_set_acl(handle, inode, di_bh,
|
||||||
ACL_TYPE_DEFAULT, acl,
|
ACL_TYPE_DEFAULT, acl,
|
||||||
|
@ -391,28 +389,22 @@ int ocfs2_init_acl(handle_t *handle,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
clone = posix_acl_clone(acl, GFP_NOFS);
|
|
||||||
ret = -ENOMEM;
|
|
||||||
if (!clone)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
mode = inode->i_mode;
|
mode = inode->i_mode;
|
||||||
ret = posix_acl_create_masq(clone, &mode);
|
ret = posix_acl_create(&acl, GFP_NOFS, &mode);
|
||||||
if (ret >= 0) {
|
if (ret < 0)
|
||||||
ret2 = ocfs2_acl_set_mode(inode, di_bh, handle, mode);
|
return ret;
|
||||||
if (ret2) {
|
|
||||||
mlog_errno(ret2);
|
ret2 = ocfs2_acl_set_mode(inode, di_bh, handle, mode);
|
||||||
ret = ret2;
|
if (ret2) {
|
||||||
posix_acl_release(clone);
|
mlog_errno(ret2);
|
||||||
goto cleanup;
|
ret = ret2;
|
||||||
}
|
goto cleanup;
|
||||||
if (ret > 0) {
|
}
|
||||||
ret = ocfs2_set_acl(handle, inode,
|
if (ret > 0) {
|
||||||
di_bh, ACL_TYPE_ACCESS,
|
ret = ocfs2_set_acl(handle, inode,
|
||||||
clone, meta_ac, data_ac);
|
di_bh, ACL_TYPE_ACCESS,
|
||||||
}
|
acl, meta_ac, data_ac);
|
||||||
}
|
}
|
||||||
posix_acl_release(clone);
|
|
||||||
}
|
}
|
||||||
cleanup:
|
cleanup:
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
|
|
|
@ -387,6 +387,24 @@ posix_acl_chmod_masq(struct posix_acl *acl, mode_t mode)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
posix_acl_create(struct posix_acl **acl, gfp_t gfp, mode_t *mode_p)
|
||||||
|
{
|
||||||
|
struct posix_acl *clone = posix_acl_clone(*acl, gfp);
|
||||||
|
int err = -ENOMEM;
|
||||||
|
if (clone) {
|
||||||
|
err = posix_acl_create_masq(clone, mode_p);
|
||||||
|
if (err < 0) {
|
||||||
|
posix_acl_release(clone);
|
||||||
|
clone = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
posix_acl_release(*acl);
|
||||||
|
*acl = clone;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(posix_acl_create);
|
||||||
|
|
||||||
int
|
int
|
||||||
posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, mode_t mode)
|
posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, mode_t mode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -354,9 +354,7 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
|
|
||||||
if (acl) {
|
if (acl) {
|
||||||
struct posix_acl *acl_copy;
|
|
||||||
mode_t mode = inode->i_mode;
|
mode_t mode = inode->i_mode;
|
||||||
int need_acl;
|
|
||||||
|
|
||||||
/* Copy the default ACL to the default ACL of a new directory */
|
/* Copy the default ACL to the default ACL of a new directory */
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
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,
|
/* Now we reconcile the new ACL and the mode,
|
||||||
potentially modifying both */
|
potentially modifying both */
|
||||||
acl_copy = posix_acl_clone(acl, GFP_NOFS);
|
err = posix_acl_create(&acl, GFP_NOFS, &mode);
|
||||||
if (!acl_copy) {
|
if (err < 0)
|
||||||
err = -ENOMEM;
|
return err;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
need_acl = posix_acl_create_masq(acl_copy, &mode);
|
inode->i_mode = mode;
|
||||||
if (need_acl >= 0) {
|
|
||||||
if (mode != inode->i_mode) {
|
|
||||||
inode->i_mode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we need an ACL.. */
|
/* If we need an ACL.. */
|
||||||
if (need_acl > 0) {
|
if (err > 0)
|
||||||
err = reiserfs_set_acl(th, inode,
|
err = reiserfs_set_acl(th, inode, ACL_TYPE_ACCESS, acl);
|
||||||
ACL_TYPE_ACCESS,
|
|
||||||
acl_copy);
|
|
||||||
if (err)
|
|
||||||
goto cleanup_copy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cleanup_copy:
|
|
||||||
posix_acl_release(acl_copy);
|
|
||||||
cleanup:
|
cleanup:
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -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.
|
* No need for i_mutex because the inode is not yet exposed to the VFS.
|
||||||
*/
|
*/
|
||||||
int
|
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 = inode->i_mode;
|
||||||
mode_t mode;
|
|
||||||
int error = 0, inherit = 0;
|
int error = 0, inherit = 0;
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
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)
|
if (error)
|
||||||
return error;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
clone = posix_acl_clone(default_acl, GFP_KERNEL);
|
error = posix_acl_create(&acl, GFP_KERNEL, &mode);
|
||||||
if (!clone)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
mode = inode->i_mode;
|
|
||||||
error = posix_acl_create_masq(clone, &mode);
|
|
||||||
if (error < 0)
|
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
|
* inherit a permission that can't be represented using the Unix
|
||||||
* mode bits and we actually need to set an ACL.
|
* 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);
|
error = xfs_set_mode(inode, mode);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_release_clone;
|
goto out;
|
||||||
|
|
||||||
if (inherit)
|
if (inherit)
|
||||||
error = xfs_set_acl(inode, ACL_TYPE_ACCESS, clone);
|
error = xfs_set_acl(inode, ACL_TYPE_ACCESS, acl);
|
||||||
|
|
||||||
out_release_clone:
|
out:
|
||||||
posix_acl_release(clone);
|
posix_acl_release(acl);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -202,9 +202,9 @@ xfs_vn_mknod(
|
||||||
|
|
||||||
if (default_acl) {
|
if (default_acl) {
|
||||||
error = -xfs_inherit_acl(inode, default_acl);
|
error = -xfs_inherit_acl(inode, default_acl);
|
||||||
|
default_acl = NULL;
|
||||||
if (unlikely(error))
|
if (unlikely(error))
|
||||||
goto out_cleanup_inode;
|
goto out_cleanup_inode;
|
||||||
posix_acl_release(default_acl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ extern struct posix_acl *posix_acl_from_mode(mode_t, gfp_t);
|
||||||
extern int posix_acl_equiv_mode(const struct posix_acl *, mode_t *);
|
extern int posix_acl_equiv_mode(const struct posix_acl *, mode_t *);
|
||||||
extern int posix_acl_create_masq(struct posix_acl *, mode_t *);
|
extern int posix_acl_create_masq(struct posix_acl *, mode_t *);
|
||||||
extern int posix_acl_chmod_masq(struct posix_acl *, mode_t);
|
extern int posix_acl_chmod_masq(struct posix_acl *, mode_t);
|
||||||
|
extern int posix_acl_create(struct posix_acl **, gfp_t, mode_t *);
|
||||||
extern int posix_acl_chmod(struct posix_acl **, gfp_t, mode_t);
|
extern int posix_acl_chmod(struct posix_acl **, gfp_t, mode_t);
|
||||||
|
|
||||||
extern struct posix_acl *get_posix_acl(struct inode *, int);
|
extern struct posix_acl *get_posix_acl(struct inode *, int);
|
||||||
|
|
Loading…
Reference in New Issue