X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fdevice-handler.c;h=eaa85de166ce4228b707046ce3e344ec62c1f17d;hp=9033c4fdfb8d3162417ed332e415b6446d33df8e;hb=d8d61e648ebf6a3336820db94244c4251361cf2f;hpb=8b2ccd525b328994d3e62c01092b20859a23e36d diff --git a/discover/device-handler.c b/discover/device-handler.c index 9033c4f..eaa85de 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -19,6 +18,7 @@ #include "device-handler.h" #include "discover-server.h" +#include "platform.h" #include "event.h" #include "parser.h" #include "resource.h" @@ -250,7 +250,7 @@ const char *discover_device_get_param(struct discover_device *device, list_for_each_entry(&device->params, param, list) { if (!strcmp(param->name, name)) - return param->name; + return param->value; } return NULL; } @@ -279,6 +279,7 @@ struct device_handler *device_handler_init(struct discover_server *server, void device_handler_remove(struct device_handler *handler, struct discover_device *device) { + struct discover_boot_option *opt, *tmp; unsigned int i; for (i = 0; i < handler->n_devices; i++) @@ -290,6 +291,16 @@ void device_handler_remove(struct device_handler *handler, return; } + /* Free any unresolved options, as they're currently allocated + * against the handler */ + list_for_each_entry_safe(&handler->unresolved_boot_options, + opt, tmp, list) { + if (opt->device != device) + continue; + list_remove(&opt->list); + talloc_free(opt); + } + handler->n_devices--; memmove(&handler->devices[i], &handler->devices[i + 1], (handler->n_devices - i) * sizeof(handler->devices[0])); @@ -361,7 +372,8 @@ static int default_timeout(void *arg) static bool priority_match(struct boot_priority *prio, struct discover_boot_option *opt) { - return prio->type == opt->device->device->type; + return prio->type == opt->device->device->type || + prio->type == DEVICE_TYPE_ANY; } static int default_option_priority(struct discover_boot_option *opt) @@ -375,28 +387,36 @@ static int default_option_priority(struct discover_boot_option *opt) for (i = 0; i < config->n_boot_priorities; i++) { prio = &config->boot_priorities[i]; if (priority_match(prio, opt)) - break; + return prio->priority; } - return i; + return 0; } static void set_default(struct device_handler *handler, struct discover_boot_option *opt) { + int new_prio; + if (!handler->autoboot_enabled) return; + new_prio = default_option_priority(opt); + + /* A negative priority indicates that we don't want to boot this device + * by default */ + if (new_prio < 0) + return; + /* Resolve any conflicts: if we have a new default option, it only * replaces the current if it has a higher priority. */ if (handler->default_boot_option) { - int new_prio, cur_prio; + int cur_prio; - new_prio = default_option_priority(opt); cur_prio = default_option_priority( handler->default_boot_option); - if (new_prio < cur_prio) { + if (new_prio > cur_prio) { handler->default_boot_option = opt; /* extend the timeout a little, so the user sees some * indication of the change */ @@ -816,17 +836,6 @@ static int mount_device(struct discover_device *dev) return 0; } - /* Retry mount without ro option. */ - rc = process_run_simple(dev, pb_system_apps.mount, - dev->device_path, dev->mount_path, NULL); - - if (!rc) { - dev->mounted = true; - dev->mounted_rw = true; - dev->unmount = true; - return 0; - } - pb_rmdir_recursive(mount_base(), dev->mount_path); err_free: talloc_free(dev->mount_path);