]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: use devno to get mountpoint
authorKarel Zak <kzak@redhat.com>
Mon, 8 Jul 2013 12:21:03 +0000 (14:21 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 30 Jul 2013 09:08:51 +0000 (11:08 +0200)
The device (for example LVM logical volume) could be renamed and then
the device name from /proc/self/mountinfo does not match with reality.
So, we also need to check devno. Unfortunately we cannot completely
rely on devno, because for example btrfs uses psudo device numbers.

References: https://bugzilla.redhat.com/show_bug.cgi?id=980463
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsblk.c

index a62042bef7e64a08c6a7e340844f5b167b49a6f7..866b31fe94e4a864e1bd59a664944fb091b8df79 100644 (file)
@@ -372,8 +372,12 @@ static char *get_device_mountpoint(struct blkdev_cxt *cxt)
                mnt_table_parse_mtab(mtab, NULL);
        }
 
-       /* try /etc/mtab or /proc/self/mountinfo */
-       fs = mnt_table_find_srcpath(mtab, cxt->filename, MNT_ITER_BACKWARD);
+       /* Note that maj:min in /proc/self/mouninfo does not have to match with
+        * devno as returned by stat(), so we have to try devname too
+        */
+       fs = mnt_table_find_devno(mtab, makedev(cxt->maj, cxt->min), MNT_ITER_BACKWARD);
+       if (!fs)
+               fs = mnt_table_find_srcpath(mtab, cxt->filename, MNT_ITER_BACKWARD);
        if (!fs)
                return is_active_swap(cxt->filename) ? xstrdup("[SWAP]") : NULL;