summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-11-01 14:19:56 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-11-05 08:37:55 +0100
commit533835d53612543b4b2ebbd31589e4ba0a0080f5 (patch)
treea6803895cc15e876091869860205f49dba8c44e0 /commands
parent9e26e30af4e503d4a8286a3932899afaee271c6d (diff)
downloadbarebox-533835d53612543b4b2ebbd31589e4ba0a0080f5.tar.gz
barebox-533835d53612543b4b2ebbd31589e4ba0a0080f5.tar.xz
boot command: Add timeout support for menu
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/boot.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/commands/boot.c b/commands/boot.c
index 1bec406ee3..91766e03be 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -21,6 +21,7 @@
#include <blspec.h>
#include <libgen.h>
#include <malloc.h>
+#include <clock.h>
#include <boot.h>
#include <menu.h>
#include <fs.h>
@@ -30,6 +31,7 @@
static int verbose;
static int dryrun;
+static int timeout;
/*
* Start a single boot script. 'path' is a full path to a boot script.
@@ -255,6 +257,9 @@ static void bootsources_menu(char *entries[], int num_entries)
back_entry->non_re_ent = 1;
menu_add_entry(blspec->menu, back_entry);
+ if (timeout >= 0)
+ blspec->menu->auto_select = timeout;
+
menu_show(blspec->menu);
free(back_entry);
@@ -332,8 +337,9 @@ static int do_boot(int argc, char *argv[])
verbose = 0;
dryrun = 0;
+ timeout = -1;
- while ((opt = getopt(argc, argv, "vldm")) > 0) {
+ while ((opt = getopt(argc, argv, "vldmt:")) > 0) {
switch (opt) {
case 'v':
verbose++;
@@ -347,6 +353,9 @@ static int do_boot(int argc, char *argv[])
case 'm':
do_menu = 1;
break;
+ case 't':
+ timeout = simple_strtoul(optarg, NULL, 0);
+ break;
}
}
@@ -415,6 +424,7 @@ BAREBOX_CMD_HELP_OPT ("-v","Increase verbosity\n")
BAREBOX_CMD_HELP_OPT ("-d","Dryrun. See what happens but do no actually boot\n")
BAREBOX_CMD_HELP_OPT ("-l","List available boot sources\n")
BAREBOX_CMD_HELP_OPT ("-m","Show a menu with boot options\n")
+BAREBOX_CMD_HELP_OPT ("-t <timeout>","specify timeout for the menu\n")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(boot)