mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
kill boilerplate around posix_acl_chmod_masq()
new helper: posix_acl_chmod(&acl, gfp, mode). Replaces acl with modified clone or with NULL if that has failed; returns 0 or -ve on error. All callers of posix_acl_chmod_masq() switched to that - they'd been doing exactly the same thing. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
4482a087d4
commit
bc26ab5f65
14 changed files with 140 additions and 169 deletions
13
fs/9p/acl.c
13
fs/9p/acl.c
|
@ -162,21 +162,18 @@ err_free_out:
|
||||||
int v9fs_acl_chmod(struct dentry *dentry)
|
int v9fs_acl_chmod(struct dentry *dentry)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
struct posix_acl *acl, *clone;
|
struct posix_acl *acl;
|
||||||
struct inode *inode = dentry->d_inode;
|
struct inode *inode = dentry->d_inode;
|
||||||
|
|
||||||
if (S_ISLNK(inode->i_mode))
|
if (S_ISLNK(inode->i_mode))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS);
|
acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS);
|
||||||
if (acl) {
|
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);
|
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;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,7 +272,7 @@ failed:
|
||||||
|
|
||||||
int btrfs_acl_chmod(struct inode *inode)
|
int btrfs_acl_chmod(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct posix_acl *acl, *clone;
|
struct posix_acl *acl;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (S_ISLNK(inode->i_mode))
|
if (S_ISLNK(inode->i_mode))
|
||||||
|
@ -285,17 +285,11 @@ int btrfs_acl_chmod(struct inode *inode)
|
||||||
if (IS_ERR_OR_NULL(acl))
|
if (IS_ERR_OR_NULL(acl))
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
|
|
||||||
clone = posix_acl_clone(acl, GFP_KERNEL);
|
ret = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
ret = btrfs_set_acl(NULL, inode, acl, ACL_TYPE_ACCESS);
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
if (!clone)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
ret = posix_acl_chmod_masq(clone, inode->i_mode);
|
|
||||||
if (!ret)
|
|
||||||
ret = btrfs_set_acl(NULL, inode, clone, ACL_TYPE_ACCESS);
|
|
||||||
|
|
||||||
posix_acl_release(clone);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -316,7 +316,7 @@ cleanup:
|
||||||
int
|
int
|
||||||
ext2_acl_chmod(struct inode *inode)
|
ext2_acl_chmod(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct posix_acl *acl, *clone;
|
struct posix_acl *acl;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (!test_opt(inode->i_sb, POSIX_ACL))
|
if (!test_opt(inode->i_sb, POSIX_ACL))
|
||||||
|
@ -326,14 +326,11 @@ ext2_acl_chmod(struct inode *inode)
|
||||||
acl = ext2_get_acl(inode, ACL_TYPE_ACCESS);
|
acl = ext2_get_acl(inode, ACL_TYPE_ACCESS);
|
||||||
if (IS_ERR(acl) || !acl)
|
if (IS_ERR(acl) || !acl)
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
clone = posix_acl_clone(acl, GFP_KERNEL);
|
error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
error = ext2_set_acl(inode, ACL_TYPE_ACCESS, acl);
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
if (!clone)
|
|
||||||
return -ENOMEM;
|
|
||||||
error = posix_acl_chmod_masq(clone, inode->i_mode);
|
|
||||||
if (!error)
|
|
||||||
error = ext2_set_acl(inode, ACL_TYPE_ACCESS, clone);
|
|
||||||
posix_acl_release(clone);
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -326,7 +326,9 @@ cleanup:
|
||||||
int
|
int
|
||||||
ext3_acl_chmod(struct inode *inode)
|
ext3_acl_chmod(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct posix_acl *acl, *clone;
|
struct posix_acl *acl;
|
||||||
|
handle_t *handle;
|
||||||
|
int retries = 0;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (S_ISLNK(inode->i_mode))
|
if (S_ISLNK(inode->i_mode))
|
||||||
|
@ -336,31 +338,24 @@ ext3_acl_chmod(struct inode *inode)
|
||||||
acl = ext3_get_acl(inode, ACL_TYPE_ACCESS);
|
acl = ext3_get_acl(inode, ACL_TYPE_ACCESS);
|
||||||
if (IS_ERR(acl) || !acl)
|
if (IS_ERR(acl) || !acl)
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
clone = posix_acl_clone(acl, GFP_KERNEL);
|
error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
|
||||||
posix_acl_release(acl);
|
if (error)
|
||||||
if (!clone)
|
return error;
|
||||||
return -ENOMEM;
|
retry:
|
||||||
error = posix_acl_chmod_masq(clone, inode->i_mode);
|
handle = ext3_journal_start(inode,
|
||||||
if (!error) {
|
EXT3_DATA_TRANS_BLOCKS(inode->i_sb));
|
||||||
handle_t *handle;
|
if (IS_ERR(handle)) {
|
||||||
int retries = 0;
|
error = PTR_ERR(handle);
|
||||||
|
ext3_std_error(inode->i_sb, error);
|
||||||
retry:
|
goto out;
|
||||||
handle = ext3_journal_start(inode,
|
|
||||||
EXT3_DATA_TRANS_BLOCKS(inode->i_sb));
|
|
||||||
if (IS_ERR(handle)) {
|
|
||||||
error = PTR_ERR(handle);
|
|
||||||
ext3_std_error(inode->i_sb, error);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
error = ext3_set_acl(handle, inode, ACL_TYPE_ACCESS, clone);
|
|
||||||
ext3_journal_stop(handle);
|
|
||||||
if (error == -ENOSPC &&
|
|
||||||
ext3_should_retry_alloc(inode->i_sb, &retries))
|
|
||||||
goto retry;
|
|
||||||
}
|
}
|
||||||
|
error = ext3_set_acl(handle, inode, ACL_TYPE_ACCESS, acl);
|
||||||
|
ext3_journal_stop(handle);
|
||||||
|
if (error == -ENOSPC &&
|
||||||
|
ext3_should_retry_alloc(inode->i_sb, &retries))
|
||||||
|
goto retry;
|
||||||
out:
|
out:
|
||||||
posix_acl_release(clone);
|
posix_acl_release(acl);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -324,9 +324,12 @@ cleanup:
|
||||||
int
|
int
|
||||||
ext4_acl_chmod(struct inode *inode)
|
ext4_acl_chmod(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct posix_acl *acl, *clone;
|
struct posix_acl *acl;
|
||||||
|
handle_t *handle;
|
||||||
|
int retries = 0;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
|
||||||
if (S_ISLNK(inode->i_mode))
|
if (S_ISLNK(inode->i_mode))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
if (!test_opt(inode->i_sb, POSIX_ACL))
|
if (!test_opt(inode->i_sb, POSIX_ACL))
|
||||||
|
@ -334,31 +337,24 @@ ext4_acl_chmod(struct inode *inode)
|
||||||
acl = ext4_get_acl(inode, ACL_TYPE_ACCESS);
|
acl = ext4_get_acl(inode, ACL_TYPE_ACCESS);
|
||||||
if (IS_ERR(acl) || !acl)
|
if (IS_ERR(acl) || !acl)
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
clone = posix_acl_clone(acl, GFP_KERNEL);
|
error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
|
||||||
posix_acl_release(acl);
|
if (error)
|
||||||
if (!clone)
|
return error;
|
||||||
return -ENOMEM;
|
retry:
|
||||||
error = posix_acl_chmod_masq(clone, inode->i_mode);
|
handle = ext4_journal_start(inode,
|
||||||
if (!error) {
|
EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
|
||||||
handle_t *handle;
|
if (IS_ERR(handle)) {
|
||||||
int retries = 0;
|
error = PTR_ERR(handle);
|
||||||
|
ext4_std_error(inode->i_sb, error);
|
||||||
retry:
|
goto out;
|
||||||
handle = ext4_journal_start(inode,
|
|
||||||
EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
|
|
||||||
if (IS_ERR(handle)) {
|
|
||||||
error = PTR_ERR(handle);
|
|
||||||
ext4_std_error(inode->i_sb, error);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
error = ext4_set_acl(handle, inode, ACL_TYPE_ACCESS, clone);
|
|
||||||
ext4_journal_stop(handle);
|
|
||||||
if (error == -ENOSPC &&
|
|
||||||
ext4_should_retry_alloc(inode->i_sb, &retries))
|
|
||||||
goto retry;
|
|
||||||
}
|
}
|
||||||
|
error = ext4_set_acl(handle, inode, ACL_TYPE_ACCESS, acl);
|
||||||
|
ext4_journal_stop(handle);
|
||||||
|
if (error == -ENOSPC &&
|
||||||
|
ext4_should_retry_alloc(inode->i_sb, &retries))
|
||||||
|
goto retry;
|
||||||
out:
|
out:
|
||||||
posix_acl_release(clone);
|
posix_acl_release(acl);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,21 +170,18 @@ cleanup:
|
||||||
int
|
int
|
||||||
generic_acl_chmod(struct inode *inode)
|
generic_acl_chmod(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct posix_acl *acl, *clone;
|
struct posix_acl *acl;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
if (S_ISLNK(inode->i_mode))
|
if (S_ISLNK(inode->i_mode))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
acl = get_cached_acl(inode, ACL_TYPE_ACCESS);
|
acl = get_cached_acl(inode, ACL_TYPE_ACCESS);
|
||||||
if (acl) {
|
if (acl) {
|
||||||
clone = posix_acl_clone(acl, GFP_KERNEL);
|
error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
if (!clone)
|
|
||||||
return -ENOMEM;
|
|
||||||
error = posix_acl_chmod_masq(clone, inode->i_mode);
|
|
||||||
if (!error)
|
|
||||||
set_cached_acl(inode, ACL_TYPE_ACCESS, clone);
|
|
||||||
posix_acl_release(clone);
|
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,7 @@ out:
|
||||||
|
|
||||||
int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr)
|
int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr)
|
||||||
{
|
{
|
||||||
struct posix_acl *acl, *clone;
|
struct posix_acl *acl;
|
||||||
char *data;
|
char *data;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
int error;
|
int error;
|
||||||
|
@ -198,25 +198,19 @@ int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr)
|
||||||
if (!acl)
|
if (!acl)
|
||||||
return gfs2_setattr_simple(ip, attr);
|
return gfs2_setattr_simple(ip, attr);
|
||||||
|
|
||||||
clone = posix_acl_clone(acl, GFP_NOFS);
|
error = posix_acl_chmod(&acl, GFP_NOFS, attr->ia_mode);
|
||||||
error = -ENOMEM;
|
if (error)
|
||||||
if (!clone)
|
return error;
|
||||||
goto out;
|
|
||||||
posix_acl_release(acl);
|
|
||||||
acl = clone;
|
|
||||||
|
|
||||||
error = posix_acl_chmod_masq(acl, attr->ia_mode);
|
len = posix_acl_to_xattr(acl, NULL, 0);
|
||||||
if (!error) {
|
data = kmalloc(len, GFP_NOFS);
|
||||||
len = posix_acl_to_xattr(acl, NULL, 0);
|
error = -ENOMEM;
|
||||||
data = kmalloc(len, GFP_NOFS);
|
if (data == NULL)
|
||||||
error = -ENOMEM;
|
goto out;
|
||||||
if (data == NULL)
|
posix_acl_to_xattr(acl, data, len);
|
||||||
goto out;
|
error = gfs2_xattr_acl_chmod(ip, attr, data);
|
||||||
posix_acl_to_xattr(acl, data, len);
|
kfree(data);
|
||||||
error = gfs2_xattr_acl_chmod(ip, attr, data);
|
set_cached_acl(&ip->i_inode, ACL_TYPE_ACCESS, acl);
|
||||||
kfree(data);
|
|
||||||
set_cached_acl(&ip->i_inode, ACL_TYPE_ACCESS, acl);
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
|
|
|
@ -332,7 +332,7 @@ int jffs2_init_acl_post(struct inode *inode)
|
||||||
|
|
||||||
int jffs2_acl_chmod(struct inode *inode)
|
int jffs2_acl_chmod(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct posix_acl *acl, *clone;
|
struct posix_acl *acl;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (S_ISLNK(inode->i_mode))
|
if (S_ISLNK(inode->i_mode))
|
||||||
|
@ -340,14 +340,11 @@ int jffs2_acl_chmod(struct inode *inode)
|
||||||
acl = jffs2_get_acl(inode, ACL_TYPE_ACCESS);
|
acl = jffs2_get_acl(inode, ACL_TYPE_ACCESS);
|
||||||
if (IS_ERR(acl) || !acl)
|
if (IS_ERR(acl) || !acl)
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
clone = posix_acl_clone(acl, GFP_KERNEL);
|
rc = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
rc = jffs2_set_acl(inode, ACL_TYPE_ACCESS, acl);
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
if (!clone)
|
|
||||||
return -ENOMEM;
|
|
||||||
rc = posix_acl_chmod_masq(clone, inode->i_mode);
|
|
||||||
if (!rc)
|
|
||||||
rc = jffs2_set_acl(inode, ACL_TYPE_ACCESS, clone);
|
|
||||||
posix_acl_release(clone);
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
31
fs/jfs/acl.c
31
fs/jfs/acl.c
|
@ -177,8 +177,9 @@ cleanup:
|
||||||
|
|
||||||
int jfs_acl_chmod(struct inode *inode)
|
int jfs_acl_chmod(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct posix_acl *acl, *clone;
|
struct posix_acl *acl;
|
||||||
int rc;
|
int rc;
|
||||||
|
tid_t tid;
|
||||||
|
|
||||||
if (S_ISLNK(inode->i_mode))
|
if (S_ISLNK(inode->i_mode))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
@ -187,22 +188,18 @@ int jfs_acl_chmod(struct inode *inode)
|
||||||
if (IS_ERR(acl) || !acl)
|
if (IS_ERR(acl) || !acl)
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
|
|
||||||
clone = posix_acl_clone(acl, GFP_KERNEL);
|
rc = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
tid = txBegin(inode->i_sb, 0);
|
||||||
|
mutex_lock(&JFS_IP(inode)->commit_mutex);
|
||||||
|
rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, acl);
|
||||||
|
if (!rc)
|
||||||
|
rc = txCommit(tid, 1, &inode, 0);
|
||||||
|
txEnd(tid);
|
||||||
|
mutex_unlock(&JFS_IP(inode)->commit_mutex);
|
||||||
|
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
if (!clone)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
rc = posix_acl_chmod_masq(clone, inode->i_mode);
|
|
||||||
if (!rc) {
|
|
||||||
tid_t tid = txBegin(inode->i_sb, 0);
|
|
||||||
mutex_lock(&JFS_IP(inode)->commit_mutex);
|
|
||||||
rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, clone);
|
|
||||||
if (!rc)
|
|
||||||
rc = txCommit(tid, 1, &inode, 0);
|
|
||||||
txEnd(tid);
|
|
||||||
mutex_unlock(&JFS_IP(inode)->commit_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
posix_acl_release(clone);
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,7 +327,7 @@ int ocfs2_check_acl(struct inode *inode, int mask)
|
||||||
int ocfs2_acl_chmod(struct inode *inode)
|
int ocfs2_acl_chmod(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
|
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
|
||||||
struct posix_acl *acl, *clone;
|
struct posix_acl *acl;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (S_ISLNK(inode->i_mode))
|
if (S_ISLNK(inode->i_mode))
|
||||||
|
@ -339,15 +339,12 @@ int ocfs2_acl_chmod(struct inode *inode)
|
||||||
acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS);
|
acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS);
|
||||||
if (IS_ERR(acl) || !acl)
|
if (IS_ERR(acl) || !acl)
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
clone = posix_acl_clone(acl, GFP_KERNEL);
|
ret = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
ret = ocfs2_set_acl(NULL, inode, NULL, ACL_TYPE_ACCESS,
|
||||||
|
acl, NULL, NULL);
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
if (!clone)
|
|
||||||
return -ENOMEM;
|
|
||||||
ret = posix_acl_chmod_masq(clone, inode->i_mode);
|
|
||||||
if (!ret)
|
|
||||||
ret = ocfs2_set_acl(NULL, inode, NULL, ACL_TYPE_ACCESS,
|
|
||||||
clone, NULL, NULL);
|
|
||||||
posix_acl_release(clone);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -386,3 +386,21 @@ posix_acl_chmod_masq(struct posix_acl *acl, mode_t mode)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, mode_t mode)
|
||||||
|
{
|
||||||
|
struct posix_acl *clone = posix_acl_clone(*acl, gfp);
|
||||||
|
int err = -ENOMEM;
|
||||||
|
if (clone) {
|
||||||
|
err = posix_acl_chmod_masq(clone, mode);
|
||||||
|
if (err) {
|
||||||
|
posix_acl_release(clone);
|
||||||
|
clone = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
posix_acl_release(*acl);
|
||||||
|
*acl = clone;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(posix_acl_chmod);
|
||||||
|
|
|
@ -445,7 +445,10 @@ int reiserfs_cache_default_acl(struct inode *inode)
|
||||||
|
|
||||||
int reiserfs_acl_chmod(struct inode *inode)
|
int reiserfs_acl_chmod(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct posix_acl *acl, *clone;
|
struct reiserfs_transaction_handle th;
|
||||||
|
struct posix_acl *acl;
|
||||||
|
size_t size;
|
||||||
|
int depth;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (S_ISLNK(inode->i_mode))
|
if (S_ISLNK(inode->i_mode))
|
||||||
|
@ -463,30 +466,22 @@ int reiserfs_acl_chmod(struct inode *inode)
|
||||||
return 0;
|
return 0;
|
||||||
if (IS_ERR(acl))
|
if (IS_ERR(acl))
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
clone = posix_acl_clone(acl, GFP_NOFS);
|
error = posix_acl_chmod(&acl, GFP_NOFS, inode->i_mode);
|
||||||
posix_acl_release(acl);
|
if (error)
|
||||||
if (!clone)
|
return error;
|
||||||
return -ENOMEM;
|
|
||||||
error = posix_acl_chmod_masq(clone, inode->i_mode);
|
|
||||||
if (!error) {
|
|
||||||
struct reiserfs_transaction_handle th;
|
|
||||||
size_t size = reiserfs_xattr_nblocks(inode,
|
|
||||||
reiserfs_acl_size(clone->a_count));
|
|
||||||
int depth;
|
|
||||||
|
|
||||||
depth = reiserfs_write_lock_once(inode->i_sb);
|
size = reiserfs_xattr_nblocks(inode, reiserfs_acl_size(acl->a_count));
|
||||||
error = journal_begin(&th, inode->i_sb, size * 2);
|
depth = reiserfs_write_lock_once(inode->i_sb);
|
||||||
if (!error) {
|
error = journal_begin(&th, inode->i_sb, size * 2);
|
||||||
int error2;
|
if (!error) {
|
||||||
error = reiserfs_set_acl(&th, inode, ACL_TYPE_ACCESS,
|
int error2;
|
||||||
clone);
|
error = reiserfs_set_acl(&th, inode, ACL_TYPE_ACCESS, acl);
|
||||||
error2 = journal_end(&th, inode->i_sb, size * 2);
|
error2 = journal_end(&th, inode->i_sb, size * 2);
|
||||||
if (error2)
|
if (error2)
|
||||||
error = error2;
|
error = error2;
|
||||||
}
|
|
||||||
reiserfs_write_unlock_once(inode->i_sb, depth);
|
|
||||||
}
|
}
|
||||||
posix_acl_release(clone);
|
reiserfs_write_unlock_once(inode->i_sb, depth);
|
||||||
|
posix_acl_release(acl);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -326,7 +326,7 @@ xfs_inherit_acl(struct inode *inode, struct posix_acl *default_acl)
|
||||||
int
|
int
|
||||||
xfs_acl_chmod(struct inode *inode)
|
xfs_acl_chmod(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct posix_acl *acl, *clone;
|
struct posix_acl *acl;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (S_ISLNK(inode->i_mode))
|
if (S_ISLNK(inode->i_mode))
|
||||||
|
@ -336,16 +336,12 @@ xfs_acl_chmod(struct inode *inode)
|
||||||
if (IS_ERR(acl) || !acl)
|
if (IS_ERR(acl) || !acl)
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
|
|
||||||
clone = posix_acl_clone(acl, GFP_KERNEL);
|
error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = xfs_set_acl(inode, ACL_TYPE_ACCESS, acl);
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
if (!clone)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
error = posix_acl_chmod_masq(clone, inode->i_mode);
|
|
||||||
if (!error)
|
|
||||||
error = xfs_set_acl(inode, ACL_TYPE_ACCESS, clone);
|
|
||||||
|
|
||||||
posix_acl_release(clone);
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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_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);
|
||||||
extern int set_posix_acl(struct inode *, int, struct posix_acl *);
|
extern int set_posix_acl(struct inode *, int, struct posix_acl *);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue