- if (boot_option_resolve(opt, handler)) {
- list_add(&dev->boot_options, &opt->list);
- talloc_steal(dev, opt);
- boot_option_finalise(opt);
- discover_server_notify_boot_option_add(handler->server,
- opt->option);
- } else {
- if (!opt->source->resolve_resource) {
- pb_log("parser %s gave us an unresolved "
- "resource (%s), but no way to "
- "resolve it\n",
- opt->source->name, opt->option->id);
- talloc_free(opt);
- } else {
- pb_log("boot option %s is unresolved, "
- "adding to queue\n",
- opt->option->id);
- list_add(&handler->unresolved_boot_options,
- &opt->list);
- talloc_steal(handler, opt);
- }
+ umount_device(dev);
+
+ return 0;
+}
+
+struct discover_device *discover_device_create(struct device_handler *handler,
+ const char *id)
+{
+ struct discover_device *dev;
+
+ dev = device_lookup_by_id(handler, id);
+ if (dev)
+ return dev;
+
+ dev = talloc_zero(handler, struct discover_device);
+ dev->device = talloc_zero(dev, struct device);
+ dev->device->id = talloc_strdup(dev->device, id);
+ list_init(&dev->params);
+ list_init(&dev->boot_options);
+
+ talloc_set_destructor(dev, destroy_device);
+
+ return dev;
+}
+
+struct discover_device_param {
+ char *name;
+ char *value;
+ struct list_item list;
+};
+
+void discover_device_set_param(struct discover_device *device,
+ const char *name, const char *value)
+{
+ struct discover_device_param *param;
+ bool found = false;
+
+ list_for_each_entry(&device->params, param, list) {
+ if (!strcmp(param->name, name)) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ if (!value)
+ return;
+ param = talloc(device, struct discover_device_param);
+ param->name = talloc_strdup(param, name);
+ list_add(&device->params, ¶m->list);
+ } else {
+ if (!value) {
+ list_remove(¶m->list);
+ talloc_free(param);
+ return;