]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: follow --sysroot when read mountpoints
authorKarel Zak <kzak@redhat.com>
Tue, 19 Jun 2018 10:22:59 +0000 (12:22 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 21 Jun 2018 11:19:28 +0000 (13:19 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsblk.c

index 26b58ab4e727adb1f5e70e46bf64286dfedfcfbb..d797f6295e952aac25cd17d75e7894a1829f47d1 100644 (file)
@@ -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