summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-02-12 15:16:38 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-02-14 08:56:40 +0100
commite43eed6606e44574d665b3338b701da1035c504e (patch)
tree5926d9067296f4c2b4fe990a29c9d560ffac5f3b /commands
parent4c368ee077b8918bf68979e8079439fcf55ac13f (diff)
downloadbarebox-e43eed6606e44574d665b3338b701da1035c504e.tar.gz
commands: boot: create boot entries on demand
We currently create all boot entries before attempting boot. This is less than optimal, because this may involve probing devices that won't be used for actual boot. Fix this by not creating boot entries till the previous boot argument (command line argument or boot.default word) was found to be unbootable. This means that "boot mmc1 mmc0" will now not touch mmc0 if mmc1 had a bootable entry. This is only done when no menu or list was requested. As the boot entries are in a linked list, the allocation done for each boot argument could be omitted, but as the saving from skipping an allocation is easily dwarfed by the boot medium access, we just reallocate and enjoy the improved code clarity. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/boot.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/commands/boot.c b/commands/boot.c
index ce4eeac..aeaba39 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -90,6 +90,18 @@ static int do_boot(int argc, char *argv[])
ret = bootentry_create_from_name(entries, name);
if (ret <= 0)
printf("Nothing bootable found on '%s'\n", name);
+
+ if (do_list || do_menu)
+ continue;
+
+ bootentries_for_each_entry(entries, entry) {
+ ret = boot_entry(entry, verbose, dryrun);
+ if (!ret)
+ break;
+ }
+
+ bootentries_free(entries);
+ entries = bootentries_alloc();
}
if (list_empty(&entries->entries)) {
@@ -107,12 +119,6 @@ static int do_boot(int argc, char *argv[])
goto out;
}
- bootentries_for_each_entry(entries, entry) {
- ret = boot_entry(entry, verbose, dryrun);
- if (!ret)
- break;
- }
-
out:
bootentries_free(entries);
free(freep);