-static int destroy_device(void *arg)
-{
- struct discover_device *dev = arg;
-
- umount_device(dev);
-
- return 0;
-}
-
-static struct discover_device *find_device(struct device_handler *handler,
- const char *id)
-{
- struct discover_device *dev;
- unsigned int i;
-
- for (i = 0; i < handler->n_devices; i++) {
- dev = handler->devices[i];
- if (!strcmp(dev->device->id, id))
- return dev;
- }
-
- 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,
- struct event *event)
-{
- struct discover_device *dev;
- const char *devnode;
-
- dev = find_device(handler, event->device);
- if (dev)
- return dev;
-
- dev = talloc_zero(ctx, struct discover_device);
- dev->device = talloc_zero(dev, struct device);
- list_init(&dev->boot_options);
-
- devnode = event_get_param(ctx->event, "node");
- if (devnode)
- dev->device_path = talloc_strdup(dev, devnode);
-
- dev->device->id = talloc_strdup(dev, event->device);
- dev->device->type = event_device_type(dev->device, event);
-
- talloc_set_destructor(dev, destroy_device);
-
- return dev;
-}
-
-/**
- * device_handler_remove - Remove a device from the handler device array.
- */
-
-static void device_handler_remove(struct device_handler *handler,
- struct discover_device *device)