Skip to content

Commit 7317555

Browse files
fdmananakdave
authored andcommitted
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 <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>
1 parent cee3aa1 commit 7317555

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

fs/btrfs/print-tree.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,26 @@ static void print_inode_ref_item(const struct extent_buffer *eb, int i)
297297
}
298298
}
299299

300+
static void print_inode_extref_item(const struct extent_buffer *eb, int i)
301+
{
302+
const u32 size = btrfs_item_size(eb, i);
303+
struct btrfs_inode_extref *extref;
304+
u32 cur = 0;
305+
306+
extref = btrfs_item_ptr(eb, i, struct btrfs_inode_extref);
307+
while (cur < size) {
308+
const u64 index = btrfs_inode_extref_index(eb, extref);
309+
const u32 name_len = btrfs_inode_extref_name_len(eb, extref);
310+
const u64 parent = btrfs_inode_extref_parent(eb, extref);
311+
const u32 len = sizeof(*extref) + name_len;
312+
313+
pr_info("\t\tindex %llu parent %llu name_len %u\n",
314+
index, parent, name_len);
315+
extref = (struct btrfs_inode_extref *)((char *)extref + len);
316+
cur += len;
317+
}
318+
}
319+
300320
void btrfs_print_leaf(const struct extent_buffer *l)
301321
{
302322
struct btrfs_fs_info *fs_info;
@@ -334,6 +354,9 @@ void btrfs_print_leaf(const struct extent_buffer *l)
334354
case BTRFS_INODE_REF_KEY:
335355
print_inode_ref_item(l, i);
336356
break;
357+
case BTRFS_INODE_EXTREF_KEY:
358+
print_inode_extref_item(l, i);
359+
break;
337360
case BTRFS_DIR_ITEM_KEY:
338361
case BTRFS_DIR_INDEX_KEY:
339362
case BTRFS_XATTR_ITEM_KEY:

0 commit comments

Comments
 (0)