]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - misc-utils/lsblk-mnt.c
lsblk: differentiate between swap and mount
[thirdparty/util-linux.git] / misc-utils / lsblk-mnt.c
index 6bc634043fa3bfd0e991a3c2652ee55f2d6e3945..890675ed5d1659ef2854ee328dd85da481a2f887 100644 (file)
@@ -50,7 +50,7 @@ char *lsblk_device_get_mountpoint(struct blkdev_cxt *cxt)
        assert(cxt);
        assert(cxt->filename);
 
-       if (cxt->is_mounted)
+       if (cxt->is_mounted || cxt->is_swap)
                return cxt->mountpoint;
 
        if (!mtab) {
@@ -79,8 +79,12 @@ char *lsblk_device_get_mountpoint(struct blkdev_cxt *cxt)
        if (!fs)
                fs = mnt_table_find_srcpath(mtab, cxt->filename, MNT_ITER_BACKWARD);
        if (!fs) {
-               cxt->mountpoint = is_active_swap(cxt->filename) ? xstrdup("[SWAP]") : NULL;
-               cxt->is_mounted = 1;
+               if (is_active_swap(cxt->filename)) {
+                       cxt->mountpoint = xstrdup("[SWAP]");
+                       cxt->is_swap = 1;
+               } else
+                       cxt->mountpoint = NULL;
+
                return cxt->mountpoint;
        }