X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fdevice-handler.c;h=b93cdfa1130cc5c956e6608a997c118a3786cd08;hp=dd3aee92ca35d0385880b190f60a379494152ad8;hb=1860aac29624b1cb292a7ca549dc063bcd3f9bb6;hpb=85bd33ca9777c386359b9b3899888316354a4e1f diff --git a/discover/device-handler.c b/discover/device-handler.c index dd3aee9..b93cdfa 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -344,6 +344,11 @@ void device_handler_remove(struct device_handler *handler, talloc_free(opt); } + /* if this is a network device, we have to unregister it from the + * network code */ + if (device->device->type == DEVICE_TYPE_NETWORK) + network_unregister_device(handler->network, device); + handler->n_devices--; memmove(&handler->devices[i], &handler->devices[i + 1], (handler->n_devices - i) * sizeof(handler->devices[0])); @@ -373,7 +378,7 @@ static void countdown_status(struct device_handler *handler, status.progress = -1; status.detail = NULL; status.message = talloc_asprintf(handler, - "Booting %s in %u sec", opt->option->name, sec); + "Booting in %d sec: %s", sec, opt->option->name); discover_server_notify_boot_status(handler->server, &status); @@ -436,6 +441,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) { @@ -444,6 +465,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 @@ -646,6 +671,8 @@ void device_handler_add_device(struct device_handler *handler, struct discover_device *, handler->n_devices); handler->devices[handler->n_devices - 1] = device; + if (device->device->type == DEVICE_TYPE_NETWORK) + network_register_device(handler->network, device); } /* Start discovery on a hotplugged device. The device will be in our devices