X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fudev.c;h=3127ec25edc68dbc1cf484b973f76905c3ae0ebc;hp=80029d6820d225f001940d696ec3c67c63ced878;hb=e1b713b0c862a93cd3e8cea59070f469510d3c39;hpb=9de5d31f93dab36cfb451e9ad724d47311b54424 diff --git a/discover/udev.c b/discover/udev.c index 80029d6..3127ec2 100644 --- a/discover/udev.c +++ b/discover/udev.c @@ -1,5 +1,7 @@ -#define _GNU_SOURCE +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif #include #include @@ -62,7 +64,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 *uuid; const char *path; const char *name; const char *node; @@ -112,23 +114,28 @@ 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; + /* We may see multipath devices; they'll have the same uuid as an + * existing device, so only parse the first. */ + uuid = udev_device_get_property_value(dev, "ID_FS_UUID"); + if (uuid) { + ddev = device_lookup_by_uuid(udev->handler, uuid); + if (ddev) { + pb_log("SKIP: %s UUID [%s] already present (as %s)\n", + name, uuid, ddev->device->id); + return -1; + } + } ddev = discover_device_create(udev->handler, name); ddev->device_path = talloc_strdup(ddev, node); - prop = udev_device_get_property_value(dev, "ID_FS_UUID"); - if (prop) - ddev->uuid = talloc_strdup(ddev, prop); + if (uuid) + ddev->uuid = talloc_strdup(ddev, uuid); prop = udev_device_get_property_value(dev, "ID_FS_LABEL"); if (prop) ddev->label = talloc_strdup(ddev, prop); - ddev->device->type = DEVICE_TYPE_DISK; + ddev->device->type = cdrom ? DEVICE_TYPE_OPTICAL : DEVICE_TYPE_DISK; udev_setup_device_params(dev, ddev);