X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fdevice-handler.c;h=b083af4d0c6cdc0d406e9f609bcd7b387d4f6cbe;hp=c57b7b62880d8d4a8952fd896ac3bfe8dd38311d;hb=f94ca3311758854670d25ba4e7853d76c2113402;hpb=c14b12980885edd035322cd3bc87efff444c39b1 diff --git a/discover/device-handler.c b/discover/device-handler.c index c57b7b6..b083af4 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -372,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) @@ -386,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 */