diff options
-rw-r--r-- | cmds-scrub.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/cmds-scrub.c b/cmds-scrub.c index 31ace6d4..b984e969 100644 --- a/cmds-scrub.c +++ b/cmds-scrub.c @@ -1457,14 +1457,14 @@ static int cmd_scrub_cancel(int argc, char **argv) again: ret = ioctl(fdmnt, BTRFS_IOC_SCRUB_CANCEL, NULL); err = errno; - close(fdmnt); if (ret && err == EINVAL) { - /* path is no mounted btrfs. try if it's a device */ + /* path is not a btrfs mount point. See if it's a device. */ ret = check_mounted_where(fdmnt, path, mp, sizeof(mp), &fs_devices_mnt); - close(fdmnt); if (ret) { + /* It is a device; open the mountpoint. */ + close(fdmnt); fdmnt = open_file_or_dir(mp); if (fdmnt >= 0) { path = mp; @@ -1473,6 +1473,8 @@ again: } } + close(fdmnt); + if (ret) { fprintf(stderr, "ERROR: scrub cancel failed on %s: %s\n", path, err == ENOTCONN ? "not running" : strerror(errno)); |