summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-07-24 20:48:07 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-08-09 07:13:02 +0200
commit29a2e4e34c6c8f15010f0e5f98483309ecc6ec70 (patch)
tree9374fbd819e2966fcd34647da0f02ff964c292d7 /common
parent206a4bc31fb518fadfd10e857cf7492442b54b59 (diff)
downloadbarebox-29a2e4e34c6c8f15010f0e5f98483309ecc6ec70.tar.gz
barebox-29a2e4e34c6c8f15010f0e5f98483309ecc6ec70.tar.xz
boot: allow booting by bootspec absolute path
When multiple bootloader spec files are available, the first match in lexical order will be the one to autoboot. Users can customize which one to use interactively via boot -m, but no means to select a different by default exists. Allow for this by having the boot command not only accept a directory to search for bootloader spec entries in, but also the path of a single bootloader spec file. This aligns it with what we have for bootscripts, where both directories containing boot scripts and the path to a specific boot script is understood. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220724184807.2123459-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/blspec.c11
-rw-r--r--common/boot.c1
2 files changed, 11 insertions, 1 deletions
diff --git a/common/blspec.c b/common/blspec.c
index b7cf2193dd..9bb25ee721 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -527,6 +527,7 @@ int blspec_scan_file(struct bootentries *bootentries, const char *root,
if (IS_ERR(entry))
return PTR_ERR(entry);
+ root = root ?: get_mounted_path(configname);
entry->rootpath = xstrdup(root);
entry->configpath = xstrdup(configname);
entry->cdev = get_cdev_by_mountpath(root);
@@ -813,6 +814,7 @@ int blspec_scan_devicename(struct bootentries *bootentries, const char *devname)
static int blspec_bootentry_provider(struct bootentries *bootentries,
const char *name)
{
+ struct stat s;
int ret, found = 0;
ret = blspec_scan_devicename(bootentries, name);
@@ -825,7 +827,14 @@ static int blspec_bootentry_provider(struct bootentries *bootentries,
if (!IS_ERR(nfspath))
name = nfspath;
- ret = blspec_scan_directory(bootentries, name);
+ ret = stat(name, &s);
+ if (ret)
+ return found;
+
+ if (S_ISDIR(s.st_mode))
+ ret = blspec_scan_directory(bootentries, name);
+ else if (S_ISREG(s.st_mode) && strends(name, ".conf"))
+ ret = blspec_scan_file(bootentries, NULL, name);
if (ret > 0)
found += ret;
diff --git a/common/boot.c b/common/boot.c
index 52b03eb64d..9c6fc30442 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -272,6 +272,7 @@ int bootentry_register_provider(int (*fn)(struct bootentries *bootentries, const
* name can be:
* - a name of a boot script under /env/boot
* - a full path of a boot script
+ * - a full path of a bootloader spec entry
* - a device name
* - a cdev name
* - a full path of a directory containing bootloader spec entries