summaryrefslogtreecommitdiffstats
path: root/discover
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-09-18 11:44:41 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-09-18 11:44:41 +0800
commitbad9baa8794ed0c31b7f93b110815d98db7b2d7a (patch)
tree97bf348fcbfc56634873ce4613948a2369c9067e /discover
parent7b793150f96a6fe6033ac1390a663b1b62be2df6 (diff)
downloadtalos-petitboot-bad9baa8794ed0c31b7f93b110815d98db7b2d7a.tar.gz
talos-petitboot-bad9baa8794ed0c31b7f93b110815d98db7b2d7a.zip
discover: populate udev device types
Now that we have device types, populate from the udev info. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover')
-rw-r--r--discover/device-handler.c22
-rw-r--r--discover/udev.c1
2 files changed, 23 insertions, 0 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index a06dafc..11fb115 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -304,6 +304,27 @@ static struct discover_device *find_device(struct device_handler *handler,
return NULL;
}
+static enum device_type event_device_type(struct device *device,
+ struct event *event)
+{
+ const char *param;
+
+ param = event_get_param(event, "type");
+ if (!param) {
+ pb_log("%s: empty type\n", device->id);
+ return DEVICE_TYPE_UNKNOWN;
+ }
+
+ if (!strcmp(param, "disk") || !strcmp(param, "partition"))
+ return DEVICE_TYPE_DISK;
+
+ if (!strcmp(param, "net"))
+ return DEVICE_TYPE_NETWORK;
+
+ pb_log("%s: unknown type '%s'\n", device->id, param);
+ return DEVICE_TYPE_UNKNOWN;
+}
+
static struct discover_device *discover_device_create(
struct device_handler *handler,
struct discover_context *ctx,
@@ -325,6 +346,7 @@ static struct discover_device *discover_device_create(
dev->device_path = talloc_strdup(dev, devname);
dev->device->id = talloc_strdup(dev, event->device);
+ dev->device->type = event_device_type(dev->device, event);
talloc_set_destructor(dev, destroy_device);
diff --git a/discover/udev.c b/discover/udev.c
index 309a749..d13ced7 100644
--- a/discover/udev.c
+++ b/discover/udev.c
@@ -126,6 +126,7 @@ static int udev_handle_dev_action(struct udev_device *dev, const char *action)
event->n_params = 0;
event->params = NULL;
event_set_param(event, "DEVNAME", devnode);
+ event_set_param(event, "type", devtype);
udev_setup_event_params(dev, event);
OpenPOWER on IntegriCloud