summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2014-04-30 10:58:43 +0800
committerJeremy Kerr <jk@ozlabs.org>2014-07-21 17:20:08 +0800
commit1860aac29624b1cb292a7ca549dc063bcd3f9bb6 (patch)
treee26898762a34d66219fcfbbadb9e0a5865fa493b /discover/device-handler.c
parente19c5fe83174de749843bb8486a0d12c25adcb82 (diff)
downloadtalos-petitboot-1860aac29624b1cb292a7ca549dc063bcd3f9bb6.tar.gz
talos-petitboot-1860aac29624b1cb292a7ca549dc063bcd3f9bb6.zip
discover: check config.boot_device before setting a default
If a default device is set, we only allow booting from that device. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/device-handler.c')
-rw-r--r--discover/device-handler.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 7f7081d..b93cdfa 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -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
OpenPOWER on IntegriCloud