From: Filipe Manana Date: Fri, 12 Sep 2025 16:25:12 +0000 (+0100) Subject: btrfs: print-tree: print information about inode extref items X-Git-Tag: v6.18-rc1~204^2~32 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7317555f4553aaec9dc732e24c88b8258b3c9deb;p=thirdparty%2Fkernel%2Flinux.git btrfs: print-tree: print information about inode extref items Currently we ignore inode extref items, we just print their key, item offset in the leaf and their size, no information about their content like the index number, parent inode, name length and name. Improve on this by printing the index, parent and name length in the same format as btrfs-progs. Note that we don't print the name, as that would require some processing and escaping like we do in btrfs-progs, and that could expose sensitive information for some users in case they share their dmesg/syslog and it contains a leaf dump. So for now leave names out. Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c index 7a7156257d593..0a2a6e82a3bfc 100644 --- a/fs/btrfs/print-tree.c +++ b/fs/btrfs/print-tree.c @@ -297,6 +297,26 @@ static void print_inode_ref_item(const struct extent_buffer *eb, int i) } } +static void print_inode_extref_item(const struct extent_buffer *eb, int i) +{ + const u32 size = btrfs_item_size(eb, i); + struct btrfs_inode_extref *extref; + u32 cur = 0; + + extref = btrfs_item_ptr(eb, i, struct btrfs_inode_extref); + while (cur < size) { + const u64 index = btrfs_inode_extref_index(eb, extref); + const u32 name_len = btrfs_inode_extref_name_len(eb, extref); + const u64 parent = btrfs_inode_extref_parent(eb, extref); + const u32 len = sizeof(*extref) + name_len; + + pr_info("\t\tindex %llu parent %llu name_len %u\n", + index, parent, name_len); + extref = (struct btrfs_inode_extref *)((char *)extref + len); + cur += len; + } +} + void btrfs_print_leaf(const struct extent_buffer *l) { struct btrfs_fs_info *fs_info; @@ -334,6 +354,9 @@ void btrfs_print_leaf(const struct extent_buffer *l) case BTRFS_INODE_REF_KEY: print_inode_ref_item(l, i); break; + case BTRFS_INODE_EXTREF_KEY: + print_inode_extref_item(l, i); + break; case BTRFS_DIR_ITEM_KEY: case BTRFS_DIR_INDEX_KEY: case BTRFS_XATTR_ITEM_KEY: