Skip to contentSkip to conversation

ocfs2: enable ocfs2_listxattr for special files

PATCH Applied Su Yue 2 participants 2 messages Mar 12, 2024 OCFS2

lore
Share & tools
lore

Su Yue

author
#0 lore raw

PATCH 1/1 ocfs2: enable ocfs2_listxattr for special files

From: Su Yue <[email protected]>

For special files in S_IFBLK/S_IFCHR/S_IFIFO type, we already have ocfs2_setattr and ocfs2_getattr enabled.
It's confusing for user space if it can use setattr/getattr to control one attribute appointed but can not list attributes using listxattr for above type files:

$ mknod /mnt/b b 0 0
$ setfattr -h -n trusted.name -v 0xbabe /mnt/b
$ getfattr -n trusted.name  /mnt/b
getfattr: Removing leading '/' from absolute path names
trusted.name=0sur4=
$ getfattr -m trusted  /mnt/b
$

Fix it by enabling ocfs2_listxattr for ocfs2_special_file_iops. After the commit, fstests/generic/062 will pass.

---
 fs/ocfs2/file.c | 1 +
 1 file changed, 1 insertion(+)
fs/ocfs2/file.c +1 -0
index 8b6d15010703..0da8e7bd3261 100644
@@ -2763,6 +2763,7 @@ const struct inode_operations ocfs2_file_iops = {
 const struct inode_operations ocfs2_special_file_iops = {
 	.setattr	= ocfs2_setattr,
 	.getattr	= ocfs2_getattr,
+	.listxattr	= ocfs2_listxattr,
 	.permission	= ocfs2_permission,
 	.get_inode_acl	= ocfs2_iop_get_acl,
 	.set_acl	= ocfs2_iop_set_acl,
Signature · 1 line
2.44.0
maintainer Acked-by Joseph Qi \ on v1 1/1
#1 lore raw
Quoted 14 lines · Su Yue

From: Su Yue <[email protected]>

For special files in S_IFBLK/S_IFCHR/S_IFIFO type, we already have ocfs2_setattr and ocfs2_getattr enabled.
It's confusing for user space if it can use setattr/getattr to control one attribute appointed but can not list attributes using listxattr for above type files:

$ mknod /mnt/b b 0 0
$ setfattr -h -n trusted.name -v 0xbabe /mnt/b
$ getfattr -n trusted.name  /mnt/b
getfattr: Removing leading '/' from absolute path names
trusted.name=0sur4=
Quoted 7 lines
$ getfattr -m trusted  /mnt/b
$

Fix it by enabling ocfs2_listxattr for ocfs2_special_file_iops. After the commit, fstests/generic/062 will pass.

Quoted 16 lines
---
 fs/ocfs2/file.c | 1 +
 1 file changed, 1 insertion(+)
fs/ocfs2/file.c +1 -0
index 8b6d15010703..0da8e7bd3261 100644
@@ -2763,6 +2763,7 @@ const struct inode_operations ocfs2_file_iops = {
 const struct inode_operations ocfs2_special_file_iops = {
 	.setattr	= ocfs2_setattr,
 	.getattr	= ocfs2_getattr,
+	.listxattr	= ocfs2_listxattr,
 	.permission	= ocfs2_permission,
 	.get_inode_acl	= ocfs2_iop_get_acl,
 	.set_acl	= ocfs2_iop_set_acl,