]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - cmd_fsck.c
Don't display an error on --help
[bcachefs-tools-debian] / cmd_fsck.c
index 3f79f7330348d225087324c03b866b1d3a5d41f5..d16760acfd3b363b54485f973e73d183fd5d6462 100644 (file)
@@ -23,13 +23,14 @@ static void usage(void)
 int cmd_fsck(int argc, char *argv[])
 {
        struct bch_opts opts = bch2_opts_empty();
-       int opt;
+       int opt, ret = 0;
 
        opt_set(opts, degraded, true);
        opt_set(opts, fix_errors, FSCK_OPT_ASK);
 
-       while ((opt = getopt(argc, argv, "pynfvh")) != -1)
+       while ((opt = getopt(argc, argv, "apynfvh")) != -1)
                switch (opt) {
+               case 'a': /* outdated alias for -p */
                case 'p':
                        opt_set(opts, fix_errors, FSCK_OPT_YES);
                        break;
@@ -59,6 +60,11 @@ int cmd_fsck(int argc, char *argv[])
        if (IS_ERR(c))
                die("error opening %s: %s", argv[0], strerror(-PTR_ERR(c)));
 
+       if (test_bit(BCH_FS_FSCK_FIXED_ERRORS, &c->flags))
+               ret = 2;
+       if (test_bit(BCH_FS_FSCK_UNFIXED_ERRORS, &c->flags))
+               ret = 4;
+
        bch2_fs_stop(c);
-       return 0;
+       return ret;
 }