[PATCH] btrfs: fix parsing of output of 'btrfs qgroup show' (RHBZ#1188553)
'btrfs qgroup show' used to output bytes in raw, but in btrfs-progs v3.18.2 it outputs bytes with suffix KiB, MiB or like by default, which causes error when parsing the output. Fix it by adding '--raw' to let 'btrfs qgroup show' output raw numbers always. Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> --- daemon/btrfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/daemon/btrfs.c b/daemon/btrfs.c index 5cab52a..402b7de 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -1231,6 +1231,7 @@ do_btrfs_qgroup_show (const char *path) ADD_ARG (argv, i, str_btrfs); ADD_ARG (argv, i, "qgroup"); ADD_ARG (argv, i, "show"); + ADD_ARG (argv, i, "--raw"); ADD_ARG (argv, i, path_buf); ADD_ARG (argv, i, NULL); @@ -1240,6 +1241,9 @@ do_btrfs_qgroup_show (const char *path) return NULL; } + if (verbose) + fprintf (stderr, "output of 'btrfs qgroup show %s' is:\n%s\n", path_buf, out); + lines = split_lines (out); if (!lines) return NULL; -- 2.1.0
On Wednesday 04 February 2015 10:12:06 Hu Tao wrote:
'btrfs qgroup show' used to output bytes in raw, but in btrfs-progs v3.18.2 it outputs bytes with suffix KiB, MiB or like by default, which causes error when parsing the output.
Fix it by adding '--raw' to let 'btrfs qgroup show' output raw numbers always.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> --- daemon/btrfs.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c index 5cab52a..402b7de 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -1231,6 +1231,7 @@ do_btrfs_qgroup_show (const char *path) ADD_ARG (argv, i, str_btrfs); ADD_ARG (argv, i, "qgroup"); ADD_ARG (argv, i, "show"); + ADD_ARG (argv, i, "--raw"); ADD_ARG (argv, i, path_buf); ADD_ARG (argv, i, NULL);
It seems that --raw has been added in btrfs-tools 0.18.2, so need to check for the availability of that parameter, and pass it only in that case. Thanks, -- Pino Toscano
participants (2)
-
Hu Tao -
Pino Toscano