Prepare for the feature of exporting extended attributes for `fsck.erofs`, which requires obtaining the index based on the name of the extended attribute.
Signed-off-by: Hongzhen Luo <[email protected]> --- include/erofs/xattr.h | 2 ++ lib/xattr.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/erofs/xattr.h b/include/erofs/xattr.h index 7643611..7848fe7 100644 --- a/include/erofs/xattr.h +++ b/include/erofs/xattr.h @@ -61,6 +61,8 @@ 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); +int erofs_xattr_prefix_index(const char *key); + #ifdef __cplusplus } #endif diff --git a/lib/xattr.c b/lib/xattr.c index 9f31f2d..1fed7c0 100644 --- a/lib/xattr.c +++ b/lib/xattr.c @@ -1681,3 +1681,10 @@ out: erofs_xattr_prefixes_cleanup(sbi); return ret; } + +int erofs_xattr_prefix_index(const char *key) +{ + unsigned int index, len; + + return match_prefix(key, &index, &len) ? index : -EINVAL; +} -- 2.43.5
