btrfs-progs: fi show: canonicalize path when using blkid and -d
There's a report that passing raw device mapper path and -d don't work together: yyy@xxx ~ $ sudo btrfs filesystem show /dev/dm-0 Label: none uuid: a7fbb8d6-ec5d-4e88-bd8b-c686553e0dc7 Total devices 1 FS bytes used 144.00KiB devid 1 size 256.00MiB used 88.00MiB path /dev/mapper/da0972636816-LogVol00 With --all-devices yyy@xxx ~ $ sudo btrfs filesystem show --all-devices /dev/dm-0 ERROR: not a valid btrfs filesystem: /dev/dm-0 Where dm-0 corresponds to the LogVol00 device from above. Passing the option -d skips some steps but still uses the real path of the device that is required for scanning and identification, while blkid uses the canonicalized path. The combination of raw device name and -d was not handled as the raw path is not in cache and thus not recognized. Canonicalization fixes that although this changes the device name in the output. Issue: #732 Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
74e57d25dc
commit
cb740b3dfb
|
@ -709,6 +709,7 @@ static int cmd_filesystem_show(const struct cmd_struct *cmd,
|
|||
struct btrfs_fs_devices *fs_devices;
|
||||
struct btrfs_root *root = NULL;
|
||||
char *search = NULL;
|
||||
char *canon_path = NULL;
|
||||
int ret;
|
||||
/* default, search both kernel and udev */
|
||||
int where = -1;
|
||||
|
@ -790,8 +791,15 @@ static int cmd_filesystem_show(const struct cmd_struct *cmd,
|
|||
}
|
||||
}
|
||||
|
||||
if (where == BTRFS_SCAN_LBLKID)
|
||||
if (where == BTRFS_SCAN_LBLKID) {
|
||||
/*
|
||||
* Blkid needs canonicalized paths, eg. when the /dev/dm-0 is
|
||||
* passed on command line.
|
||||
*/
|
||||
canon_path = path_canonicalize(search);
|
||||
search = canon_path;
|
||||
goto devs_only;
|
||||
}
|
||||
|
||||
/* show mounted btrfs */
|
||||
ret = btrfs_scan_kernel(search, unit_mode);
|
||||
|
@ -850,6 +858,7 @@ devs_only:
|
|||
free_fs_devices(fs_devices);
|
||||
}
|
||||
out:
|
||||
free(canon_path);
|
||||
if (root)
|
||||
close_ctree(root);
|
||||
free_seen_fsid(seen_fsid_hash);
|
||||
|
|
Loading…
Reference in New Issue