diff mbox series

[1/6] btrfs-progs: Added rowspec struct and neccesary include file for json output format

Message ID 20250214164709.51465-2-racz.zoli@gmail.com (mailing list archive)
State New
Headers show
Series btrfs-progs: V2 scrub status: add json output format | expand

Commit Message

Racz Zoltan Feb. 14, 2025, 4:47 p.m. UTC
---
 cmds/scrub.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
diff mbox series

Patch

diff --git a/cmds/scrub.c b/cmds/scrub.c
index f769188a..f049e1ed 100644
--- a/cmds/scrub.c
+++ b/cmds/scrub.c
@@ -53,6 +53,7 @@ 
 #include "common/sysfs-utils.h"
 #include "common/string-table.h"
 #include "common/string-utils.h"
+#include "common/format-output.h"
 #include "common/help.h"
 #include "cmds/commands.h"
 
@@ -124,6 +125,41 @@  struct scrub_fs_stat {
 	int i;
 };
 
+struct format_ctx fctx;
+
+static const struct rowspec scrub_status_rowspec[] = {
+	{ .key = "uuid", .fmt = "%s", .out_json = "uuid"},
+	{ .key = "dev", .fmt = "%s", .out_json = "dev"},
+	{ .key = "id", .fmt = "%llu", .out_json = "id"},
+	{ .key = "status", .fmt = "%s", .out_json = "status"},
+	{ .key = "duration", .fmt = "duration", .out_json = "duration"},
+	{ .key = "started-at", .fmt = "date-time", .out_json = "started-at"},
+	{ .key = "resumed-at", .fmt = "date-time", .out_json = "resumed-at"},
+	{ .key = "data-extents-scrubbed", .fmt = "%llu", .out_json = "data-extents-scrubbed"},
+	{ .key = "tree-extents-scrubbed", .fmt = "%llu", .out_json = "tree-extents-scrubbed"},
+	{ .key = "data-bytes-scrubbed", .fmt = "%llu", .out_json = "data-bytes-scrubbed"},
+	{ .key = "tree-bytes-scrubbed", .fmt = "%llu", .out_json = "tree-bytes-scrubbed"},
+	{ .key = "read-errors", .fmt = "%llu", .out_json = "read-errors"},
+	{ .key = "csum-errors", .fmt = "%llu", .out_json = "csum-errors"},
+	{ .key = "verify-errors", .fmt = "%llu", .out_json = "verify-errors"},
+	{ .key = "no-csum", .fmt = "%llu", .out_json = "no-csum"},
+	{ .key = "csum-discards", .fmt = "%llu", .out_json = "csum-discards"},
+	{ .key = "super-errors", .fmt = "%llu", .out_json = "super-errors"},
+	{ .key = "malloc-errors", .fmt = "%llu", .out_json = "malloc-errors"},
+	{ .key = "uncorrectable-errors", .fmt = "%llu", .out_json = "uncorrectable-errors"},
+	{ .key = "unverified-errors", .fmt = "%llu", .out_json = "unverified-errors"},
+	{ .key = "corrected-errors", .fmt = "%llu", .out_json = "corrected-errors"},
+	{ .key = "last-physical", .fmt = "%llu", .out_json = "last-physical"},
+	{ .key = "time-left", .fmt = "duration", .out_json = "time-left"},
+	{ .key = "eta", .fmt = "date-time", .out_json = "eta"},
+	{ .key = "total-bytes-to-scrub", .fmt = "%llu", .out_json = "total-bytes-to-scrub"},
+	{ .key = "bytes-scrubbed", .fmt = "%llu", .out_json = "bytes-scrubbed"},
+	{ .key = "rate", .fmt = "%llu", .out_json = "rate"},
+	{ .key = "limit", .fmt = "%llu", .out_json = "limit"},
+
+	ROWSPEC_END
+};
+
 static void print_scrub_full(struct btrfs_scrub_progress *sp)
 {
 	pr_verbose(LOG_DEFAULT, "\tdata_extents_scrubbed: %llu\n", sp->data_extents_scrubbed);