From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 1/5] boot: aggregate bootentry provider entries one by one
Date: Mon, 9 Feb 2026 10:08:51 +0100 [thread overview]
Message-ID: <20260209090911.3561875-2-a.fatoum@barebox.org> (raw)
In-Reply-To: <20260209090911.3561875-1-a.fatoum@barebox.org>
To allow individual bootentry providers to more easily sort their
entries, pass each provider an empty list that's spliced onto the tail
of the aggregated list at the end.
This way we maintain that boot entries of different providers are sorted
by provider priority and boot entries of a single provider can be sorted
by each provider without having to worry about foreign boot entries.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
common/boot.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/common/boot.c b/common/boot.c
index 78d990f1617e..8ccc269ac5bd 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -26,6 +26,14 @@ int bootentries_add_entry(struct bootentries *entries, struct bootentry *entry)
return 0;
}
+#define BOOTENTRIES(name) \
+ struct bootentries name = { .entries = LIST_HEAD_INIT(name.entries) }
+
+static inline void bootentries_merge(struct bootentries *dst, struct bootentries *src)
+{
+ list_splice_tail_init(&src->entries, &dst->entries);
+}
+
struct bootentries *bootentries_alloc(void)
{
struct bootentries *bootentries;
@@ -452,9 +460,17 @@ int bootentry_create_from_name(struct bootentries *bootentries,
name = nfspath;
list_for_each_entry(p, &bootentry_providers, list) {
- ret = p->generate(bootentries, name);
+ BOOTENTRIES(provider_bootentries);
+
+ ret = p->generate(&provider_bootentries, name);
if (ret > 0)
found += ret;
+
+ /* We want to allow for providers to sort their bootentries as
+ * they see fit, so they are passed an empty list above with
+ * only their own entries and then we aggregate here
+ */
+ bootentries_merge(bootentries, &provider_bootentries);
}
free(nfspath);
--
2.47.3
next prev parent reply other threads:[~2026-02-09 9:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-09 9:08 [PATCH 0/5] blspec: sort entries according to specification Ahmad Fatoum
2026-02-09 9:08 ` Ahmad Fatoum [this message]
2026-02-09 9:08 ` [PATCH 2/5] " Ahmad Fatoum
2026-02-09 9:08 ` [PATCH 3/5] boot: give struct bootentry a path member Ahmad Fatoum
2026-02-09 9:08 ` [PATCH 4/5] commands: boot: support file path in boot -M for default entry Ahmad Fatoum
2026-02-09 9:08 ` [PATCH 5/5] test: self: add bootloader spec files test Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260209090911.3561875-2-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox