From e7049c592a181d6d43e970ca57f1e21f03c30594 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Fri, 5 Jan 2024 12:39:05 -0500 Subject: [PATCH] cmd_show_super: --field-only --- cmd_format.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cmd_format.c b/cmd_format.c index 86bc59e..45c44e3 100644 --- a/cmd_format.c +++ b/cmd_format.c @@ -305,6 +305,7 @@ static void show_super_usage(void) "\n" "Options:\n" " -f, --fields=(fields) list of sections to print\n" + " --field-only=fiel) print superblock section only, no header\n" " -l, --layout print superblock layout\n" " -h, --help display this help and exit\n" "Report bugs to "); @@ -315,11 +316,13 @@ int cmd_show_super(int argc, char *argv[]) { static const struct option longopts[] = { { "fields", 1, NULL, 'f' }, + { "field-only", 1, NULL, 'F' }, { "layout", 0, NULL, 'l' }, { "help", 0, NULL, 'h' }, { NULL } }; unsigned fields = 0; + int field_only = -1; bool print_layout = false; bool print_default_fields = true; int opt; @@ -333,6 +336,11 @@ int cmd_show_super(int argc, char *argv[]) bch2_sb_fields, "superblock field"); print_default_fields = false; break; + case 'F': + field_only = read_string_list_or_die(optarg, + bch2_sb_fields, "superblock field"); + print_default_fields = false; + break; case 'l': print_layout = true; break; @@ -369,7 +377,14 @@ int cmd_show_super(int argc, char *argv[]) buf.human_readable_units = true; - bch2_sb_to_text(&buf, sb.sb, print_layout, fields); + if (field_only >= 0) { + struct bch_sb_field *f = bch2_sb_field_get_id(sb.sb, field_only); + + if (f) + __bch2_sb_field_to_text(&buf, sb.sb, f); + } else { + bch2_sb_to_text(&buf, sb.sb, print_layout, fields); + } printf("%s", buf.buf); bch2_free_super(&sb); -- 2.39.2