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>
}
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);
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);
return 1;
}
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);
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;
}