X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fdevice-handler.c;h=23961249ff595b857b327a34f025e31c64a97d1d;hp=594a7c3c80a87b2c142cd17730cf09f46b50b149;hb=198c4e575e177ae5458238e7b474361506a6f302;hpb=19dab336ae13f0476bfbf0db34f1329a802eeb8e diff --git a/discover/device-handler.c b/discover/device-handler.c index 594a7c3..2396124 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -75,6 +75,7 @@ static void boot_option_finalise(struct discover_boot_option *opt) assert(!opt->option->boot_image_file); assert(!opt->option->initrd_file); assert(!opt->option->icon_file); + assert(!opt->option->device_id); if (opt->boot_image) opt->option->boot_image_file = opt->boot_image->url->full; @@ -82,6 +83,8 @@ static void boot_option_finalise(struct discover_boot_option *opt) opt->option->initrd_file = opt->initrd->url->full; if (opt->icon) opt->option->icon_file = opt->icon->url->full; + + opt->option->device_id = opt->device->device->id; } static void process_boot_option_queue(struct device_handler *handler) @@ -149,8 +152,20 @@ static void context_commit(struct device_handler *handler, discover_server_notify_boot_option_add(handler->server, opt->option); } else { - list_add(&handler->unresolved_boot_options, &opt->list); - talloc_steal(handler, opt); + 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); + } } } } @@ -159,7 +174,7 @@ void discover_context_add_boot_option(struct discover_context *ctx, struct discover_boot_option *boot_option) { boot_option->source = ctx->parser; - list_add(&ctx->boot_options, &boot_option->list); + list_add_tail(&ctx->boot_options, &boot_option->list); talloc_steal(ctx, boot_option); } @@ -220,6 +235,9 @@ static int mount_device(struct discover_device *dev) { const char *argv[6]; + if (!dev->device_path) + return -1; + if (!dev->mount_path) dev->mount_path = join_paths(dev, mount_base(), dev->device_path); @@ -561,7 +579,7 @@ void device_handler_destroy(struct device_handler *handler) static int device_match_path(struct discover_device *dev, const char *path) { - return !strcmp(dev->device_path, path); + return dev->device_path && !strcmp(dev->device_path, path); } static int device_match_uuid(struct discover_device *dev, const char *uuid) @@ -663,6 +681,13 @@ static struct discover_boot_option *find_boot_option_by_id( return NULL; } +static void boot_status(void *arg, struct boot_status *status) +{ + struct device_handler *handler = arg; + + discover_server_notify_boot_status(handler->server, status); +} + void device_handler_boot(struct device_handler *handler, struct boot_command *cmd) { @@ -670,5 +695,5 @@ void device_handler_boot(struct device_handler *handler, opt = find_boot_option_by_id(handler, cmd->option_id); - boot(handler, opt, cmd, handler->dry_run); + boot(handler, opt, cmd, handler->dry_run, boot_status, handler); }