discover: Check for devices with duplicate serial properties
[petitboot] / discover / udev.c
index 1c5cf71ff4fee7caf0949211ba4c0f7ee48afd37..e996e221228804d6a16a7a41aeb25463198800a8 100644 (file)
@@ -70,6 +70,7 @@ static int udev_handle_dev_add(struct pb_udev *udev, struct udev_device *dev)
 {
        struct discover_device *ddev;
        const char *typestr;
+       const char *serial;
        const char *path;
        const char *name;
 
@@ -104,6 +105,12 @@ static int udev_handle_dev_add(struct pb_udev *udev, struct udev_device *dev)
                return -1;
        }
 
+       /* we may also see multipath devices; same dev nodes (hence id), but
+        * different serial numbers */
+       serial = udev_device_get_property_value(dev, "ID_SERIAL");
+       if (serial && device_lookup_by_serial(udev->handler, serial))
+               return -1;
+
        ddev = discover_device_create(udev->handler, name);
 
        ddev->device_path = udev_device_get_devnode(dev);