5 #include "tools-util.h"
7 static void usage(void)
9 puts("bcache fsck - filesystem check and repair\n"
10 "Usage: bcache fsck [OPTION]... <devices>\n"
13 " -p Automatic repair (no questions\n"
14 " -n Don't repair, only check for errors\n"
15 " -y Assume \"yes\" to all questions\n"
16 " -f Force checking even if filesystem is marked clean\n"
18 " --h Display this help and exit\n"
19 "Report bugs to <linux-bcache@vger.kernel.org>");
22 int cmd_fsck(int argc, char *argv[])
24 DECLARE_COMPLETION_ONSTACK(shutdown);
25 struct cache_set_opts opts = cache_set_opts_empty();
26 struct cache_set *c = NULL;
30 while ((opt = getopt(argc, argv, "pynfvh")) != -1)
33 fsck_err_opt = FSCK_ERR_YES;
36 fsck_err_opt = FSCK_ERR_YES;
39 opts.nochanges = true;
40 fsck_err_opt = FSCK_ERR_NO;
43 /* force check, even if filesystem marked clean: */
46 opts.verbose_recovery = true;
54 die("Please supply device(s) to check");
56 err = bch_register_cache_set(argv + optind, argc - optind, opts, &c);
58 die("error opening %s: %s", argv[optind], err);
60 c->stop_completion = &shutdown;
61 bch_cache_set_stop(c);
65 wait_for_completion(&shutdown);