X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fdevice-handler.c;h=e4978faaffd13d4a0c3545d10caf54955062b5c2;hp=7f7081df5f6fc27abd033788d2202c5cca1988c2;hb=d2b12ddb905a74fa6b2e454142b0b9f71fd99398;hpb=0adfe11dc0738321cdd529f30773899cc8f79855 diff --git a/discover/device-handler.c b/discover/device-handler.c index 7f7081d..e4978fa 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -285,6 +285,9 @@ struct device_handler *device_handler_init(struct discover_server *server, parser_init(); + if (config_get()->safe_mode) + return handler; + rc = device_handler_init_sources(handler); if (rc) { talloc_free(handler); @@ -441,6 +444,22 @@ static int default_option_priority(struct discover_boot_option *opt) return 0; } +static bool device_allows_default(struct discover_device *dev) +{ + const char *dev_str; + + dev_str = config_get()->boot_device; + + if (!dev_str || !strlen(dev_str)) + return true; + + /* default devices are specified by UUIDs at present */ + if (strcmp(dev->uuid, dev_str)) + return false; + + return true; +} + static void set_default(struct device_handler *handler, struct discover_boot_option *opt) { @@ -449,6 +468,10 @@ static void set_default(struct device_handler *handler, if (!handler->autoboot_enabled) return; + /* do we allow default-booting from this device? */ + if (!device_allows_default(opt->device)) + return; + new_prio = default_option_priority(opt); /* A negative priority indicates that we don't want to boot this device @@ -822,6 +845,13 @@ static int device_handler_init_sources(struct device_handler *handler) static void device_handler_reinit_sources(struct device_handler *handler) { + /* if we haven't initialised sources previously (becuase we started in + * safe mode), then init once here. */ + if (!(handler->udev || handler->network || handler->user_event)) { + device_handler_init_sources(handler); + return; + } + udev_reinit(handler->udev); network_shutdown(handler->network);