Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] erofs-utils: lib: add erofs_inode_has_xattr helper
@ 2026-11-07  4:27 Wenyuan Xu
  2026-11-07  4:27 ` [PATCH 2/2] erofs-utils: mkfs: fix origin xattrs when merging layers Wenyuan Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Wenyuan Xu @ 2026-11-07  4:27 UTC (permalink / raw)
  To: xiang, linux-erofs

Allow callers to check whether an inode already has an in-memory xattr
with a given name without exposing the internal xattr structures.

Assisted-by: LLM
Signed-off-by: Wenyuan Xu <sereno.xu@deepseek.com>
---
 include/erofs/xattr.h |  1 +
 lib/xattr.c           | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/include/erofs/xattr.h b/include/erofs/xattr.h
index d12c292..0016ad2 100644
--- a/include/erofs/xattr.h
+++ b/include/erofs/xattr.h
@@ -45,6 +45,7 @@ int erofs_setxattr(struct erofs_inode *inode, int index, const char *name,
 		   const void *value, size_t size);
 int erofs_vfs_setxattr(struct erofs_inode *inode, const char *name,
 		       const void *value, size_t size);
+bool erofs_inode_has_xattr(struct erofs_inode *inode, const char *name);
 int erofs_set_opaque_xattr(struct erofs_inode *inode);
 void erofs_clear_opaque_xattr(struct erofs_inode *inode);
 bool erofs_get_opaque_from_disk(struct erofs_inode *inode);
diff --git a/lib/xattr.c b/lib/xattr.c
index d86d94a..a0ac76f 100644
--- a/lib/xattr.c
+++ b/lib/xattr.c
@@ -579,6 +579,16 @@ int erofs_vfs_setxattr(struct erofs_inode *inode, const char *name,
 	return erofs_setxattr(inode, 0, name, value, size);
 }
 
+bool erofs_inode_has_xattr(struct erofs_inode *inode, const char *name)
+{
+	struct erofs_inode_xattr_node *node;
+
+	list_for_each_entry(node, &inode->i_xattrs, list)
+		if (!strcmp(node->item->kvbuf, name))
+			return true;
+	return false;
+}
+
 static void erofs_removexattr(struct erofs_inode *inode, const char *key)
 {
 	struct erofs_inode_xattr_node *node, *n;
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-09  8:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-07  4:27 [PATCH 1/2] erofs-utils: lib: add erofs_inode_has_xattr helper Wenyuan Xu
2026-11-07  4:27 ` [PATCH 2/2] erofs-utils: mkfs: fix origin xattrs when merging layers Wenyuan Xu
2026-11-09  8:51   ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox