]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: differentiate between swap and mount
authorKarel Zak <kzak@redhat.com>
Fri, 14 Sep 2018 13:57:45 +0000 (15:57 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 14 Sep 2018 13:57:45 +0000 (15:57 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsblk-mnt.c
misc-utils/lsblk.c
misc-utils/lsblk.h

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;
        }
 
index d466a25b181dafa3ee8aec33deab9cd8b0ba30ec..2a6044c0e5b94131eaf2179623fe23b81abd4133 100644 (file)
@@ -786,7 +786,7 @@ static char *get_vfs_attribute(struct blkdev_cxt *cxt, int id)
 
        if (!cxt->fsstat.f_blocks) {
                mnt = lsblk_device_get_mountpoint(cxt);
-               if (!mnt)
+               if (!mnt || cxt->is_swap)
                        return NULL;
                if (statvfs(mnt, &cxt->fsstat) != 0)
                        return NULL;
index 8817314afd9da1378f90b0a2258809c3ed1b868e..13e8e754d1c2e926dbc876c664e5cee15554a8f1 100644 (file)
@@ -89,7 +89,8 @@ struct blkdev_cxt {
 
        uint64_t size;          /* device size */
 
-       unsigned int    is_mounted : 1;
+       unsigned int    is_mounted : 1,
+                       is_swap : 1;
 };
 
 /* lsblk-mnt.c */