From 15eb03ca1d2f9f8817e8b2ef6f991c272ad390d9 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 6 Oct 2021 23:42:43 +0200 Subject: [PATCH] btrfs-progs: use raid table for profile names in print-tree.c Pick the names from the raid table and do the uppercase conversion. Signed-off-by: David Sterba --- kernel-shared/print-tree.c | 43 ++++++++++++++------------------------ 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c index 0f97e6c5..67b654e6 100644 --- a/kernel-shared/print-tree.c +++ b/kernel-shared/print-tree.c @@ -25,6 +25,7 @@ #include "kernel-shared/ctree.h" #include "kernel-shared/disk-io.h" #include "kernel-shared/print-tree.h" +#include "kernel-shared/volumes.h" #include "common/utils.h" static void print_dir_item_type(struct extent_buffer *eb, @@ -162,6 +163,7 @@ static void print_inode_ref_item(struct extent_buffer *eb, u32 size, static void bg_flags_to_str(u64 flags, char *ret) { int empty = 1; + const char *name; if (flags & BTRFS_BLOCK_GROUP_DATA) { empty = 0; @@ -177,33 +179,20 @@ static void bg_flags_to_str(u64 flags, char *ret) strcat(ret, "|"); strcat(ret, "SYSTEM"); } - switch (flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) { - case BTRFS_BLOCK_GROUP_RAID0: - strcat(ret, "|RAID0"); - break; - case BTRFS_BLOCK_GROUP_RAID1: - strcat(ret, "|RAID1"); - break; - case BTRFS_BLOCK_GROUP_RAID1C3: - strcat(ret, "|RAID1C3"); - break; - case BTRFS_BLOCK_GROUP_RAID1C4: - strcat(ret, "|RAID1C4"); - break; - case BTRFS_BLOCK_GROUP_DUP: - strcat(ret, "|DUP"); - break; - case BTRFS_BLOCK_GROUP_RAID10: - strcat(ret, "|RAID10"); - break; - case BTRFS_BLOCK_GROUP_RAID5: - strcat(ret, "|RAID5"); - break; - case BTRFS_BLOCK_GROUP_RAID6: - strcat(ret, "|RAID6"); - break; - default: - break; + strcat(ret, "|"); + name = btrfs_bg_type_to_raid_name(flags); + if (!name) { + strcat(ret, "UNKNOWN"); + } else { + char buf[32]; + char *tmp = buf; + + strcpy(buf, name); + while (*tmp) { + *tmp = toupper(*tmp); + tmp++; + } + strcpy(ret, buf); } }