Skip to contentSkip to conversation

staging: erofs: use xattr_prefix to wrap up

PATCH In review Gao Xiang 2 participants 6 messages Jan 25, 2019 Staging

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/2 staging: erofs: use xattr_prefix to wrap up

Let's use xattr_prefix instead of open code.
No logic changes.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 drivers/staging/erofs/xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/erofs/xattr.c +1 -1
index 1c9498e38f0e..eca65df46133 100644
@@ -521,7 +521,7 @@ static int xattr_entrylist(struct xattr_iter *_it,
 		return 1;
 
 	/* Note that at least one of 'prefix' and 'name' should be non-NULL */
-	prefix = h->prefix != NULL ? h->prefix : h->name;
+	prefix = xattr_prefix(h);
 	prefix_len = strlen(prefix);
 
 	if (it->buffer == NULL) {
Signature · 1 line
2.14.4
author
#1 lore raw

PATCH 2/2 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.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>

---
This [PATCH 2/2] currently hasn't tested, please ignore temporarily... I will test it asap...

Thanks,
Gao Xiang

 drivers/staging/erofs/inode.c |  3 +++
 drivers/staging/erofs/namei.c |  1 +
 drivers/staging/erofs/xattr.c | 40 ++++++++++++++++++++++++++++++++++++++++
 drivers/staging/erofs/xattr.h |  6 ++++++
 4 files changed, 50 insertions(+)
drivers/staging/erofs/inode.c +3 -0
index 4f04f7c38cf2..924b8dfc7a8f 100644
@@ -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,
 };
 
drivers/staging/erofs/namei.c +1 -0
index 7fed1f996ab0..b1752adc5934 100644
@@ -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,
 };
 
drivers/staging/erofs/xattr.c +40 -0
index eca65df46133..ee66ebffbb93 100644
@@ -644,3 +644,43 @@ 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 ea_prefix, rc;
+	char *ea_name;
+	char *value = NULL;
+
+	switch (type) {
+	case ACL_TYPE_ACCESS:
+		ea_prefix = EROFS_XATTR_INDEX_POSIX_ACL_ACCESS;
+		ea_name = XATTR_NAME_POSIX_ACL_ACCESS;
+		break;
+	case ACL_TYPE_DEFAULT:
+		ea_prefix = EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT;
+		ea_name = XATTR_NAME_POSIX_ACL_DEFAULT;
+		break;
+	default:
+		return ERR_PTR(-EINVAL);
+	}
+
+	rc = erofs_getxattr(inode, ea_prefix, ea_name, NULL, 0);
+	if (rc > 0) {
+		value = kvmalloc(rc, GFP_KERNEL);
+		if (!value)
+			return ERR_PTR(-ENOMEM);
+		rc = erofs_getxattr(inode, ea_prefix, ea_name, 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);
+	kvfree(value);
+	return acl;
+}
+#endif
+
drivers/staging/erofs/xattr.h +6 -0
index 634dae9aaa0b..35ba5ac2139a 100644
@@ -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
 
Signature · 1 line
2.14.4
#2 lore raw

Re: [PATCH 2/2] staging: erofs: complete POSIX ACL support

Quoted 7 lines · Gao Xiang

Let's add .get_acl() to read the file's acl
from its xattrs to make POSIX ACL usable.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>

---
This [PATCH 2/2] currently hasn't tested, please ignore temporarily... I will test it asap...

This is an awkward thing.

Just don't send it until after you test it. We also ignore RFC patches so if you mark it as RFC that will be ignored if you want.

regards,
dan carpenter

author
#3 lore raw

Re: [PATCH 2/2] staging: erofs: complete POSIX ACL support

Hi Dan,

Quoted 9 lines · Dan Carpenter
Quoted 7 lines · Gao Xiang

Let's add .get_acl() to read the file's acl
from its xattrs to make POSIX ACL usable.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>

---
This [PATCH 2/2] currently hasn't tested, please ignore temporarily... I will test it asap...

Quoted 4 lines

This is an awkward thing.

Just don't send it until after you test it. We also ignore RFC patches so if you mark it as RFC that will be ignored if you want.

Yes, you are right.

Actually I just want to send the only [PATCH 1/2], but I missed to change the subject of [PATCH 1/2] -> [PATCH]...Therefore I have to send this incomplete one to complete this "patchset" by mistake...

Thanks,
Gao Xiang

Quoted 4 lines

regards,
dan carpenter

#4 lore raw
In reply to Gao Xiang
Quoted 13 lines · Gao Xiang

Let's use xattr_prefix instead of open code.
No logic changes.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 drivers/staging/erofs/xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/erofs/xattr.c +0 -0
index 1c9498e38f0e..eca65df46133 100644

drivers/staging/erofs/xattr.c static int xattr_entrylist(struct xattr_iter *_it, · line 523

Quoted 3 lines
drivers/staging/erofs/xattr.c +0 -0
@@ -521,7 +521,7 @@ static int xattr_entrylist(struct xattr_iter *_it,
 		return 1;
 
 	/* Note that at least one of 'prefix' and 'name' should be non-NULL */

The comment is sort of confusing now.

drivers/staging/erofs/xattr.c static int xattr_entrylist(struct xattr_iter *_it, · line 525

Quoted 3 lines
drivers/staging/erofs/xattr.c +1 -1
-	prefix = h->prefix != NULL ? h->prefix : h->name;
+	prefix = xattr_prefix(h);
 	prefix_len = strlen(prefix);

regards,
dan carpenter

author
#5 lore raw

Hi Dan,

Quoted 16 lines · Dan Carpenter
Quoted 15 lines · Gao Xiang

Let's use xattr_prefix instead of open code.
No logic changes.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 drivers/staging/erofs/xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/erofs/xattr.c +0 -0
index 1c9498e38f0e..eca65df46133 100644
@@ -521,7 +521,7 @@ static int xattr_entrylist(struct xattr_iter *_it,
 		return 1;
 
Quoted 3 lines

drivers/staging/erofs/xattr.c static int xattr_entrylist(struct xattr_iter *_it, · line 523

Quoted 1 line
drivers/staging/erofs/xattr.c +0 -0
 	/* Note that at least one of 'prefix' and 'name' should be non-NULL */

The comment is sort of confusing now.

OK, I will remove this line.

And I think I will send the whole patchset instead of this cleanup patch only after I test the ACL feature and confirm that it works.

Sorry again about the [PATCH 2/2]...

Thanks,
Gao Xiang

Quoted 8 lines

drivers/staging/erofs/xattr.c static int xattr_entrylist(struct xattr_iter *_it, · line 525

Quoted 4 lines
drivers/staging/erofs/xattr.c +1 -1
-	prefix = h->prefix != NULL ? h->prefix : h->name;
+	prefix = xattr_prefix(h);
 	prefix_len = strlen(prefix);

regards,
dan carpenter