diff options
author | Karel Zak | 2013-07-01 15:59:16 +0200 |
---|---|---|
committer | Karel Zak | 2013-07-01 15:59:16 +0200 |
commit | 4ba4893b3634ff1f6bca688641283cee38989654 (patch) | |
tree | 0198d0d2608f52a10f20fb303438d5bda3cb108d /misc-utils | |
parent | dmesg: make time stamps to be printed consistently (diff) | |
download | kernel-qcow2-util-linux-4ba4893b3634ff1f6bca688641283cee38989654.tar.gz kernel-qcow2-util-linux-4ba4893b3634ff1f6bca688641283cee38989654.tar.xz kernel-qcow2-util-linux-4ba4893b3634ff1f6bca688641283cee38989654.zip |
findmnt: make udev usage more robust
$ findmnt -rn --target /home/kzak/.bashrc -o UUID
uses libudev to ask for UUID, unfortunately /home/kzak is DM device
and libudev expects sysfs-like names (e.g. dm-0). We have to convert
the name to kernel devname.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils')
-rw-r--r-- | misc-utils/findmnt.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index b6dbbf5d3..85d8b6392 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -368,17 +368,24 @@ static char *get_tag_from_udev(const char *devname, int col) { struct udev_device *dev; const char *data = NULL; - char *res = NULL; + char *res = NULL, *path; if (!udev) udev = udev_new(); if (!udev) return NULL; + /* libudev don't like /dev/mapper/ symlinks */ + path = realpath(devname, NULL); + if (path) + devname = path; + if (strncmp(devname, "/dev/", 5) == 0) devname += 5; dev = udev_device_new_from_subsystem_sysname(udev, "block", devname); + free(path); + if (!dev) return NULL; |