mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-23 22:53:35 +00:00
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>
This commit is contained in:
parent
64fddab8ac
commit
51a40f6df0
@ -2729,7 +2729,12 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
file = argv[optind];
|
file = argv[optind];
|
||||||
if (check_mounted(file)) {
|
ret = check_mounted(file);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Could not check mount status: %s\n",
|
||||||
|
strerror(-ret));
|
||||||
|
return 1;
|
||||||
|
} else if (ret) {
|
||||||
fprintf(stderr, "%s is mounted\n", file);
|
fprintf(stderr, "%s is mounted\n", file);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,12 @@ int main(int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_mounted(device)) {
|
ret = check_mounted(device);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Could not check mount status: %s\n",
|
||||||
|
strerror(-ret));
|
||||||
|
return 1;
|
||||||
|
} else if (ret) {
|
||||||
fprintf(stderr, "%s is mounted\n", device);
|
fprintf(stderr, "%s is mounted\n", device);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -80,9 +80,13 @@ int cmd_chunk_recover(int argc, char *argv[])
|
|||||||
file = argv[optind];
|
file = argv[optind];
|
||||||
|
|
||||||
ret = check_mounted(file);
|
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");
|
fprintf(stderr, "the device is busy\n");
|
||||||
return ret;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = btrfs_recover_chunk_tree(file, verbose, yes);
|
ret = btrfs_recover_chunk_tree(file, verbose, yes);
|
||||||
@ -133,7 +137,11 @@ int cmd_super_recover(int argc, char **argv)
|
|||||||
|
|
||||||
dname = argv[optind];
|
dname = argv[optind];
|
||||||
ret = check_mounted(dname);
|
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");
|
fprintf(stderr, "the device is busy\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user