[syslinux:elflink] ldlinux: Never exit from ldlinux.c32

syslinux-bot for Matt Fleming matt.fleming at intel.com
Mon Nov 26 05:27:03 PST 2012


Commit-ID:  4e140a59517f79bf593bec0f5a80810aa877f3ed
Gitweb:     http://www.syslinux.org/commit/4e140a59517f79bf593bec0f5a80810aa877f3ed
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Wed, 21 Nov 2012 21:03:24 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Mon, 26 Nov 2012 12:33:58 +0000

ldlinux: Never exit from ldlinux.c32

If there's no DEFAULT directive in the config file and the user hits
the ENTER key enough times, or we timeout waiting for input,
ldlinux.c32 will exit. This should never be allowed to happen, and we
need to keep doing the ldlinux_auto_boot()/boot prompt dance.

Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 com32/elflink/ldlinux/cli.c     |  3 ++-
 com32/elflink/ldlinux/ldlinux.c | 49 +++++++++++++++++++++++------------------
 com32/include/cli.h             |  2 +-
 3 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/com32/elflink/ldlinux/cli.c b/com32/elflink/ldlinux/cli.c
index ebeaeec..d876895 100644
--- a/com32/elflink/ldlinux/cli.c
+++ b/com32/elflink/ldlinux/cli.c
@@ -119,7 +119,7 @@ static const char * cmd_reverse_search(int *cursor, clock_t *kbd_to,
 
 const char *edit_cmdline(const char *input, int top /*, int width */ ,
 			 int (*pDraw_Menu) (int, int, int),
-			 void (*show_fkey) (int))
+			 void (*show_fkey) (int), bool *timedout)
 {
     static char cmdline[MAX_CMDLINE_LEN];
     char temp_cmdline[MAX_CMDLINE_LEN] = { };
@@ -202,6 +202,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
 	switch (key) {
 	case KEY_NONE:
 	    /* We timed out. */
+	    *timedout = true;
 	    return NULL;
 
 	case KEY_CTRL('L'):
diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index 59c5598..004769c 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -206,26 +206,6 @@ bad_kernel:
 	}
 }
 
-static void enter_cmdline(void)
-{
-	const char *cmdline;
-
-	/* Enter endless command line prompt, should support "exit" */
-	while (1) {
-		cmdline = edit_cmdline("boot:", 1, NULL, cat_help_file);
-		printf("\n");
-
-		/* return if user only press enter or we timed out */
-		if (!cmdline || cmdline[0] == '\0') {
-			if (ontimeoutlen)
-				load_kernel(ontimeout);
-			return;
-		}
-
-		load_kernel(cmdline);
-	}
-}
-
 /*
  * If this function returns you must call ldinux_enter_command() to
  * preserve the 4.0x behaviour.
@@ -241,10 +221,35 @@ void ldlinux_auto_boot(void)
 		load_kernel(default_cmd);
 }
 
+static void enter_cmdline(void)
+{
+	const char *cmdline;
+
+	/* Enter endless command line prompt, should support "exit" */
+	while (1) {
+		bool to = false;
+
+		if (noescape) {
+			ldlinux_auto_boot();
+			continue;
+		}
+
+		cmdline = edit_cmdline("boot:", 1, NULL, cat_help_file, &to);
+		printf("\n");
+
+		/* return if user only press enter or we timed out */
+		if (!cmdline || cmdline[0] == '\0') {
+			if (to && ontimeoutlen)
+				load_kernel(ontimeout);
+			else
+				ldlinux_auto_boot();
+		} else
+			load_kernel(cmdline);
+	}
+}
+
 void ldlinux_enter_command(void)
 {
-	if (noescape)
-		ldlinux_auto_boot();
 	enter_cmdline();
 }
 
diff --git a/com32/include/cli.h b/com32/include/cli.h
index 513c171..eee4576 100644
--- a/com32/include/cli.h
+++ b/com32/include/cli.h
@@ -14,7 +14,7 @@ extern void clear_screen(void);
 extern int mygetkey(clock_t timeout);
 extern const char *edit_cmdline(const char *input, int top /*, int width */ ,
 				int (*pDraw_Menu) (int, int, int),
-				void (*show_fkey) (int));
+				void (*show_fkey) (int), bool *);
 
 extern struct menu *root_menu, *start_menu, *hide_menu, *menu_list, *default_menu;
 #endif


More information about the Syslinux-commits mailing list