[PATCH v8 1/2] erofs-utils: lib: expose erofs_xattr_prefix_matches()
Hongzhen Luo
hongzhen at linux.alibaba.com
Thu Sep 12 23:11:07 AEST 2024
Prepare for the feature of exporting extended attributes for
`fsck.erofs`.
Signed-off-by: Hongzhen Luo <hongzhen at linux.alibaba.com>
---
v3: Change the name erofs_match_prefix() to erofs_xattr_prefix_matches().
v2: https://lore.kernel.org/all/20240906095853.3167228-1-hongzhen@linux.alibaba.com/
v1: https://lore.kernel.org/all/20240906083849.3090392-1-hongzhen@linux.alibaba.com/
---
include/erofs/xattr.h | 3 +++
lib/xattr.c | 12 +++++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/include/erofs/xattr.h b/include/erofs/xattr.h
index 7643611..804f565 100644
--- a/include/erofs/xattr.h
+++ b/include/erofs/xattr.h
@@ -61,6 +61,9 @@ void erofs_clear_opaque_xattr(struct erofs_inode *inode);
int erofs_set_origin_xattr(struct erofs_inode *inode);
int erofs_read_xattrs_from_disk(struct erofs_inode *inode);
+bool erofs_xattr_prefix_matches(const char *key, unsigned int *index,
+ unsigned int *len);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/xattr.c b/lib/xattr.c
index 9f31f2d..63c7fce 100644
--- a/lib/xattr.c
+++ b/lib/xattr.c
@@ -138,8 +138,8 @@ struct ea_type_node {
static LIST_HEAD(ea_name_prefixes);
static unsigned int ea_prefix_count;
-static bool match_prefix(const char *key, unsigned int *index,
- unsigned int *len)
+bool erofs_xattr_prefix_matches(const char *key, unsigned int *index,
+ unsigned int *len)
{
struct xattr_prefix *p;
@@ -196,7 +196,8 @@ static struct xattr_item *get_xattritem(char *kvbuf, unsigned int len[2])
if (!item)
return ERR_PTR(-ENOMEM);
- if (!match_prefix(kvbuf, &item->base_index, &item->prefix_len)) {
+ if (!erofs_xattr_prefix_matches(kvbuf, &item->base_index,
+ &item->prefix_len)) {
free(item);
return ERR_PTR(-ENODATA);
}
@@ -1425,7 +1426,7 @@ int erofs_getxattr(struct erofs_inode *vi, const char *name, char *buffer,
if (ret)
return ret;
- if (!match_prefix(name, &prefix, &prefixlen))
+ if (!erofs_xattr_prefix_matches(name, &prefix, &prefixlen))
return -ENODATA;
it.it.sbi = vi->sbi;
@@ -1600,7 +1601,8 @@ int erofs_xattr_insert_name_prefix(const char *prefix)
if (!tnode)
return -ENOMEM;
- if (!match_prefix(prefix, &tnode->base_index, &tnode->base_len)) {
+ if (!erofs_xattr_prefix_matches(prefix, &tnode->base_index,
+ &tnode->base_len)) {
free(tnode);
return -ENODATA;
}
--
2.43.5
More information about the Linux-erofs
mailing list