]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - cmd_format.c
Change open_for_format to the block io api
[bcachefs-tools-debian] / cmd_format.c
index 26a1cd9f725837cb50b5b82d42339b91453220b7..42f3fc6ca4ac822422906a1505a20ff7c6a571ce 100644 (file)
@@ -230,8 +230,11 @@ int cmd_format(int argc, char *argv[])
                initialize = false;
        }
 
-       darray_for_each(devices, dev)
-               dev->fd = open_for_format(dev->path, force);
+       darray_for_each(devices, dev) {
+               int ret = open_for_format(dev, force);
+               if (ret)
+                       die("Error opening %s: %s", dev_opts.path, strerror(-ret));
+       }
 
        struct bch_sb *sb =
                bch2_format(fs_opt_strs,
@@ -245,7 +248,7 @@ int cmd_format(int argc, char *argv[])
 
                buf.human_readable_units = true;
 
-               bch2_sb_to_text(&buf, sb, false, 1 << BCH_SB_FIELD_members);
+               bch2_sb_to_text(&buf, sb, false, 1 << BCH_SB_FIELD_members_v2);
                printf("%s", buf.buf);
 
                printbuf_exit(&buf);
@@ -305,8 +308,9 @@ int cmd_show_super(int argc, char *argv[])
                { "help",                       0, NULL, 'h' },
                { NULL }
        };
-       unsigned fields = 1 << BCH_SB_FIELD_members;
+       unsigned fields = 0;
        bool print_layout = false;
+       bool print_default_fields = true;
        int opt;
 
        while ((opt = getopt_long(argc, argv, "f:lh", longopts, NULL)) != -1)
@@ -316,6 +320,7 @@ int cmd_show_super(int argc, char *argv[])
                                ? ~0
                                : read_flag_list_or_die(optarg,
                                        bch2_sb_fields, "superblock field");
+                       print_default_fields = false;
                        break;
                case 'l':
                        print_layout = true;
@@ -342,6 +347,11 @@ int cmd_show_super(int argc, char *argv[])
        if (ret)
                die("Error opening %s: %s", dev, bch2_err_str(ret));
 
+       if (print_default_fields)
+               fields = bch2_sb_get_members_v2(sb.sb)
+                       ? 1 << BCH_SB_FIELD_members_v2
+                       : 1 << BCH_SB_FIELD_members_v1;
+
        struct printbuf buf = PRINTBUF;
 
        buf.human_readable_units = true;