X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fdevice-handler.c;h=11fb115293fcd44076ac30cee7e695a4d7dc7e49;hp=a06dafc03c6f92808f6c0c35a28b9dfaed470e04;hb=bad9baa8794ed0c31b7f93b110815d98db7b2d7a;hpb=7b793150f96a6fe6033ac1390a663b1b62be2df6 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);