diff options
author | Karel Zak | 2013-07-08 14:21:03 +0200 |
---|---|---|
committer | Karel Zak | 2013-07-08 14:21:03 +0200 |
commit | da531dd8d5d3aa284b7f73ce6345e54ce3b3bc1d (patch) | |
tree | 2f1aad95da577e93d8ed6e0e803fe54e4a10cfbe /misc-utils | |
parent | findmnt: avoid unused parameter warning (diff) | |
download | kernel-qcow2-util-linux-da531dd8d5d3aa284b7f73ce6345e54ce3b3bc1d.tar.gz kernel-qcow2-util-linux-da531dd8d5d3aa284b7f73ce6345e54ce3b3bc1d.tar.xz kernel-qcow2-util-linux-da531dd8d5d3aa284b7f73ce6345e54ce3b3bc1d.zip |
lsblk: use devno to get mountpoint
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>
Diffstat (limited to 'misc-utils')
-rw-r--r-- | misc-utils/lsblk.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 494bc73a8..4f4350587 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -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; |