assert(event->device);
- device = talloc_zero(handler, struct device);
+ device = device_handler_find(handler, event->device);
- if (!device)
- goto fail;
+ if (!device) {
+ device = talloc_zero(handler, struct device);
- device->id = talloc_strdup(device, event->device);
- list_init(&device->boot_options);
+ if (!device)
+ goto fail;
- parse_user_event(device, event);
+ device->id = talloc_strdup(device, event->device);
+ list_init(&device->boot_options);
- discover_server_notify_device_add(handler->server, device);
+ /* add device to handler device array */
+ device_handler_add(handler, device);
- list_for_each_entry(&device->boot_options, opt, list)
- discover_server_notify_boot_option_add(handler->server, opt);
+ discover_server_notify_device_add(handler->server, device);
+ }
- /* add device to handler device array */
- device_handler_add(handler, device);
+ opt = parse_user_event(device, event);
+ discover_server_notify_boot_option_add(handler->server, opt);
return 0;
* Understands params: name, image, args.
*/
-int parse_user_event(struct device *device, struct event *event)
+struct boot_option *parse_user_event(struct device *device, struct event *event)
{
struct boot_option *opt;
const char *p;
device_add_boot_option(device, opt);
- return 0;
+ return opt;
fail:
talloc_free(opt);
- return -1;
+ return NULL;
}
void parser_init(void);
void iterate_parsers(struct discover_context *ctx);
-int parse_user_event(struct device *device, struct event *event);
+struct boot_option *parse_user_event(struct device *device,
+ struct event *event);
#endif /* _PARSER_H */
return 0;
}
+static int print_boot_option_add(struct device *dev,
+ struct boot_option *opt,
+ void __attribute__((unused)) *arg)
+{
+ printf("new boot option (dev: %s):\n", dev->id);
+ printf("\tdev id: %s\n", opt->device_id);
+ printf("\tid: %s\n", opt->id);
+ printf("\tname: %s\n", opt->name);
+ printf("\tdesc: %s\n", opt->description);
+ printf("\ticon: %s\n", opt->icon_file);
+ printf("\tboot: %s\n", opt->boot_image_file);
+ printf("\tinit: %s\n", opt->initrd_file);
+ printf("\targs: %s\n", opt->boot_args);
+
+ return 0;
+}
+
static void print_device_remove(struct device *device,
void __attribute__((unused)) *arg)
{
static struct discover_client_ops client_ops = {
.device_add = print_device_add,
+ .boot_option_add = print_boot_option_add,
.device_remove = print_device_remove,
};