erofs-utils: fuse: introduce xattr support
PATCH v2 1/2 erofs-utils: fuse: introduce xattr support
This implements xattr functionalities for erofsfuse. A large amount of code was adapted from Linux kernel.
Signed-off-by Huang Jianan <[email protected]>
--- fuse/main.c | 31 +++ include/erofs/internal.h | 8 + include/erofs/xattr.h | 21 ++ lib/xattr.c | 508 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 568 insertions(+)
fuse/main.c +31 -0
@@ -139,7 +139,38 @@ static int erofsfuse_readlink(const char *path, char *buffer, size_t size)return 0 ; } +static int erofsfuse_getxattr (const char *path,const char *name,char *value, +size_t size) +{ +int ret; +struct erofs_inode vi; + +erofs_dbg ("getxattr(%s): name=%s size=%llu" , path, name, size); + + ret =erofs_ilookup (path, &vi); +if (ret) +return ret; + +return erofs_getxattr (&vi, name, value, size); +} + +static int erofsfuse_listxattr (const char *path,char *list,size_t size) +{ +int ret; +struct erofs_inode vi; + +erofs_dbg ("listxattr(%s): size=%llu" , path, size); + + ret =erofs_ilookup (path, &vi); +if (ret) +return ret; + +return erofs_listxattr (&vi, list, size); +} +static struct fuse_operations erofs_ops = { + .getxattr = erofsfuse_getxattr, + .listxattr = erofsfuse_listxattr, .readlink = erofsfuse_readlink, .getattr = erofsfuse_getattr, .readdir = erofsfuse_readdir,
include/erofs/internal.h +8 -0
@@ -180,6 +180,9 @@ struct erofs_inode {unsigned int xattr_isize;unsigned int extent_isize; +unsigned int xattr_shared_count; +unsigned int *xattr_shared_xattrs; +erofs_nid_t nid;struct erofs_buffer_head *bh;struct erofs_buffer_head *bh_inline, *bh_data;
@@ -351,6 +354,11 @@ static inline int erofs_get_occupied_size(const struct erofs_inode *inode,return 0 ; } +/* data.c */ +int erofs_getxattr (struct erofs_inode *vi,const char *name,char *buffer, +size_t buffer_size); +int erofs_listxattr (struct erofs_inode *vi,char *buffer,size_t buffer_size); +/* zmap.c */ int z_erofs_fill_inode (struct erofs_inode *vi); int z_erofs_map_blocks_iter(struct erofs_inode *vi,
include/erofs/xattr.h +21 -0
@@ -14,6 +14,27 @@ extern "C"#include "internal.h" +#ifndef ENOATTR +#define ENOATTR ENODATA +#endif + +static inline unsigned int inlinexattr_header_size (struct erofs_inode *vi) +{ +return sizeof (struct erofs_xattr_ibody_header ) + +sizeof (u32) * vi->xattr_shared_count; +} + +static inline erofs_blk_t xattrblock_addr (unsigned int xattr_id) +{ +return sbi.xattr_blkaddr + + xattr_id *sizeof (__u32) /EROFS_BLKSIZ ; +} + +static inline unsigned int xattrblock_offset (unsigned int xattr_id) +{ +return (xattr_id *sizeof (__u32)) %EROFS_BLKSIZ ; +} +#define EROFS_INODE_XATTR_ICOUNT (_size) ({\ u32 __size = le16_to_cpu(_size); \ ((__size) == 0) ? 0 : \
lib/xattr.c +508 -0
511 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v2 2/2 erofs-utils: tests: add random test for xattrs
Add random functional check for xattrs.
Signed-off-by Huang Jianan <[email protected]>
--- tests/Makefile.am | 3 ++ tests/erofs/020 | 72 +++++++++++++++++++++++++++++++++++++++++++++ tests/erofs/020.out | 2 ++ 3 files changed, 77 insertions(+) create mode 100755 tests/erofs/020 create mode 100644 tests/erofs/020.out
tests/Makefile.am +3 -0
@@ -91,6 +91,9 @@ TESTS += erofs/018 # 019 - check extended attribute functionality TESTS += erofs/019 +# 020 - test random extended attribute functionality for mkfs and fuse +TESTS += erofs/020 + EXTRA_DIST = common/rc erofs clean-local: clean-local-check
tests/erofs/020 new file +72 -0
72 lines not on this page · raw message
tests/erofs/020.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 020 +Silence is golden
Signature · 1 line
2.34.1
Hi Jianan,
( +Cc Sheng Yong )
Quoted 4 lines · Huang Jianan
This implements xattr functionalities for erofsfuse. A large amount of code was adapted from Linux kernel.
Signed-off-by Huang Jianan <[email protected]>
I've applied this patch. Yet if you have extra time, could you update fsck.erofs supporting xattr extraction as well?
Thanks,
Gao Xiang