summaryrefslogtreecommitdiffstats
path: root/common/startup.c
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2020-04-22 09:35:16 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-04-27 21:16:05 +0200
commit19738925331a98244f7f774001e4964e9891d3b6 (patch)
treee54d9d10403d77c71cf58ef52223fe4e20235346 /common/startup.c
parentc5c6fa599fcc2e1506b4088993d4e36bb6a21543 (diff)
downloadbarebox-19738925331a98244f7f774001e4964e9891d3b6.tar.gz
barebox-19738925331a98244f7f774001e4964e9891d3b6.tar.xz
startup: don't clobber original autoboot state
do_autoboot_countdown changes autoboot state if the user presses m for menu or ctrl+c to abort during count down. This is an internal detail and doesn't need to be reflected in the state of the global variable. This will improve UX when exporting the variable in the follow-up commit, because on a regular boot it $autoboot will expand to countdown instead of abort/boot/menu dependent on prior user input. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/startup.c')
-rw-r--r--common/startup.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/common/startup.c b/common/startup.c
index 7373ba7d0c..bda7823176 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -195,7 +195,7 @@ static bool test_abort(void)
#define INITFILE "/env/bin/init"
#define MENUFILE "/env/menu/mainmenu"
-static enum autoboot_state autoboot_state = AUTOBOOT_COUNTDOWN;
+static enum autoboot_state global_autoboot_state = AUTOBOOT_COUNTDOWN;
/**
* set_autoboot_state - set the autoboot state
@@ -206,7 +206,7 @@ static enum autoboot_state autoboot_state = AUTOBOOT_COUNTDOWN;
*/
void set_autoboot_state(enum autoboot_state autoboot)
{
- autoboot_state = autoboot;
+ global_autoboot_state = autoboot;
}
/**
@@ -222,6 +222,7 @@ void set_autoboot_state(enum autoboot_state autoboot)
*/
enum autoboot_state do_autoboot_countdown(void)
{
+ enum autoboot_state autoboot_state;
unsigned flags = CONSOLE_COUNTDOWN_EXTERN;
int ret;
struct stat s;
@@ -229,8 +230,8 @@ enum autoboot_state do_autoboot_countdown(void)
char *abortkeys = NULL;
unsigned char outkey;
- if (autoboot_state != AUTOBOOT_COUNTDOWN)
- return autoboot_state;
+ if (global_autoboot_state != AUTOBOOT_COUNTDOWN)
+ return global_autoboot_state;
menu_exists = stat(MENUFILE, &s) == 0;