X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fdevice-handler.c;h=983c50909ef7f5900f916bb5cf4040b7bdf6d994;hp=9c050293df98cf446a44aa560ad3941dbfa4aa89;hb=3917e88b838001b13a19fc6ea01d08b08c0770ca;hpb=70a58a78c951403ae67c44c839caf0e77d0d84db diff --git a/discover/device-handler.c b/discover/device-handler.c index 9c05029..983c509 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -1278,6 +1278,7 @@ static int device_handler_requery_timeout_fn(void *data) struct requery_data *rqd = data; struct device_handler *handler; struct discover_device *device; + bool autoboot; handler = rqd->handler; device = rqd->device; @@ -1300,9 +1301,14 @@ static int device_handler_requery_timeout_fn(void *data) talloc_free(opt); } + /* Track whether autoboot was enabled, if we cancel a default option + * it will be switched off. + */ + autoboot = handler->autoboot_enabled; + 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 is being requeried", + pb_log("Default option %s cancelled since device is being requeried\n", opt->option->name); device_handler_cancel_default(handler); } @@ -1310,6 +1316,8 @@ static int device_handler_requery_timeout_fn(void *data) talloc_free(opt); } + handler->autoboot_enabled = autoboot; + discover_server_notify_device_remove(handler->server, device->device); device->notified = false; @@ -1404,6 +1412,28 @@ int device_handler_dhcp(struct device_handler *handler, return 0; } +struct discover_boot_option *device_handler_find_option_by_name( + struct device_handler *handler, const char *device, + const char *name) +{ + size_t len = strlen(name); + unsigned int i; + + for (i = 0; i < handler->n_devices; i++) { + struct discover_device *dev = handler->devices[i]; + struct discover_boot_option *opt; + + list_for_each_entry(&dev->boot_options, opt, list) + /* Match exactly, partial matches can be quite common */ + if (strlen(opt->option->name) == len && + !strcmp(opt->option->name, name)) + if (!dev || !strcmp(opt->option->device_id, device)) + return opt; + } + + return NULL; +} + static struct discover_boot_option *find_boot_option_by_id( struct device_handler *handler, const char *id) {