diff options
author | Karel Zak | 2018-06-19 12:02:52 +0200 |
---|---|---|
committer | Karel Zak | 2018-06-21 13:19:28 +0200 |
commit | 5a89aa99a7f13722102fa8730f4647da9138134d (patch) | |
tree | 07587e5e96643cb9f1f6bb37a655230c07da1e36 /misc-utils/lsblk.c | |
parent | lsblk: add --sysroot (diff) | |
download | kernel-qcow2-util-linux-5a89aa99a7f13722102fa8730f4647da9138134d.tar.gz kernel-qcow2-util-linux-5a89aa99a7f13722102fa8730f4647da9138134d.tar.xz kernel-qcow2-util-linux-5a89aa99a7f13722102fa8730f4647da9138134d.zip |
lsblk: use prefix for DM name
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/lsblk.c')
-rw-r--r-- | misc-utils/lsblk.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 2d0c98127..26b58ab4e 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -446,7 +446,7 @@ static char *get_device_path(struct blkdev_cxt *cxt) assert(cxt->name); if (is_dm(cxt->name)) - return canonicalize_dm_name(cxt->name); + return __canonicalize_dm_name(lsblk->sysroot, cxt->name); snprintf(path, sizeof(path), "/dev/%s", cxt->name); sysfs_devname_sys_to_dev(path); @@ -1473,9 +1473,17 @@ static int iterate_block_devices(void) DIR *dir; struct dirent *d; struct blkdev_cxt cxt = { NULL }; + struct path_cxt *pc = ul_new_path(_PATH_SYS_BLOCK); - if (!(dir = opendir(_PATH_SYS_BLOCK))) - return -errno; + if (!pc) + err(EXIT_FAILURE, _("failed to allocate /sys handler")); + + ul_path_set_prefix(pc, lsblk->sysroot); + + /* TODO: reuse @pc in set_cxt(), etc. */ + dir = ul_path_opendir(pc, NULL); + if (!dir) + goto done; DBG(DEV, ul_debug("iterate on " _PATH_SYS_BLOCK)); @@ -1499,7 +1507,8 @@ static int iterate_block_devices(void) } closedir(dir); - +done: + ul_unref_path(pc); DBG(DEV, ul_debug("iterate on " _PATH_SYS_BLOCK " -- done")); return 0; } @@ -1929,6 +1938,7 @@ int main(int argc, char *argv[]) mnt_init_debug(0); scols_init_debug(0); + ul_path_init_debug(); /* * initialize output columns |