btrfs-progs: print-tree: show the compression method string

Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
[ changed the format of unknown value ]
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Wang Xiaoguang 2016-03-11 13:09:02 +08:00 committed by David Sterba
parent 1ff2823225
commit cfa4b5bc4d
1 changed files with 24 additions and 4 deletions

View File

@ -285,19 +285,40 @@ static void print_uuids(struct extent_buffer *eb)
printf("fs uuid %s\nchunk uuid %s\n", fs_uuid, chunk_uuid); printf("fs uuid %s\nchunk uuid %s\n", fs_uuid, chunk_uuid);
} }
static void compress_type_to_str(u8 compress_type, char *ret)
{
switch (compress_type) {
case BTRFS_COMPRESS_NONE:
strcpy(ret, "none");
break;
case BTRFS_COMPRESS_ZLIB:
strcpy(ret, "zlib");
break;
case BTRFS_COMPRESS_LZO:
strcpy(ret, "lzo");
break;
default:
sprintf(ret, "UNKNOWN.%d", compress_type);
}
}
static void print_file_extent_item(struct extent_buffer *eb, static void print_file_extent_item(struct extent_buffer *eb,
struct btrfs_item *item, struct btrfs_item *item,
int slot, int slot,
struct btrfs_file_extent_item *fi) struct btrfs_file_extent_item *fi)
{ {
int extent_type = btrfs_file_extent_type(eb, fi); int extent_type = btrfs_file_extent_type(eb, fi);
char compress_str[16];
compress_type_to_str(btrfs_file_extent_compression(eb, fi),
compress_str);
if (extent_type == BTRFS_FILE_EXTENT_INLINE) { if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
printf("\t\tinline extent data size %u " printf("\t\tinline extent data size %u "
"ram %u compress %d\n", "ram %u compress(%s)\n",
btrfs_file_extent_inline_item_len(eb, item), btrfs_file_extent_inline_item_len(eb, item),
btrfs_file_extent_inline_len(eb, slot, fi), btrfs_file_extent_inline_len(eb, slot, fi),
btrfs_file_extent_compression(eb, fi)); compress_str);
return; return;
} }
if (extent_type == BTRFS_FILE_EXTENT_PREALLOC) { if (extent_type == BTRFS_FILE_EXTENT_PREALLOC) {
@ -316,8 +337,7 @@ static void print_file_extent_item(struct extent_buffer *eb,
(unsigned long long)btrfs_file_extent_offset(eb, fi), (unsigned long long)btrfs_file_extent_offset(eb, fi),
(unsigned long long)btrfs_file_extent_num_bytes(eb, fi), (unsigned long long)btrfs_file_extent_num_bytes(eb, fi),
(unsigned long long)btrfs_file_extent_ram_bytes(eb, fi)); (unsigned long long)btrfs_file_extent_ram_bytes(eb, fi));
printf("\t\textent compression %d\n", printf("\t\textent compression(%s)\n", compress_str);
btrfs_file_extent_compression(eb, fi));
} }
/* Caller should ensure sizeof(*ret) >= 16("DATA|TREE_BLOCK") */ /* Caller should ensure sizeof(*ret) >= 16("DATA|TREE_BLOCK") */