diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2025-06-25 13:20:59 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-06-25 13:20:59 -0400 |
commit | 84f7b2fdc3ba8e1a7bb7f33da8c67d1dda36f86a (patch) | |
tree | ac63111e62cd51f1341547b8319e157291a53515 /c_src | |
parent | 45f6fe0a144a82542a37f34e826e16dedfdaca5d (diff) |
cmd_fsck: Online fsck can now specify a mountpoint
If the specified path is a directory, we'll try to run online fsck on
the filesystem mounted at that path.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'c_src')
-rw-r--r-- | c_src/cmd_fsck.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/c_src/cmd_fsck.c b/c_src/cmd_fsck.c index cf1ecc62..a3fd1d6a 100644 --- a/c_src/cmd_fsck.c +++ b/c_src/cmd_fsck.c @@ -90,11 +90,8 @@ static int splice_fd_to_stdinout(int fd) return close(fd); } -static int fsck_online(const char *dev_path, const char *opt_str) +static int fsck_online(struct bchfs_handle fs, const char *opt_str) { - int dev_idx; - struct bchfs_handle fs = bchu_fs_open_by_dev(dev_path, &dev_idx); - struct bch_ioctl_fsck_online fsck = { .opts = (unsigned long) opt_str }; @@ -265,10 +262,21 @@ int cmd_fsck(int argc, char *argv[]) darray_const_str devs = get_or_split_cmdline_devs(argc, argv); + if (devs.nr == 1 && + S_ISDIR(xstat(devs.data[0]).st_mode)) { + printf("Running fsck online\n"); + + struct bchfs_handle fs = bcache_fs_open(devs.data[0]); + return fsck_online(fs, opts_str.buf); + } + darray_for_each(devs, i) if (dev_mounted(*i)) { printf("Running fsck online\n"); - return fsck_online(*i, opts_str.buf); + + int dev_idx; + struct bchfs_handle fs = bchu_fs_open_by_dev(*i, &dev_idx); + return fsck_online(fs, opts_str.buf); } if (kernel) |