erofs-utils: fuse: introduce xattr support
PATCH 1/1 erofs-utils: fuse: introduce xattr support
This implements xattr functionalities for erofsfuse. A large amount of code was adapted from Linux kernel.
--- fuse/main.c | 32 +++ include/erofs/internal.h | 8 + include/erofs/xattr.h | 21 ++ lib/xattr.c | 508 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 569 insertions(+)
fuse/main.c +32 -0
@@ -139,7 +139,39 @@ 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; +int i; + +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.0
Hi Jianan,
Quoted 29 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]>--- fuse/main.c | 32 +++ include/erofs/internal.h | 8 + include/erofs/xattr.h | 21 ++ lib/xattr.c | 508 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 569 insertions(+)fuse/main.c +10
-0@@ -139,7 +139,39 @@ 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)
fuse/main.c static int erofsfuse_readlink(const char *path, char *buffer, size_t size) · line 161
Quoted 10 lines
fuse/main.c +10
-0+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; +int i;
As we discussed offline, this line should be unneeded.
Thanks,
Gao Xiang
Quoted 36 lines · Gao Xiang
Hi Jianan,
Quoted 33 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]>--- fuse/main.c | 32 +++ include/erofs/internal.h | 8 + include/erofs/xattr.h | 21 ++ lib/xattr.c | 508 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 569 insertions(+)fuse/main.c +14
-0@@ -139,7 +139,39 @@ 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); +}
Quoted 8 lines
fuse/main.c static int erofsfuse_readlink(const char *path, char *buffer, size_t size) · line 161
Quoted 6 lines
fuse/main.c +6
-0+ +static int erofsfuse_listxattr (const char *path,char *list,size_t size) +{ +int ret; +struct erofs_inode vi; +int i;As we discussed offline, this line should be unneeded.
A new patch has been sent, in addition a test case has been added.
Thanks,
Jianan
Quoted 3 lines
Thanks,
Gao Xiang