]> git.ozlabs.org Git - petitboot/blobdiff - discover/device-handler.c
discover: check config.boot_device before setting a default
[petitboot] / discover / device-handler.c
index 7f7081df5f6fc27abd033788d2202c5cca1988c2..b93cdfa1130cc5c956e6608a997c118a3786cd08 100644 (file)
@@ -441,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)
 {
@@ -449,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