mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-11 03:31:17 +00:00
btrfs-progs: apply realpath for btrfs fi show when mount point is given
For now, # btrfs fi show /mnt/btrfs gives info correctly, while # btrfs fi show /mnt/btrfs/ gives nothing. This implies that the @realpath() function should be applied to unify the behavior. Made a more clear comment right above the call as well. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
05afee3468
commit
8be2fff129
@ -901,39 +901,45 @@ static int cmd_show(int argc, char **argv)
|
|||||||
if (strlen(search) == 0)
|
if (strlen(search) == 0)
|
||||||
usage(cmd_show_usage);
|
usage(cmd_show_usage);
|
||||||
type = check_arg_type(search);
|
type = check_arg_type(search);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* needs spl handling if input arg is block dev
|
* For search is a device:
|
||||||
* And if input arg is mount-point just print it
|
* realpath do /dev/mapper/XX => /dev/dm-X
|
||||||
* right away
|
* which is required by BTRFS_SCAN_DEV
|
||||||
|
* For search is a mountpoint:
|
||||||
|
* realpath do /mnt/btrfs/ => /mnt/btrfs
|
||||||
|
* which shall be recognized by btrfs_scan_kernel()
|
||||||
*/
|
*/
|
||||||
if (type == BTRFS_ARG_BLKDEV) {
|
if (!realpath(search, path)) {
|
||||||
if (where == BTRFS_SCAN_LBLKID) {
|
fprintf(stderr, "ERROR: Could not show %s: %s\n",
|
||||||
/* we need to do this because
|
search, strerror(errno));
|
||||||
* legacy BTRFS_SCAN_DEV
|
return 1;
|
||||||
* provides /dev/dm-x paths
|
}
|
||||||
*/
|
|
||||||
if (realpath(search, path))
|
search = path;
|
||||||
search = path;
|
|
||||||
|
/*
|
||||||
|
* Needs special handling if input arg is block dev And if
|
||||||
|
* input arg is mount-point just print it right away
|
||||||
|
*/
|
||||||
|
if (type == BTRFS_ARG_BLKDEV && where != BTRFS_SCAN_LBLKID) {
|
||||||
|
ret = get_btrfs_mount(search, mp, sizeof(mp));
|
||||||
|
if (!ret) {
|
||||||
|
/* given block dev is mounted */
|
||||||
|
search = mp;
|
||||||
|
type = BTRFS_ARG_MNTPOINT;
|
||||||
} else {
|
} else {
|
||||||
ret = get_btrfs_mount(search,
|
ret = dev_to_fsid(search, fsid);
|
||||||
mp, sizeof(mp));
|
if (ret) {
|
||||||
if (!ret) {
|
fprintf(stderr,
|
||||||
/* given block dev is mounted*/
|
"ERROR: No btrfs on %s\n",
|
||||||
search = mp;
|
search);
|
||||||
type = BTRFS_ARG_MNTPOINT;
|
return 1;
|
||||||
} else {
|
|
||||||
ret = dev_to_fsid(search, fsid);
|
|
||||||
if (ret) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"ERROR: No btrfs on %s\n",
|
|
||||||
search);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
uuid_unparse(fsid, uuid_buf);
|
|
||||||
search = uuid_buf;
|
|
||||||
type = BTRFS_ARG_UUID;
|
|
||||||
goto devs_only;
|
|
||||||
}
|
}
|
||||||
|
uuid_unparse(fsid, uuid_buf);
|
||||||
|
search = uuid_buf;
|
||||||
|
type = BTRFS_ARG_UUID;
|
||||||
|
goto devs_only;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user