summaryrefslogtreecommitdiffstats
path: root/commands/boot.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-03-20 12:26:19 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2014-03-24 07:58:33 +0100
commit09b884bdec3dd4cb4bac8a6f6e777eedf33c82f3 (patch)
tree7bd3f59ef16e3ed79c80be181515285d3b5b3d60 /commands/boot.c
parent6357b7fdad6b8954e743fc26dd6cc14056d751a7 (diff)
downloadbarebox-09b884bdec3dd4cb4bac8a6f6e777eedf33c82f3.tar.gz
barebox-09b884bdec3dd4cb4bac8a6f6e777eedf33c82f3.tar.xz
blspec: honor default/once entries again
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/boot.c')
-rw-r--r--commands/boot.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/commands/boot.c b/commands/boot.c
index a54d0d51ec..4a839790d1 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -243,7 +243,7 @@ static struct blspec *bootentries_collect(char *entries[], int num_entries)
static void bootsources_menu(char *entries[], int num_entries)
{
struct blspec *blspec = NULL;
- struct blspec_entry *entry;
+ struct blspec_entry *entry, *entry_default;
struct menu_entry *back_entry;
if (!IS_ENABLED(CONFIG_MENU)) {
@@ -252,10 +252,16 @@ static void bootsources_menu(char *entries[], int num_entries)
}
blspec = bootentries_collect(entries, num_entries);
+ if (blspec)
+ return;
+
+ entry_default = blspec_entry_default(blspec);
blspec_for_each_entry(blspec, entry) {
entry->me.action = bootsource_action;
menu_add_entry(blspec->menu, &entry->me);
+ if (entry == entry_default)
+ menu_set_selected_entry(blspec->menu, &entry->me);
}
back_entry = xzalloc(sizeof(*back_entry));
@@ -280,14 +286,23 @@ static void bootsources_menu(char *entries[], int num_entries)
static void bootsources_list(char *entries[], int num_entries)
{
struct blspec *blspec;
- struct blspec_entry *entry;
+ struct blspec_entry *entry, *entry_default;
blspec = bootentries_collect(entries, num_entries);
+ if (!blspec)
+ return;
- printf("%-20s %-20s %s\n", "device", "hwdevice", "title");
- printf("%-20s %-20s %s\n", "------", "--------", "-----");
+ entry_default = blspec_entry_default(blspec);
+
+ printf(" %-20s %-20s %s\n", "device", "hwdevice", "title");
+ printf(" %-20s %-20s %s\n", "------", "--------", "-----");
blspec_for_each_entry(blspec, entry) {
+ if (entry == entry_default)
+ printf("* ");
+ else
+ printf(" ");
+
if (entry->scriptpath)
printf("%-40s %s\n", basename(entry->scriptpath), entry->me.display);
else
@@ -312,7 +327,7 @@ static void bootsources_list(char *entries[], int num_entries)
static int boot(const char *name)
{
struct blspec *blspec;
- struct blspec_entry *entry;
+ struct blspec_entry *entry, *entry_default;
int ret;
blspec = blspec_alloc();
@@ -325,7 +340,19 @@ static int boot(const char *name)
return -ENOENT;
}
+ entry_default = blspec_entry_default(blspec);
+ if (entry_default) {
+ ret = boot_entry(entry_default);
+ if (!ret)
+ return ret;
+ printf("booting %s failed: %s\n", entry_default->me.display,
+ strerror(-ret));
+ }
+
blspec_for_each_entry(blspec, entry) {
+ if (entry == entry_default)
+ continue;
+
printf("booting %s\n", entry->me.display);
ret = boot_entry(entry);
if (!ret)