diff options
author | Gao Xiang <gaoxiang25@huawei.com> | 2019-01-29 16:35:20 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-01-30 15:38:50 +0100 |
commit | 516c115c9170f5835102ef3982d7073808da540b (patch) | |
tree | 4a94b5f62816c5f7098ab56448c64fe5cad0bec6 /drivers/staging/erofs/xattr.c | |
parent | a24df1f62f7929d5d8f31fc64988581e160057d1 (diff) | |
download | linux-stable-516c115c9170f5835102ef3982d7073808da540b.tar.gz linux-stable-516c115c9170f5835102ef3982d7073808da540b.tar.bz2 linux-stable-516c115c9170f5835102ef3982d7073808da540b.zip |
staging: erofs: complete POSIX ACL support
Let's add .get_acl() to read the file's acl from its xattrs
to make POSIX ACL usable.
Here is the on-disk detail,
fullname: system.posix_acl_access
struct erofs_xattr_entry:
.e_name_len = 0
.e_name_index = EROFS_XATTR_INDEX_POSIX_ACL_ACCESS (2)
fullname: system.posix_acl_default
struct erofs_xattr_entry:
.e_name_len = 0
.e_name_index = EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT (3)
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/erofs/xattr.c')
-rw-r--r-- | drivers/staging/erofs/xattr.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c index 7de46690d972..e748df8d2b44 100644 --- a/drivers/staging/erofs/xattr.c +++ b/drivers/staging/erofs/xattr.c @@ -643,3 +643,40 @@ ssize_t erofs_listxattr(struct dentry *dentry, return shared_listxattr(&it); } +#ifdef CONFIG_EROFS_FS_POSIX_ACL +struct posix_acl *erofs_get_acl(struct inode *inode, int type) +{ + struct posix_acl *acl; + int prefix, rc; + char *value = NULL; + + switch (type) { + case ACL_TYPE_ACCESS: + prefix = EROFS_XATTR_INDEX_POSIX_ACL_ACCESS; + break; + case ACL_TYPE_DEFAULT: + prefix = EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT; + break; + default: + return ERR_PTR(-EINVAL); + } + + rc = erofs_getxattr(inode, prefix, "", NULL, 0); + if (rc > 0) { + value = kmalloc(rc, GFP_KERNEL); + if (!value) + return ERR_PTR(-ENOMEM); + rc = erofs_getxattr(inode, prefix, "", value, rc); + } + + if (rc == -ENOATTR) + acl = NULL; + else if (rc < 0) + acl = ERR_PTR(rc); + else + acl = posix_acl_from_xattr(&init_user_ns, value, rc); + kfree(value); + return acl; +} +#endif + |