summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-11-02 11:16:12 +0100
committerDavid Sterba <dsterba@suse.com>2016-11-09 13:47:30 +0100
commitb9ff0190cf7c215684c12de279364b552bab7776 (patch)
tree55475c5ffab4a0fdb3d002e56a44c97b4006bddd
parente6410f631d19eb15885fdbea5b8a33c059dd0a3c (diff)
btrfs-progs: dump-tree: convert dir-item-to-string to table
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--print-tree.c42
1 files changed, 14 insertions, 28 deletions
diff --git a/print-tree.c b/print-tree.c
index ea9b194f..e3f87cb2 100644
--- a/print-tree.c
+++ b/print-tree.c
@@ -31,35 +31,21 @@ static void print_dir_item_type(struct extent_buffer *eb,
struct btrfs_dir_item *di)
{
u8 type = btrfs_dir_type(eb, di);
+ static const char* dir_item_str[] = {
+ [BTRFS_FT_REG_FILE] = "FILE",
+ [BTRFS_FT_DIR] = "DIR",
+ [BTRFS_FT_CHRDEV] = "CHRDEV",
+ [BTRFS_FT_BLKDEV] = "BLKDEV",
+ [BTRFS_FT_FIFO] = "FIFO",
+ [BTRFS_FT_SOCK] = "SOCK",
+ [BTRFS_FT_SYMLINK] = "SYMLINK",
+ [BTRFS_FT_XATTR] = "XATTR"
+ };
- switch (type) {
- case BTRFS_FT_REG_FILE:
- printf("FILE");
- break;
- case BTRFS_FT_DIR:
- printf("DIR");
- break;
- case BTRFS_FT_CHRDEV:
- printf("CHRDEV");
- break;
- case BTRFS_FT_BLKDEV:
- printf("BLKDEV");
- break;
- case BTRFS_FT_FIFO:
- printf("FIFO");
- break;
- case BTRFS_FT_SOCK:
- printf("SOCK");
- break;
- case BTRFS_FT_SYMLINK:
- printf("SYMLINK");
- break;
- case BTRFS_FT_XATTR:
- printf("XATTR");
- break;
- default:
- printf("%u", type);
- }
+ if (type < ARRAY_SIZE(dir_item_str) && dir_item_str[type])
+ printf("%s", dir_item_str[type]);
+ else
+ printf("DIR_ITEM.%u", type);
}
static void print_dir_item(struct extent_buffer *eb, u32 size,