btrfs-fuse: Add listxattr and getxattr interface
PATCH 1/1 btrfs-fuse: Add listxattr and getxattr interface
Signed-off-by hmsjwzb <[email protected]>
--- inode.c | 32 +++++++++++ inode.h | 7 +++ main.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++++ ondisk_format.h | 1 + 4 files changed, 180 insertions(+)
inode.c +32 -0
@@ -9,6 +9,38 @@#include "hash.h" #include "messages.h" +struct btrfs_dir_item *btrfs_match_dir_item_name (struct btrfs_fs_info *fs_info, +struct btrfs_path *path, +const char *name,int name_len) +{ +struct btrfs_dir_item *dir_item; +unsigned long name_ptr; +u32 total_len; +u32 cur =0 ; +u32 this_len; +struct extent_buffer *leaf; + + leaf = path->nodes[0 ]; + dir_item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dir_item); + + total_len =btrfs_item_size_nr (leaf, path->slots[0 ]); +while (cur < total_len) { + this_len =sizeof (*dir_item) + +btrfs_dir_name_len (leaf, dir_item) + +btrfs_dir_data_len (leaf, dir_item); + name_ptr = (unsigned long )(dir_item +1 ); + +if (btrfs_dir_name_len (leaf, dir_item) == name_len && +memcmp_extent_buffer (leaf, name, name_ptr, name_len) ==0 ) +return dir_item; + + cur += this_len; + dir_item = (struct btrfs_dir_item *)((char *)dir_item + + this_len); + } +return NULL ; +} +int btrfs_lookup_one_name (struct btrfs_fs_info *fs_info,struct btrfs_inode *dir,const char *name,size_t name_len,struct btrfs_inode *inode_ret)
inode.h +7 -0
@@ -27,6 +27,12 @@ struct btrfs_inode {u8 file_type; }; +/* +* Match one dir item name +*/ +struct btrfs_dir_item *btrfs_match_dir_item_name (struct btrfs_fs_info *fs_info, +struct btrfs_path *path, +const char *name,int name_len);/* * Lookup one name for @dir. *
@@ -132,4 +138,5 @@ static inline u32 btrfs_type_to_imode(u8 btrfs_ft)int btrfs_stat (struct btrfs_fs_info *fs_info,struct btrfs_inode *inode,struct stat *stbuf); +#endif
main.c +140 -0
158 lines not on this page · raw message
ondisk_format.h +1 -0
@@ -59,6 +59,7 @@ enum btrfs_csum_type {/* A subset of needed key types for read-only operations */ #define BTRFS_INODE_ITEM_KEY 1 +#define BTRFS_XATTR_ITEM_KEY 24#define BTRFS_DIR_ITEM_KEY 84#define BTRFS_DIR_INDEX_KEY 96#define BTRFS_EXTENT_DATA_KEY 108
Signature · 1 line
2.25.1