Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc26ab5f authored by Al Viro's avatar Al Viro
Browse files

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: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 4482a087
Loading
Loading
Loading
Loading
+5 −8
Original line number Diff line number Diff line
@@ -162,21 +162,18 @@ static int v9fs_set_acl(struct dentry *dentry, int type, struct posix_acl *acl)
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;
}
+5 −11
Original line number Diff line number Diff line
@@ -272,7 +272,7 @@ int btrfs_init_acl(struct btrfs_trans_handle *trans,

int btrfs_acl_chmod(struct inode *inode)
{
	struct posix_acl *acl, *clone;
	struct posix_acl *acl;
	int ret = 0;

	if (S_ISLNK(inode->i_mode))
@@ -285,17 +285,11 @@ int btrfs_acl_chmod(struct inode *inode)
	if (IS_ERR_OR_NULL(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);
	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;
}

+5 −8
Original line number Diff line number Diff line
@@ -316,7 +316,7 @@ ext2_init_acl(struct inode *inode, struct inode *dir)
int
ext2_acl_chmod(struct inode *inode)
{
	struct posix_acl *acl, *clone;
	struct posix_acl *acl;
        int error;

	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);
	if (IS_ERR(acl) || !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);
	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;
}

+19 −24
Original line number Diff line number Diff line
@@ -326,7 +326,9 @@ ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
int
ext3_acl_chmod(struct inode *inode)
{
	struct posix_acl *acl, *clone;
	struct posix_acl *acl;
	handle_t *handle;
	int retries = 0;
        int error;

	if (S_ISLNK(inode->i_mode))
@@ -336,15 +338,9 @@ ext3_acl_chmod(struct inode *inode)
	acl = ext3_get_acl(inode, ACL_TYPE_ACCESS);
	if (IS_ERR(acl) || !acl)
		return PTR_ERR(acl);
	clone = posix_acl_clone(acl, GFP_KERNEL);
	posix_acl_release(acl);
	if (!clone)
		return -ENOMEM;
	error = posix_acl_chmod_masq(clone, inode->i_mode);
	if (!error) {
		handle_t *handle;
		int retries = 0;

	error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
	if (error)
		return error;
retry:
	handle = ext3_journal_start(inode,
			EXT3_DATA_TRANS_BLOCKS(inode->i_sb));
@@ -353,14 +349,13 @@ ext3_acl_chmod(struct inode *inode)
		ext3_std_error(inode->i_sb, error);
		goto out;
	}
		error = ext3_set_acl(handle, inode, ACL_TYPE_ACCESS, clone);
	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:
	posix_acl_release(clone);
	posix_acl_release(acl);
	return error;
}

+20 −24
Original line number Diff line number Diff line
@@ -324,9 +324,12 @@ ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
int
ext4_acl_chmod(struct inode *inode)
{
	struct posix_acl *acl, *clone;
	struct posix_acl *acl;
	handle_t *handle;
	int retries = 0;
	int error;


	if (S_ISLNK(inode->i_mode))
		return -EOPNOTSUPP;
	if (!test_opt(inode->i_sb, POSIX_ACL))
@@ -334,15 +337,9 @@ ext4_acl_chmod(struct inode *inode)
	acl = ext4_get_acl(inode, ACL_TYPE_ACCESS);
	if (IS_ERR(acl) || !acl)
		return PTR_ERR(acl);
	clone = posix_acl_clone(acl, GFP_KERNEL);
	posix_acl_release(acl);
	if (!clone)
		return -ENOMEM;
	error = posix_acl_chmod_masq(clone, inode->i_mode);
	if (!error) {
		handle_t *handle;
		int retries = 0;

	error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
	if (error)
		return error;
retry:
	handle = ext4_journal_start(inode,
			EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
@@ -351,14 +348,13 @@ ext4_acl_chmod(struct inode *inode)
		ext4_std_error(inode->i_sb, error);
		goto out;
	}
		error = ext4_set_acl(handle, inode, ACL_TYPE_ACCESS, clone);
	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:
	posix_acl_release(clone);
	posix_acl_release(acl);
	return error;
}

Loading