mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-09 22:26:55 +00:00
btrfs-progs: Fix wrong return value when executing 'fi show' on umounted device.
When executing 'btrfs fi show' on unmounted device, even no problem happens, the return value is still 1 not 0. The problem lies in search_umounted_fs_uuids(), where when it finds the given uuid, it should return 1, but later uuid copy overwrites the return value, causing it always return 0 under that case. Fix it by pass found as pointer, and return value only indicates whether anything wrong happens, whether found or not is stored in the new parameter. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
54498f9a14
commit
e015a83e6d
@ -700,7 +700,7 @@ static int has_seed_devices(struct btrfs_fs_devices *fs_devices)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int search_umounted_fs_uuids(struct list_head *all_uuids,
|
static int search_umounted_fs_uuids(struct list_head *all_uuids,
|
||||||
char *search)
|
char *search, int *found)
|
||||||
{
|
{
|
||||||
struct btrfs_fs_devices *cur_fs, *fs_copy;
|
struct btrfs_fs_devices *cur_fs, *fs_copy;
|
||||||
struct list_head *fs_uuids;
|
struct list_head *fs_uuids;
|
||||||
@ -717,7 +717,8 @@ static int search_umounted_fs_uuids(struct list_head *all_uuids,
|
|||||||
if (search) {
|
if (search) {
|
||||||
if (uuid_search(cur_fs, search) == 0)
|
if (uuid_search(cur_fs, search) == 0)
|
||||||
continue;
|
continue;
|
||||||
ret = 1;
|
if (found)
|
||||||
|
*found = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip all fs already shown as mounted fs */
|
/* skip all fs already shown as mounted fs */
|
||||||
@ -922,8 +923,8 @@ devs_only:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
found = search_umounted_fs_uuids(&all_uuids, search);
|
ret = search_umounted_fs_uuids(&all_uuids, search, &found);
|
||||||
if (found < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"ERROR: %d while searching target device\n", ret);
|
"ERROR: %d while searching target device\n", ret);
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user