X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fdevice-handler.c;h=c31fceaf5a11b1ac22c28f50ad530866f4b7f23e;hp=9fd9fab5cf5f60db1b8c372b7401cc07b511b176;hb=8f0e069fc43ed6f6a230329839f970415147d1aa;hpb=07a5f9f1c50a9185851cd486d732976573d15c4f diff --git a/discover/device-handler.c b/discover/device-handler.c index 9fd9fab..c31fcea 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -359,6 +359,15 @@ void device_handler_remove(struct device_handler *handler, struct discover_boot_option *opt, *tmp; unsigned int i; + list_for_each_entry_safe(&device->boot_options, opt, tmp, list) { + if (opt == handler->default_boot_option) { + pb_log("Default option %s cancelled since device removed", + opt->option->name); + device_handler_cancel_default(handler); + break; + } + } + for (i = 0; i < handler->n_devices; i++) if (handler->devices[i] == device) break; @@ -861,7 +870,7 @@ out: device_handler_boot_status(handler, status); talloc_free(status); - talloc_free(ctx); + talloc_unlink(handler, ctx); return 0; } @@ -900,7 +909,7 @@ int device_handler_dhcp(struct device_handler *handler, device_handler_boot_status(handler, status); talloc_free(status); - talloc_free(ctx); + talloc_unlink(handler, ctx); return 0; } @@ -930,7 +939,7 @@ int device_handler_conf(struct device_handler *handler, device_handler_boot_status(handler, status); talloc_free(status); - talloc_free(ctx); + talloc_unlink(handler, ctx); return 0; } @@ -1162,7 +1171,7 @@ void device_handler_process_url(struct device_handler *handler, device_handler_discover_context_commit(handler, ctx); - talloc_free(ctx); + talloc_unlink(handler, ctx); status->type = BOOT_STATUS_INFO; status->message = talloc_asprintf(status, _("Config file %s parsed"), @@ -1191,6 +1200,14 @@ void device_handler_discover_context_commit(struct device_handler *handler, list_for_each_entry_safe(&ctx->boot_options, opt, tmp, list) { list_remove(&opt->list); + /* All boot options need at least a kernel image */ + if (!opt->boot_image || !opt->boot_image->url) { + pb_log("boot option %s is missing boot image, ignoring\n", + opt->option->id); + talloc_free(opt); + continue; + } + if (boot_option_resolve(opt, handler)) { pb_log("boot option %s is resolved, " "sending to clients\n", @@ -1564,6 +1581,41 @@ void device_release_write(struct discover_device *dev, bool release) dev->mounted = true; } +void device_sync_snapshots(struct device_handler *handler, const char *device) +{ + struct discover_device *dev = NULL; + unsigned int i; + + if (device) { + /* Find matching device and sync */ + dev = device_lookup_by_name(handler, device); + if (!dev) { + pb_log("%s: device name '%s' unrecognised\n", + __func__, device); + return; + } + if (dev->ramdisk) + device_release_write(dev, true); + else + pb_log("%s has no snapshot to merge, skipping\n", + dev->device->id); + return; + } + + /* Otherwise sync all relevant devices */ + for (i = 0; i < handler->n_devices; i++) { + dev = handler->devices[i]; + if (dev->device->type != DEVICE_TYPE_DISK && + dev->device->type != DEVICE_TYPE_USB) + continue; + if (dev->ramdisk) + device_release_write(dev, true); + else + pb_log("%s has no snapshot to merge, skipping\n", + dev->device->id); + } +} + #else void device_handler_discover_context_commit( @@ -1611,4 +1663,10 @@ void device_release_write(struct discover_device *dev __attribute__((unused)), { } +void device_sync_snapshots( + struct device_handler *handler __attribute__((unused)), + const char *device __attribute__((unused))) +{ +} + #endif