summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-09-24 17:31:50 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-09-24 17:31:50 +0800
commit995e08e3de9aaff81e72227587ffcb4cc78175d0 (patch)
tree3f523456384a0e5431c61eb5373c185614853736
parent25e4608e9e4572b3a835f7c43a8ec9c77125f492 (diff)
downloadtalos-petitboot-995e08e3de9aaff81e72227587ffcb4cc78175d0.tar.gz
talos-petitboot-995e08e3de9aaff81e72227587ffcb4cc78175d0.zip
discover: Check for devices with duplicate serial properties
If we have multipath devices present in the system, we'll end up with duplicate mounts, parse results and boot options. This change adds a check to see if we've encountered a device with this serial number previously. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r--discover/device-handler.c13
-rw-r--r--discover/device-handler.h3
-rw-r--r--discover/udev.c7
3 files changed, 23 insertions, 0 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 95d2039..251c517 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -103,6 +103,12 @@ static int device_match_id(struct discover_device *dev, const char *id)
return !strcmp(dev->device->id, id);
}
+static int device_match_serial(struct discover_device *dev, const char *serial)
+{
+ const char *val = discover_device_get_param(dev, "ID_SERIAL");
+ return val && !strcmp(val, serial);
+}
+
static struct discover_device *device_lookup(
struct device_handler *device_handler,
int (match_fn)(struct discover_device *, const char *),
@@ -154,6 +160,13 @@ struct discover_device *device_lookup_by_id(
return device_lookup(device_handler, device_match_id, id);
}
+struct discover_device *device_lookup_by_serial(
+ struct device_handler *device_handler,
+ const char *serial)
+{
+ return device_lookup(device_handler, device_match_serial, serial);
+}
+
void device_handler_destroy(struct device_handler *handler)
{
talloc_free(handler);
diff --git a/discover/device-handler.h b/discover/device-handler.h
index 1d78a49..854be48 100644
--- a/discover/device-handler.h
+++ b/discover/device-handler.h
@@ -108,6 +108,9 @@ struct discover_device *device_lookup_by_label(struct device_handler *handler,
const char *label);
struct discover_device *device_lookup_by_id(struct device_handler *handler,
const char *id);
+struct discover_device *device_lookup_by_serial(
+ struct device_handler *device_handler,
+ const char *serial);
void discover_device_set_param(struct discover_device *device,
const char *name, const char *value);
diff --git a/discover/udev.c b/discover/udev.c
index 1c5cf71..e996e22 100644
--- a/discover/udev.c
+++ b/discover/udev.c
@@ -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);
OpenPOWER on IntegriCloud