]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
staging: erofs: complete POSIX ACL support
authorGao Xiang <gaoxiang25@huawei.com>
Tue, 29 Jan 2019 08:35:20 +0000 (16:35 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Jan 2019 14:38:50 +0000 (15:38 +0100)
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>
drivers/staging/erofs/Documentation/filesystems/erofs.txt
drivers/staging/erofs/inode.c
drivers/staging/erofs/namei.c
drivers/staging/erofs/super.c
drivers/staging/erofs/xattr.c
drivers/staging/erofs/xattr.h

index 803988d74c2142a033530905061c777e21c2408a..961ec4da77056cbf2df8b4f00d778ee158949c4d 100644 (file)
@@ -36,6 +36,8 @@ Here is the main features of EROFS:
 
  - 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:
    LZ4 algorithm with 4 KB fixed-output compression for high performance;
 
index 4f04f7c38cf258a6be15f690dc4d3421de51e04e..924b8dfc7a8f5723f500785016410d901c595ef9 100644 (file)
@@ -287,6 +287,7 @@ const struct inode_operations erofs_generic_iops = {
 #ifdef CONFIG_EROFS_FS_XATTR
        .listxattr = erofs_listxattr,
 #endif
+       .get_acl = erofs_get_acl,
 };
 
 const struct inode_operations erofs_symlink_iops = {
@@ -294,6 +295,7 @@ const struct inode_operations erofs_symlink_iops = {
 #ifdef CONFIG_EROFS_FS_XATTR
        .listxattr = erofs_listxattr,
 #endif
+       .get_acl = erofs_get_acl,
 };
 
 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
        .listxattr = erofs_listxattr,
 #endif
+       .get_acl = erofs_get_acl,
 };
 
index 7fed1f996ab06dd811ed1a37fdee90808239c41b..b1752adc5934c99182fe5f09c52364874e740f24 100644 (file)
@@ -238,5 +238,6 @@ const struct inode_operations erofs_dir_iops = {
 #ifdef CONFIG_EROFS_FS_XATTR
        .listxattr = erofs_listxattr,
 #endif
+       .get_acl = erofs_get_acl,
 };
 
index 176fca2af379c1d97e88a78516421c0df9b98e99..15c784fba879dc4afda4227bc9576c152c8a3c01 100644 (file)
@@ -398,6 +398,11 @@ static int erofs_read_super(struct super_block *sb,
        if (!silent)
                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
        INIT_RADIX_TREE(&sbi->workstn_tree, GFP_ATOMIC);
 #endif
@@ -646,6 +651,11 @@ static int erofs_remount(struct super_block *sb, int *flags, char *data)
        if (err)
                goto out;
 
+       if (test_opt(sbi, POSIX_ACL))
+               sb->s_flags |= SB_POSIXACL;
+       else
+               sb->s_flags &= ~SB_POSIXACL;
+
        *flags |= SB_RDONLY;
        return 0;
 out:
index 7de46690d972bd4732fd79092ca4ddbcb6ccd6cf..e748df8d2b4472f3c77752b87bc450a931d0c171 100644 (file)
@@ -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
+
index 634dae9aaa0bbfa29ed0172585558956f961489e..35ba5ac2139a8268f3171fb34348899cf7f0f044 100644 (file)
@@ -87,5 +87,11 @@ static ssize_t __maybe_unused erofs_listxattr(struct dentry *dentry,
 }
 #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