* [PATCH] extlinux: resolve absolute paths against the partition root
@ 2026-08-26 0:38 Stephano Cetola
2026-08-28 10:44 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Stephano Cetola @ 2026-08-26 0:38 UTC (permalink / raw)
To: Sascha Hauer, open list:BAREBOX
extlinux_boot() always joined a path with '/' against rootpath, which
holds the config file's own directory, not the partition root. A
KERNEL/INITRD/FDT value starting with '/', the normal syslinux way to
name a path from the partition root, got treated as relative instead.
The extlinux.conf file itself can live in a different directory than
the partition root (extlinux_scan_directory() looks in both
boot/extlinux/ and extlinux/), so this produced a wrong, nonexistent
path whenever a config used an absolute KERNEL/INITRD/FDT entry.
Track the partition root and the config file's own directory as two
separate fields, cfgdir and rootpath, and resolve a path against
rootpath if it starts with '/', or cfgdir otherwise.
Fixes: b912fa9fc3ca ("Add support for extlinux.conf")
Signed-off-by: Stephano Cetola <stephano@cetola.net>
---
common/extlinux.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/common/extlinux.c b/common/extlinux.c
index caa62923da..7a92c15e4d 100644
--- a/common/extlinux.c
+++ b/common/extlinux.c
@@ -17,6 +17,7 @@
struct extlinux_entry {
struct bootentry entry;
char *rootpath;
+ char *cfgdir;
char *label;
char *kernel;
char *initrd;
@@ -25,6 +26,19 @@ struct extlinux_entry {
char *append;
};
+/*
+ * A path starting with '/' is absolute and resolves against the
+ * partition root. Anything else is relative to the extlinux.conf
+ * file's own directory, per syslinux convention.
+ */
+static char *extlinux_make_abs(const char *rootpath, const char *cfgdir,
+ const char *relpath)
+{
+ if (relpath[0] == '/')
+ return basprintf("%s%s", rootpath, relpath);
+ return basprintf("%s/%s", cfgdir, relpath);
+}
+
static int extlinux_boot(struct bootentry *entry, int verbose, int dryrun)
{
struct extlinux_entry *e =
@@ -38,18 +52,18 @@ static int extlinux_boot(struct bootentry *entry, int verbose, int dryrun)
data.dryrun = max_t(int, dryrun, data.dryrun);
data.verbose = max(verbose, data.verbose);
- kernel_abs = basprintf("%s/%s", e->rootpath, e->kernel);
+ kernel_abs = extlinux_make_abs(e->rootpath, e->cfgdir, e->kernel);
data.os_file = kernel_abs;
if (e->initrd) {
- initrd_abs = basprintf("%s/%s", e->rootpath, e->initrd);
+ initrd_abs = extlinux_make_abs(e->rootpath, e->cfgdir, e->initrd);
data.initrd_file = initrd_abs;
}
if (e->fdt) {
- char *fdtdir = e->fdtdir ? : e->rootpath;
+ char *fdtdir = e->fdtdir ? : e->cfgdir;
- fdt_abs = basprintf("%s/%s", fdtdir, e->fdt);
+ fdt_abs = extlinux_make_abs(e->rootpath, fdtdir, e->fdt);
data.oftree_file = fdt_abs;
}
@@ -76,6 +90,7 @@ static void extlinux_entry_free(struct bootentry *entry)
container_of(entry, struct extlinux_entry, entry);
free(e->rootpath);
+ free(e->cfgdir);
free(e->label);
free(e->kernel);
free(e->initrd);
@@ -124,7 +139,8 @@ static struct extlinux_entry *parse_extlinux_conf(const char *abspath,
if (!strcmp(val, default_label)) {
entry = xzalloc(sizeof(*entry));
entry->label = xstrdup(val);
- entry->rootpath = dirname(xstrdup(abspath));
+ entry->rootpath = xstrdup(rootpath);
+ entry->cfgdir = dirname(xstrdup(abspath));
} else if (entry) {
break;
}
---
base-commit: 9bc1a26592a59919d2ee8c60c273d87d3d9f2e81
change-id: 20260822-send-extlinux-abs-path-bd9809e3dda8
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] extlinux: resolve absolute paths against the partition root
2026-08-26 0:38 [PATCH] extlinux: resolve absolute paths against the partition root Stephano Cetola
@ 2026-08-28 10:44 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-08-28 10:44 UTC (permalink / raw)
To: open list:BAREBOX, Stephano Cetola
On Tue, 25 Aug 2026 17:38:43 -0700, Stephano Cetola wrote:
> extlinux_boot() always joined a path with '/' against rootpath, which
> holds the config file's own directory, not the partition root. A
> KERNEL/INITRD/FDT value starting with '/', the normal syslinux way to
> name a path from the partition root, got treated as relative instead.
> The extlinux.conf file itself can live in a different directory than
> the partition root (extlinux_scan_directory() looks in both
> boot/extlinux/ and extlinux/), so this produced a wrong, nonexistent
> path whenever a config used an absolute KERNEL/INITRD/FDT entry.
>
> [...]
Applied, thanks!
[1/1] extlinux: resolve absolute paths against the partition root
https://git.pengutronix.de/cgit/barebox/commit/?id=1cbbf0e06cf2 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-28 10:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-26 0:38 [PATCH] extlinux: resolve absolute paths against the partition root Stephano Cetola
2026-08-28 10:44 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox