提交 516c115c 编写于 作者: G Gao Xiang 提交者: Greg Kroah-Hartman

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: NChao Yu <yuchao0@huawei.com>
Signed-off-by: NGao Xiang <gaoxiang25@huawei.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 a24df1f6
...@@ -36,6 +36,8 @@ Here is the main features of EROFS: ...@@ -36,6 +36,8 @@ Here is the main features of EROFS:
- Support xattr inline and tail-end data inline for all files; - Support xattr inline and tail-end data inline for all files;
- Support POSIX.1e ACLs by using xattrs;
- Support transparent file compression as an option: - Support transparent file compression as an option:
LZ4 algorithm with 4 KB fixed-output compression for high performance; LZ4 algorithm with 4 KB fixed-output compression for high performance;
......
...@@ -287,6 +287,7 @@ const struct inode_operations erofs_generic_iops = { ...@@ -287,6 +287,7 @@ const struct inode_operations erofs_generic_iops = {
#ifdef CONFIG_EROFS_FS_XATTR #ifdef CONFIG_EROFS_FS_XATTR
.listxattr = erofs_listxattr, .listxattr = erofs_listxattr,
#endif #endif
.get_acl = erofs_get_acl,
}; };
const struct inode_operations erofs_symlink_iops = { const struct inode_operations erofs_symlink_iops = {
...@@ -294,6 +295,7 @@ const struct inode_operations erofs_symlink_iops = { ...@@ -294,6 +295,7 @@ const struct inode_operations erofs_symlink_iops = {
#ifdef CONFIG_EROFS_FS_XATTR #ifdef CONFIG_EROFS_FS_XATTR
.listxattr = erofs_listxattr, .listxattr = erofs_listxattr,
#endif #endif
.get_acl = erofs_get_acl,
}; };
const struct inode_operations erofs_fast_symlink_iops = { const struct inode_operations erofs_fast_symlink_iops = {
...@@ -301,5 +303,6 @@ const struct inode_operations erofs_fast_symlink_iops = { ...@@ -301,5 +303,6 @@ const struct inode_operations erofs_fast_symlink_iops = {
#ifdef CONFIG_EROFS_FS_XATTR #ifdef CONFIG_EROFS_FS_XATTR
.listxattr = erofs_listxattr, .listxattr = erofs_listxattr,
#endif #endif
.get_acl = erofs_get_acl,
}; };
...@@ -238,5 +238,6 @@ const struct inode_operations erofs_dir_iops = { ...@@ -238,5 +238,6 @@ const struct inode_operations erofs_dir_iops = {
#ifdef CONFIG_EROFS_FS_XATTR #ifdef CONFIG_EROFS_FS_XATTR
.listxattr = erofs_listxattr, .listxattr = erofs_listxattr,
#endif #endif
.get_acl = erofs_get_acl,
}; };
...@@ -398,6 +398,11 @@ static int erofs_read_super(struct super_block *sb, ...@@ -398,6 +398,11 @@ static int erofs_read_super(struct super_block *sb,
if (!silent) if (!silent)
infoln("root inode @ nid %llu", ROOT_NID(sbi)); infoln("root inode @ nid %llu", ROOT_NID(sbi));
if (test_opt(sbi, POSIX_ACL))
sb->s_flags |= SB_POSIXACL;
else
sb->s_flags &= ~SB_POSIXACL;
#ifdef CONFIG_EROFS_FS_ZIP #ifdef CONFIG_EROFS_FS_ZIP
INIT_RADIX_TREE(&sbi->workstn_tree, GFP_ATOMIC); INIT_RADIX_TREE(&sbi->workstn_tree, GFP_ATOMIC);
#endif #endif
...@@ -646,6 +651,11 @@ static int erofs_remount(struct super_block *sb, int *flags, char *data) ...@@ -646,6 +651,11 @@ static int erofs_remount(struct super_block *sb, int *flags, char *data)
if (err) if (err)
goto out; goto out;
if (test_opt(sbi, POSIX_ACL))
sb->s_flags |= SB_POSIXACL;
else
sb->s_flags &= ~SB_POSIXACL;
*flags |= SB_RDONLY; *flags |= SB_RDONLY;
return 0; return 0;
out: out:
......
...@@ -643,3 +643,40 @@ ssize_t erofs_listxattr(struct dentry *dentry, ...@@ -643,3 +643,40 @@ ssize_t erofs_listxattr(struct dentry *dentry,
return shared_listxattr(&it); 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
...@@ -87,5 +87,11 @@ static ssize_t __maybe_unused erofs_listxattr(struct dentry *dentry, ...@@ -87,5 +87,11 @@ static ssize_t __maybe_unused erofs_listxattr(struct dentry *dentry,
} }
#endif #endif
#ifdef CONFIG_EROFS_FS_POSIX_ACL
struct posix_acl *erofs_get_acl(struct inode *inode, int type);
#else
#define erofs_get_acl (NULL)
#endif
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册