diff options
author | Eric Sandeen <sandeen@redhat.com> | 2013-02-25 16:54:40 -0600 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2013-02-27 14:39:37 +0100 |
commit | 5eaeb577b563620f41735e0064d55ae41e969e78 (patch) | |
tree | dea0f7bb13028d1b4bc659f9e7b190abc1c8c266 | |
parent | 67c631329a0207476f9342843601b1ad633687f7 (diff) |
btrfs-progs: fix close of error fd in scrub cancel
If we retry opening the mountpoint and fail, we'll call
close on a filehandle w/ value -1. Rearrange so the
retry uses the same open and same error handling.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
-rw-r--r-- | cmds-scrub.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/cmds-scrub.c b/cmds-scrub.c index b984e969..353d9cb1 100644 --- a/cmds-scrub.c +++ b/cmds-scrub.c @@ -1448,13 +1448,13 @@ static int cmd_scrub_cancel(int argc, char **argv) path = argv[1]; +again: fdmnt = open_file_or_dir(path); if (fdmnt < 0) { fprintf(stderr, "ERROR: scrub cancel failed\n"); - return 12; + return 1; } -again: ret = ioctl(fdmnt, BTRFS_IOC_SCRUB_CANCEL, NULL); err = errno; @@ -1463,13 +1463,10 @@ again: ret = check_mounted_where(fdmnt, path, mp, sizeof(mp), &fs_devices_mnt); if (ret) { - /* It is a device; open the mountpoint. */ + /* It is a device; try again with the mountpoint. */ close(fdmnt); - fdmnt = open_file_or_dir(mp); - if (fdmnt >= 0) { - path = mp; - goto again; - } + path = mp; + goto again; } } |