mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
posix_acl: Add set_posix_acl
Factor out part of posix_acl_xattr_set into a common function that takes a posix_acl, which nfsd can also call. The prototype already exists in include/linux/posix_acl.h. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Cc: stable@vger.kernel.org Cc: Christoph Hellwig <hch@infradead.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
committed by
J. Bruce Fields
parent
8c7245abda
commit
485e71e8fb
@@ -820,6 +820,28 @@ posix_acl_xattr_get(const struct xattr_handler *handler,
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
set_posix_acl(struct inode *inode, int type, struct posix_acl *acl)
|
||||||
|
{
|
||||||
|
if (!IS_POSIXACL(inode))
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
if (!inode->i_op->set_acl)
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
|
||||||
|
return acl ? -EACCES : 0;
|
||||||
|
if (!inode_owner_or_capable(inode))
|
||||||
|
return -EPERM;
|
||||||
|
|
||||||
|
if (acl) {
|
||||||
|
int ret = posix_acl_valid(acl);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
return inode->i_op->set_acl(inode, acl, type);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(set_posix_acl);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
posix_acl_xattr_set(const struct xattr_handler *handler,
|
posix_acl_xattr_set(const struct xattr_handler *handler,
|
||||||
struct dentry *unused, struct inode *inode,
|
struct dentry *unused, struct inode *inode,
|
||||||
@@ -829,30 +851,12 @@ posix_acl_xattr_set(const struct xattr_handler *handler,
|
|||||||
struct posix_acl *acl = NULL;
|
struct posix_acl *acl = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!IS_POSIXACL(inode))
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
if (!inode->i_op->set_acl)
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
|
|
||||||
if (handler->flags == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
|
|
||||||
return value ? -EACCES : 0;
|
|
||||||
if (!inode_owner_or_capable(inode))
|
|
||||||
return -EPERM;
|
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||||
if (IS_ERR(acl))
|
if (IS_ERR(acl))
|
||||||
return PTR_ERR(acl);
|
return PTR_ERR(acl);
|
||||||
|
|
||||||
if (acl) {
|
|
||||||
ret = posix_acl_valid(acl);
|
|
||||||
if (ret)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
ret = set_posix_acl(inode, handler->flags, acl);
|
||||||
ret = inode->i_op->set_acl(inode, acl, handler->flags);
|
|
||||||
out:
|
|
||||||
posix_acl_release(acl);
|
posix_acl_release(acl);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user