4 #include "libbcachefs.h"
5 #include "libbcachefs/super-io.h"
7 static void reset_counters_usage(void)
9 puts("bcachefs reset-counters \n"
10 "Usage: bcachefs reset-counters device\n"
13 " -h, --help display this help and exit\n"
14 "Report bugs to <linux-bcachefs@vger.kernel.org>");
18 int cmd_reset_counters(int argc, char *argv[])
20 static const struct option longopts[] = {
21 { "help", 0, NULL, 'h' },
26 while ((opt = getopt_long(argc, argv, "h", longopts, NULL)) != -1)
29 reset_counters_usage();
34 char *dev = arg_pop();
36 die("please supply a device");
38 die("too many arguments");
40 struct bch_opts opts = bch2_opts_empty();
41 struct bch_sb_handle sb;
42 int ret = bch2_read_super(dev, &opts, &sb);
44 die("Error opening %s: %s", dev, bch2_err_str(ret));
46 bch2_sb_field_resize(&sb, counters, 0);
48 bch2_super_write(sb.bdev->bd_buffered_fd, sb.sb);