diff options
author | Gui Hecheng <guihc.fnst@cn.fujitsu.com> | 2014-02-20 10:49:03 +0800 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-03-21 06:23:21 -0700 |
commit | 51a40f6df01ea7e0673bd1b50a0d28e1def345f2 (patch) | |
tree | 3bdc02616593f84e784eeae2b795736ab13da7f6 /cmds-rescue.c | |
parent | 64fddab8ac0ad7970cf713cfecba5ab6ae90b09c (diff) | |
download | btrfs-progs-51a40f6df01ea7e0673bd1b50a0d28e1def345f2.tar.gz |
btrfs-progs: judge the return value of check_mounted more accurately
For btrfs-convert, btrfstune, btrfs rescue, they report "device busy"
when given a device that does not actually exist e.g.
# btrfstune -x abcdefg (this device does not exist)
$ ...device busy...
We deal with this case by add "ret < 0" error check when
judging the return value of check_mounted.
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'cmds-rescue.c')
-rw-r--r-- | cmds-rescue.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/cmds-rescue.c b/cmds-rescue.c index e18eb98..f20a206 100644 --- a/cmds-rescue.c +++ b/cmds-rescue.c @@ -80,9 +80,13 @@ int cmd_chunk_recover(int argc, char *argv[]) file = argv[optind]; ret = check_mounted(file); - if (ret) { + if (ret < 0) { + fprintf(stderr, "Could not check mount status: %s\n", + strerror(-ret)); + return 1; + } else if (ret) { fprintf(stderr, "the device is busy\n"); - return ret; + return 1; } ret = btrfs_recover_chunk_tree(file, verbose, yes); @@ -133,7 +137,11 @@ int cmd_super_recover(int argc, char **argv) dname = argv[optind]; ret = check_mounted(dname); - if (ret) { + if (ret < 0) { + fprintf(stderr, "Could not check mount status: %s\n", + strerror(-ret)); + return 1; + } else if (ret) { fprintf(stderr, "the device is busy\n"); return 1; } |