summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2014-10-23 19:05:31 +0200
committerDavid Sterba <dsterba@suse.cz>2014-12-04 16:48:09 +0100
commit3d1ed6d152107b03c26935a8486af47e22685150 (patch)
tree433e758ee60064eccd0d1ee5667e5bfa40fb1a1d
parente4c12281c27e166ebec6e030cdfb85fd40ded13b (diff)
btrfs-progs: move group type and profile pretty printers to utils
Move and add the btrfs_ prefix. Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--cmds-filesystem.c47
-rw-r--r--utils.c44
-rw-r--r--utils.h2
3 files changed, 48 insertions, 45 deletions
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 253f105b..d3d744e0 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -136,49 +136,6 @@ static const char * const cmd_df_usage[] = {
NULL
};
-static char *group_type_str(u64 flag)
-{
- u64 mask = BTRFS_BLOCK_GROUP_TYPE_MASK |
- BTRFS_SPACE_INFO_GLOBAL_RSV;
-
- switch (flag & mask) {
- case BTRFS_BLOCK_GROUP_DATA:
- return "Data";
- case BTRFS_BLOCK_GROUP_SYSTEM:
- return "System";
- case BTRFS_BLOCK_GROUP_METADATA:
- return "Metadata";
- case BTRFS_BLOCK_GROUP_DATA|BTRFS_BLOCK_GROUP_METADATA:
- return "Data+Metadata";
- case BTRFS_SPACE_INFO_GLOBAL_RSV:
- return "GlobalReserve";
- default:
- return "unknown";
- }
-}
-
-static char *group_profile_str(u64 flag)
-{
- switch (flag & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
- case 0:
- return "single";
- case BTRFS_BLOCK_GROUP_RAID0:
- return "RAID0";
- case BTRFS_BLOCK_GROUP_RAID1:
- return "RAID1";
- case BTRFS_BLOCK_GROUP_RAID5:
- return "RAID5";
- case BTRFS_BLOCK_GROUP_RAID6:
- return "RAID6";
- case BTRFS_BLOCK_GROUP_DUP:
- return "DUP";
- case BTRFS_BLOCK_GROUP_RAID10:
- return "RAID10";
- default:
- return "unknown";
- }
-}
-
static int get_df(int fd, struct btrfs_ioctl_space_args **sargs_ret)
{
u64 count = 0;
@@ -234,8 +191,8 @@ static void print_df(struct btrfs_ioctl_space_args *sargs, unsigned unit_mode)
for (i = 0; i < sargs->total_spaces; i++, sp++) {
printf("%s, %s: total=%s, used=%s\n",
- group_type_str(sp->flags),
- group_profile_str(sp->flags),
+ btrfs_group_type_str(sp->flags),
+ btrfs_group_profile_str(sp->flags),
pretty_size_mode(sp->total_bytes, unit_mode),
pretty_size_mode(sp->used_bytes, unit_mode));
}
diff --git a/utils.c b/utils.c
index 2a924161..d564619b 100644
--- a/utils.c
+++ b/utils.c
@@ -2450,3 +2450,47 @@ int find_next_key(struct btrfs_path *path, struct btrfs_key *key)
}
return 1;
}
+
+char* btrfs_group_type_str(u64 flag)
+{
+ u64 mask = BTRFS_BLOCK_GROUP_TYPE_MASK |
+ BTRFS_SPACE_INFO_GLOBAL_RSV;
+
+ switch (flag & mask) {
+ case BTRFS_BLOCK_GROUP_DATA:
+ return "Data";
+ case BTRFS_BLOCK_GROUP_SYSTEM:
+ return "System";
+ case BTRFS_BLOCK_GROUP_METADATA:
+ return "Metadata";
+ case BTRFS_BLOCK_GROUP_DATA|BTRFS_BLOCK_GROUP_METADATA:
+ return "Data+Metadata";
+ case BTRFS_SPACE_INFO_GLOBAL_RSV:
+ return "GlobalReserve";
+ default:
+ return "unknown";
+ }
+}
+
+char* btrfs_group_profile_str(u64 flag)
+{
+ switch (flag & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
+ case 0:
+ return "single";
+ case BTRFS_BLOCK_GROUP_RAID0:
+ return "RAID0";
+ case BTRFS_BLOCK_GROUP_RAID1:
+ return "RAID1";
+ case BTRFS_BLOCK_GROUP_RAID5:
+ return "RAID5";
+ case BTRFS_BLOCK_GROUP_RAID6:
+ return "RAID6";
+ case BTRFS_BLOCK_GROUP_DUP:
+ return "DUP";
+ case BTRFS_BLOCK_GROUP_RAID10:
+ return "RAID10";
+ default:
+ return "unknown";
+ }
+}
+
diff --git a/utils.h b/utils.h
index 289e86b4..6948adb5 100644
--- a/utils.h
+++ b/utils.h
@@ -160,5 +160,7 @@ static inline u64 btrfs_min_dev_size(u32 leafsize)
}
int find_next_key(struct btrfs_path *path, struct btrfs_key *key);
+char* btrfs_group_type_str(u64 flag);
+char* btrfs_group_profile_str(u64 flag);
#endif