+ /* Use DM_NAME for logical volumes, or the device name otherwise */
+ ddev = discover_device_create(udev->handler, uuid, devname ?: name);
+
+ if (devname) {
+ /*
+ * For logical volumes udev_device_get_devnode() returns a path
+ * of the form "/dev/dm-xx". These nodes names are not
+ * persistent and are opaque to the user. Instead use the more
+ * recognisable "/dev/mapper/lv-name" node if it is available.
+ */
+ devlinks = talloc_strdup(ddev,
+ udev_device_get_property_value(dev, "DEVLINKS"));
+ link = devlinks ? strtok_r(devlinks, " ", &saveptr) : NULL;
+ while (link) {
+ if (strncmp(link, "/dev/mapper/",
+ strlen("/dev/mapper/")) == 0) {
+ node = link;
+ break;
+ }
+ link = strtok_r(NULL, " ", &saveptr);
+ }
+ }