Skip to content

Commit cee3aa1

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

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

fs/btrfs/print-tree.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,23 @@ static void print_dir_item(const struct extent_buffer *eb, int i)
280280
}
281281
}
282282

283+
static void print_inode_ref_item(const struct extent_buffer *eb, int i)
284+
{
285+
const u32 size = btrfs_item_size(eb, i);
286+
struct btrfs_inode_ref *ref = btrfs_item_ptr(eb, i, struct btrfs_inode_ref);
287+
u32 cur = 0;
288+
289+
while (cur < size) {
290+
const u64 index = btrfs_inode_ref_index(eb, ref);
291+
const u32 name_len = btrfs_inode_ref_name_len(eb, ref);
292+
const u32 len = sizeof(*ref) + name_len;
293+
294+
pr_info("\t\tindex %llu name_len %u\n", index, name_len);
295+
ref = (struct btrfs_inode_ref *)((char *)ref + len);
296+
cur += len;
297+
}
298+
}
299+
283300
void btrfs_print_leaf(const struct extent_buffer *l)
284301
{
285302
struct btrfs_fs_info *fs_info;
@@ -314,6 +331,9 @@ void btrfs_print_leaf(const struct extent_buffer *l)
314331
case BTRFS_INODE_ITEM_KEY:
315332
print_inode_item(l, i);
316333
break;
334+
case BTRFS_INODE_REF_KEY:
335+
print_inode_ref_item(l, i);
336+
break;
317337
case BTRFS_DIR_ITEM_KEY:
318338
case BTRFS_DIR_INDEX_KEY:
319339
case BTRFS_XATTR_ITEM_KEY:

0 commit comments

Comments
 (0)