btrfsprogs/0010-btrfs-progs-move-group-type-and-profile-pretty-print.patch
David Sterba 3ee7e4de90 Accepting request 259501 from home:dsterba:branches:filesystems
- version 3.17
  - check: --init-csum-tree acutally does something useful, rebuilds the whole
    csum tree
  - /dev scanning for btrfs devices is gone
  - /proc/partitions scanning is gone, blkid is used exclusively
  - new subcommand subvolume sync
  - filesystem df: new options to set unit format
  - convert: allow to copy label from the origin, or specify a new one

(not all local patches are upstream, maybe next time)

OBS-URL: https://build.opensuse.org/request/show/259501
OBS-URL: https://build.opensuse.org/package/show/filesystems/btrfsprogs?expand=0&rev=176
2014-11-03 13:17:26 +00:00

148 lines
3.7 KiB
Diff

From 86afea330be6179ac88e0fcaf14924e03257b445 Mon Sep 17 00:00:00 2001
From: David Sterba <dsterba@suse.cz>
Date: Thu, 23 Oct 2014 19:05:31 +0200
Subject: [PATCH 01/42] 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>
---
cmds-filesystem.c | 47 ++---------------------------------------------
utils.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
utils.h | 2 ++
3 files changed, 48 insertions(+), 45 deletions(-)
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index bb5881edef2d..ffa939c5b89a 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -127,49 +127,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;
@@ -225,8 +182,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 f10c178bf36e..43b693c94039 100644
--- a/utils.c
+++ b/utils.c
@@ -2431,3 +2431,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 7accbd20382c..0d202f6344c4 100644
--- a/utils.h
+++ b/utils.h
@@ -159,5 +159,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
--
2.1.1