mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-20 05:31:15 +00:00
xattr handlers: Pass handler to operations instead of flags
The xattr_handler operations are currently all passed a file system specific flags value which the operations can use to disambiguate between different handlers; some file systems use that to distinguish the xattr namespace, for example. In some oprations, it would be useful to also have access to the handler prefix. To allow that, pass a pointer to the handler to operations instead of the flags value alone. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
bf781714b3
commit
d9a82a0403
32 changed files with 306 additions and 226 deletions
|
@ -762,8 +762,9 @@ posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl,
|
|||
EXPORT_SYMBOL (posix_acl_to_xattr);
|
||||
|
||||
static int
|
||||
posix_acl_xattr_get(struct dentry *dentry, const char *name,
|
||||
void *value, size_t size, int type)
|
||||
posix_acl_xattr_get(const struct xattr_handler *handler,
|
||||
struct dentry *dentry, const char *name,
|
||||
void *value, size_t size)
|
||||
{
|
||||
struct posix_acl *acl;
|
||||
int error;
|
||||
|
@ -775,7 +776,7 @@ posix_acl_xattr_get(struct dentry *dentry, const char *name,
|
|||
if (d_is_symlink(dentry))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
acl = get_acl(d_backing_inode(dentry), type);
|
||||
acl = get_acl(d_backing_inode(dentry), handler->flags);
|
||||
if (IS_ERR(acl))
|
||||
return PTR_ERR(acl);
|
||||
if (acl == NULL)
|
||||
|
@ -788,8 +789,9 @@ posix_acl_xattr_get(struct dentry *dentry, const char *name,
|
|||
}
|
||||
|
||||
static int
|
||||
posix_acl_xattr_set(struct dentry *dentry, const char *name,
|
||||
const void *value, size_t size, int flags, int type)
|
||||
posix_acl_xattr_set(const struct xattr_handler *handler,
|
||||
struct dentry *dentry, const char *name,
|
||||
const void *value, size_t size, int flags)
|
||||
{
|
||||
struct inode *inode = d_backing_inode(dentry);
|
||||
struct posix_acl *acl = NULL;
|
||||
|
@ -802,7 +804,7 @@ posix_acl_xattr_set(struct dentry *dentry, const char *name,
|
|||
if (!inode->i_op->set_acl)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
|
||||
if (handler->flags == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
|
||||
return value ? -EACCES : 0;
|
||||
if (!inode_owner_or_capable(inode))
|
||||
return -EPERM;
|
||||
|
@ -819,27 +821,23 @@ posix_acl_xattr_set(struct dentry *dentry, const char *name,
|
|||
}
|
||||
}
|
||||
|
||||
ret = inode->i_op->set_acl(inode, acl, type);
|
||||
ret = inode->i_op->set_acl(inode, acl, handler->flags);
|
||||
out:
|
||||
posix_acl_release(acl);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static size_t
|
||||
posix_acl_xattr_list(struct dentry *dentry, char *list, size_t list_size,
|
||||
const char *name, size_t name_len, int type)
|
||||
posix_acl_xattr_list(const struct xattr_handler *handler,
|
||||
struct dentry *dentry, char *list, size_t list_size,
|
||||
const char *name, size_t name_len)
|
||||
{
|
||||
const char *xname;
|
||||
const char *xname = handler->prefix;
|
||||
size_t size;
|
||||
|
||||
if (!IS_POSIXACL(d_backing_inode(dentry)))
|
||||
return 0;
|
||||
|
||||
if (type == ACL_TYPE_ACCESS)
|
||||
xname = POSIX_ACL_XATTR_ACCESS;
|
||||
else
|
||||
xname = POSIX_ACL_XATTR_DEFAULT;
|
||||
|
||||
size = strlen(xname) + 1;
|
||||
if (list && size <= list_size)
|
||||
memcpy(list, xname, size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue