int cmd_fsck(int argc, char *argv[])
{
struct bch_opts opts = bch2_opts_empty();
+ unsigned i;
int opt, ret = 0;
opt_set(opts, degraded, true);
+ opt_set(opts, fsck, true);
opt_set(opts, fix_errors, FSCK_OPT_ASK);
while ((opt = getopt(argc, argv, "apynfvh")) != -1)
/* force check, even if filesystem marked clean: */
break;
case 'v':
- opt_set(opts, verbose_recovery, true);
+ opt_set(opts, verbose, true);
break;
case 'h':
usage();
if (!argc)
die("Please supply device(s) to check");
+ for (i = 0; i < argc; i++)
+ if (dev_mounted_rw(argv[i]))
+ die("%s is mounted read-write - aborting", argv[i]);
+
struct bch_fs *c = bch2_fs_open(argv, argc, opts);
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))
+ if (test_bit(BCH_FS_ERRORS_FIXED, &c->flags))
ret = 2;
- if (test_bit(BCH_FS_FSCK_UNFIXED_ERRORS, &c->flags))
+ if (test_bit(BCH_FS_ERROR, &c->flags))
ret = 4;
bch2_fs_stop(c);