From caf1b443c073629cc2d70cca8251849cedcffd65 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 19 Jun 2018 12:22:59 +0200 Subject: [PATCH] lsblk: follow --sysroot when read mountpoints Signed-off-by: Karel Zak --- misc-utils/lsblk.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 26b58ab4e7..d797f6295e 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -472,7 +472,14 @@ static int is_active_swap(const char *filename) mnt_table_set_parser_errcb(swaps, table_parser_errcb); mnt_table_set_cache(swaps, mntcache); - mnt_table_parse_swaps(swaps, NULL); + + if (!lsblk->sysroot) + mnt_table_parse_swaps(swaps, NULL); + else { + char buf[PATH_MAX]; + snprintf(buf, sizeof(buf), "%s" _PATH_PROC_SWAPS, lsblk->sysroot); + mnt_table_parse_swaps(swaps, buf); + } } return mnt_table_find_srcpath(swaps, filename, MNT_ITER_BACKWARD) != NULL; @@ -495,7 +502,14 @@ static char *get_device_mountpoint(struct blkdev_cxt *cxt) mnt_table_set_parser_errcb(mtab, table_parser_errcb); mnt_table_set_cache(mtab, mntcache); - mnt_table_parse_mtab(mtab, NULL); + + if (!lsblk->sysroot) + mnt_table_parse_mtab(mtab, NULL); + else { + char buf[PATH_MAX]; + snprintf(buf, sizeof(buf), "%s" _PATH_PROC_MOUNTINFO, lsblk->sysroot); + mnt_table_parse_mtab(mtab, buf); + } } /* Note that maj:min in /proc/self/mountinfo does not have to match with -- 2.47.3