]> git.ozlabs.org Git - petitboot/blobdiff - discover/device-handler.c
discover/device-handler: Disable safe mode warning on reinit
[petitboot] / discover / device-handler.c
index a73a7ce590abe65c7463899f369d7d3c7b549195..efeb6264d7cc5f8d7c031f6ed9509deeaab5c6c7 100644 (file)
@@ -18,7 +18,9 @@
 #include <process/process.h>
 #include <url/url.h>
 #include <i18n/i18n.h>
+#include <pb-config/pb-config.h>
 
+#include <sys/sysmacros.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netdb.h>
@@ -321,7 +323,7 @@ struct device_handler *device_handler_init(struct discover_server *server,
        handler->server = server;
        handler->waitset = waitset;
        handler->dry_run = dry_run;
-       handler->autoboot_enabled = config_get()->autoboot_enabled;
+       handler->autoboot_enabled = config_autoboot_active(config_get());
 
        list_init(&handler->unresolved_boot_options);
 
@@ -348,9 +350,19 @@ void device_handler_reinit(struct device_handler *handler)
 {
        struct discover_boot_option *opt, *tmp;
        struct ramdisk_device *ramdisk;
+       struct config *config;
        unsigned int i;
 
        device_handler_cancel_default(handler);
+       /* Cancel any pending non-default boot */
+       if (handler->pending_boot) {
+               boot_cancel(handler->pending_boot);
+               handler->pending_boot = NULL;
+               handler->pending_boot_is_default = false;
+       }
+
+       /* Cancel any remaining async jobs */
+       process_stop_async_all();
 
        /* free unresolved boot options */
        list_for_each_entry_safe(&handler->unresolved_boot_options,
@@ -374,6 +386,14 @@ void device_handler_reinit(struct device_handler *handler)
        handler->ramdisks = NULL;
        handler->n_ramdisks = 0;
 
+       /* If the safe mode warning was active disable it now */
+       if (config_get()->safe_mode) {
+               config = config_copy(handler, config_get());
+               config->safe_mode = false;
+               config_set(config);
+               discover_server_notify_config(handler->server, config);
+       }
+
        device_handler_reinit_sources(handler);
 }
 
@@ -442,6 +462,7 @@ static void _device_handler_vstatus(struct device_handler *handler,
 
        status.type = type;
        status.message = talloc_vasprintf(handler, fmt, ap);
+       status.backlog = false;
 
        device_handler_status(handler, &status);
 
@@ -617,6 +638,7 @@ static void countdown_status(struct device_handler *handler,
        status.type = STATUS_INFO;
        status.message = talloc_asprintf(handler,
                        _("Booting in %d sec: %s"), sec, opt->option->name);
+       status.backlog = false;
 
        device_handler_status(handler, &status);
 
@@ -1037,8 +1059,6 @@ int device_handler_discover(struct device_handler *handler,
                _("Processing new %s device"),
                device_type_display_name(dev->device->type));
 
-       process_boot_option_queue(handler);
-
        /* create our context */
        ctx = device_handler_discover_context_create(handler, dev);
 
@@ -1056,6 +1076,7 @@ int device_handler_discover(struct device_handler *handler,
        /* add discovered stuff to the handler */
        device_handler_discover_context_commit(handler, ctx);
 
+       process_boot_option_queue(handler);
 out:
        talloc_unlink(handler, ctx);