summaryrefslogtreecommitdiff
path: root/fs/btrfs/print-tree.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2025-09-11 17:36:28 +0100
committerDavid Sterba <dsterba@suse.com>2025-09-23 08:49:22 +0200
commitcee3aa138724fd354acd5947d96a3d295b606899 (patch)
tree0179de2ce278e6ce95eadfb06eb3701e9ccea8bf /fs/btrfs/print-tree.c
parent93f818e62a081c707e6833f3ba2b7fa25c90199c (diff)
btrfs: print-tree: print information about inode ref items
Currently we ignore inode ref items, we just print their key, item offset in the leaf and their size, no information about their content like the index number, name length and name. Improve on this by printing the index 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 <wqu@suse.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/print-tree.c')
-rw-r--r--fs/btrfs/print-tree.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
index 5ae611cb3f2e..7a7156257d59 100644
--- a/fs/btrfs/print-tree.c
+++ b/fs/btrfs/print-tree.c
@@ -280,6 +280,23 @@ static void print_dir_item(const struct extent_buffer *eb, int i)
}
}
+static void print_inode_ref_item(const struct extent_buffer *eb, int i)
+{
+ const u32 size = btrfs_item_size(eb, i);
+ struct btrfs_inode_ref *ref = btrfs_item_ptr(eb, i, struct btrfs_inode_ref);
+ u32 cur = 0;
+
+ while (cur < size) {
+ const u64 index = btrfs_inode_ref_index(eb, ref);
+ const u32 name_len = btrfs_inode_ref_name_len(eb, ref);
+ const u32 len = sizeof(*ref) + name_len;
+
+ pr_info("\t\tindex %llu name_len %u\n", index, name_len);
+ ref = (struct btrfs_inode_ref *)((char *)ref + len);
+ cur += len;
+ }
+}
+
void btrfs_print_leaf(const struct extent_buffer *l)
{
struct btrfs_fs_info *fs_info;
@@ -314,6 +331,9 @@ void btrfs_print_leaf(const struct extent_buffer *l)
case BTRFS_INODE_ITEM_KEY:
print_inode_item(l, i);
break;
+ case BTRFS_INODE_REF_KEY:
+ print_inode_ref_item(l, i);
+ break;
case BTRFS_DIR_ITEM_KEY:
case BTRFS_DIR_INDEX_KEY:
case BTRFS_XATTR_ITEM_KEY: