mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Krzysztof Halasa <khc@pm.waw.pl>
To: barebox@lists.infradead.org
Subject: RFC: Force a 2s delay on startup to allow bypassing /dev/env0.
Date: Sat, 05 May 2012 23:26:22 +0200	[thread overview]
Message-ID: <m31umynwu9.fsf@intrepid.localdomain> (raw)

Just requesting comments. I'm using this on my hw.

The idea is that /env/bin/init may be uninterruptible and the user
may be unable to recover control over the barebox. Perhaps there is
a better way?

Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>

diff --git a/common/startup.c b/common/startup.c
index abd1b77..fde99d5 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -30,6 +30,7 @@
  * @brief Main entry into the C part of barebox
  */
 #include <common.h>
+#include <clock.h>
 #include <init.h>
 #include <command.h>
 #include <malloc.h>
@@ -117,6 +118,8 @@ void start_barebox (void)
 	int result;
 #ifdef CONFIG_COMMAND_SUPPORT
 	struct stat s;
+	uint64_t start;
+	int stop = 0;
 #endif
 
 	for (initcall = __barebox_initcalls_start;
@@ -130,6 +133,17 @@ void start_barebox (void)
 
 	display_meminfo();
 
+#ifdef CONFIG_COMMAND_SUPPORT
+	start = get_time_ns();
+	printf("\nPress Control-C to stop.");
+	while (!is_timeout(start, 2 * SECOND))
+		if (ctrlc()) {
+			stop = 1;
+			break;
+		}
+	putchar('\n');
+#endif
+
 #ifdef CONFIG_ENV_HANDLING
 	if (envfs_load(default_environment_path, "/env")) {
 #ifdef CONFIG_DEFAULT_ENVIRONMENT
@@ -141,14 +155,16 @@ void start_barebox (void)
 	}
 #endif
 #ifdef CONFIG_COMMAND_SUPPORT
-	printf("running /env/bin/init...\n");
-
-	if (!stat("/env/bin/init", &s)) {
+	if (stop)
+		printf("skipping /env/bin/init\n");
+	else if (!stat("/env/bin/init", &s)) {
+		printf("running /env/bin/init...\n");
 		run_command("source /env/bin/init", 0);
-	} else {
-		printf("not found\n");
-	}
+	} else
+		printf("/env/bin/init not found\n");
+
 #endif
+
 	/* main_loop() can return to retry autoboot, if so just run it again. */
 	for (;;)
 		run_shell();

-- 
Krzysztof Halasa

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2012-05-05 21:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-05 21:26 Krzysztof Halasa [this message]
2012-05-06 17:16 ` Sascha Hauer
2012-05-06 17:50   ` Krzysztof Halasa
2012-05-06 18:08     ` Sascha Hauer
2012-05-07  0:14     ` Marc Reilly

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=m31umynwu9.fsf@intrepid.localdomain \
    --to=khc@pm.waw.pl \
    --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