mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-03 03:11:46 +00:00
btrfs-progs: Fix the return value of btrfs_scan_kernel()
btrfs_scan_kernel() is only used in 'btrfs fi show' but returns wrong return value. When search parameter is passed, it will never return 0 even the search can be matched. This patch will change the whatever strange logic to a more easy to understand one using 'found' var. Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Cc: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
30156b749b
commit
ccd14cbf62
@ -444,6 +444,7 @@ static int check_arg_type(char *input)
|
||||
static int btrfs_scan_kernel(void *search)
|
||||
{
|
||||
int ret = 0, fd;
|
||||
int found = 0;
|
||||
FILE *f;
|
||||
struct mntent *mnt;
|
||||
struct btrfs_ioctl_fs_info_args fs_info_arg;
|
||||
@ -466,7 +467,6 @@ static int btrfs_scan_kernel(void *search)
|
||||
|
||||
if (get_label_mounted(mnt->mnt_dir, label)) {
|
||||
kfree(dev_info_arg);
|
||||
ret = 1;
|
||||
goto out;
|
||||
}
|
||||
if (search && !match_search_item_kernel(fs_info_arg.fsid,
|
||||
@ -481,19 +481,16 @@ static int btrfs_scan_kernel(void *search)
|
||||
space_info_arg, label, mnt->mnt_dir);
|
||||
kfree(space_info_arg);
|
||||
memset(label, 0, sizeof(label));
|
||||
found = 1;
|
||||
}
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
kfree(dev_info_arg);
|
||||
if (search)
|
||||
ret = 0;
|
||||
}
|
||||
if (search)
|
||||
ret = 1;
|
||||
|
||||
out:
|
||||
endmntent(f);
|
||||
return ret;
|
||||
return !found;
|
||||
}
|
||||
|
||||
static int dev_to_fsid(char *dev, __u8 *fsid)
|
||||
|
Loading…
Reference in New Issue
Block a user