CVS commit: [netbsd-5] src/sys/arch/i386/stand/boot

2013-09-07 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Sep  7 17:23:39 UTC 2013

Modified Files:
src/sys/arch/i386/stand/boot [netbsd-5]: boot2.c

Log Message:
Pull up following revision(s) (requested by he in ticket #1872):
sys/arch/i386/stand/lib/bootmenu.c: revision 1.11 via patch
sys/arch/i386/stand/lib/bootmenu.h: revision 1.3 via patch
sys/arch/i386/stand/boot/boot2.c: revision 1.59 via patch
Two changes for the i386 boot loader related to the boot menu which
can be defined in boot.cfg:
 * Add a menu command which re-displays the menu and initiates
   the timed countdown
 * Use any default command defined in boot.cfg as default args
   if the user runs boot with no arguments
This is useful in circumstances where you e.g. need to interrupt
the normal boot process to switch to serial console, and where
simply boot netbsd is no longer sufficient (e.g. as with install
media which needs the miniroot kernel module loaded).


To generate a diff of this commit:
cvs rdiff -u -r1.38.4.2 -r1.38.4.3 src/sys/arch/i386/stand/boot/boot2.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/i386/stand/boot/boot2.c
diff -u src/sys/arch/i386/stand/boot/boot2.c:1.38.4.2 src/sys/arch/i386/stand/boot/boot2.c:1.38.4.3
--- src/sys/arch/i386/stand/boot/boot2.c:1.38.4.2	Sun Feb 14 14:01:08 2010
+++ src/sys/arch/i386/stand/boot/boot2.c	Sat Sep  7 17:23:39 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot2.c,v 1.38.4.2 2010/02/14 14:01:08 bouyer Exp $	*/
+/*	$NetBSD: boot2.c,v 1.38.4.3 2013/09/07 17:23:39 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -131,9 +131,16 @@ void	command_quit(char *);
 void	command_boot(char *);
 void	command_dev(char *);
 void	command_consdev(char *);
+#ifndef SMALL
+void	command_menu(char *);
+#endif
 void	command_modules(char *);
 void	command_load(char *);
 void	command_multiboot(char *);
+#ifndef SMALL
+void	bootdefault(void);
+void	docommandchoice(int);
+#endif
 
 const struct bootblk_command commands[] = {
 	{ help,	command_help },
@@ -143,6 +150,9 @@ const struct bootblk_command commands[] 
 	{ boot,	command_boot },
 	{ dev,	command_dev },
 	{ consdev,	command_consdev },
+#ifndef SMALL
+	{ menu,	command_menu },
+#endif
 	{ modules,	command_modules },
 	{ load,	command_load },
 	{ multiboot,	command_multiboot },
@@ -508,10 +518,58 @@ static int getchoicefrominput(char *inpu
 }
 
 void
+docommandchoice(int choice)
+{
+	char input[80], *ic, *oc;
+ 
+	ic = bootconf.command[choice];
+	/* Split command string at ; into separate commands */
+	do {
+		oc = input;
+		/* Look for ; separator */
+		for (; *ic  *ic != COMMAND_SEPARATOR; ic++)
+			*oc++ = *ic;
+		if (*input == '\0')
+			continue;
+		/* Strip out any trailing spaces */
+		oc--;
+		for (; *oc == ' '  oc  input; oc--);
+		*++oc = '\0';
+		if (*ic == COMMAND_SEPARATOR)
+			ic++;
+		/* Stop silly command strings like ;;; */
+		if (*input != '\0')
+			docommand(input);
+		/* Skip leading spaces */
+		for (; *ic == ' '; ic++);
+	} while (*ic);
+}
+
+void
+bootdefault(void)
+{
+int choice;
+static int entered;
+ 
+if (bootconf.nummenu  0) {
+if (entered) {
+printf(default boot twice, skipping...\n);
+return;
+}
+entered = 1;
+choice = bootconf.def;
+printf(command(s): %s\n, bootconf.command[choice]);
+docommandchoice(choice);
+}
+}
+
+
+
+void
 doboottypemenu(void)
 {
 	int choice;
-	char input[80], *ic, *oc;
+	char input[80];
 		
 	printf(\n);
 	/* Display menu */
@@ -567,27 +625,7 @@ doboottypemenu(void)
 			printf(type \?\ or \help\ for help.\n);
 			bootmenu(); /* does not return */
 		} else {
-			ic = bootconf.command[choice];
-			/* Split command string at ; into separate commands */
-			do {
-oc = input;
-/* Look for ; separator */
-for (; *ic  *ic != COMMAND_SEPARATOR; ic++)
-	*oc++ = *ic;
-if (*input == '\0')
-	continue;
-/* Strip out any trailing spaces */
-oc--;
-for (; *oc ==' '  oc  input; oc--);
-*++oc = '\0';
-if (*ic == COMMAND_SEPARATOR)
-	ic++;
-/* Stop silly command strings like ;;; */
-if (*input != '\0')
-	docommand(input);
-/* Skip leading spaces */
-for (; *ic == ' '; ic++);
-			} while (*ic);
+			docommandchoice(choice);
 		}
 			
 	}
@@ -707,6 +745,9 @@ command_help(char *arg)
 	   dev xd[N[x]]:\n
 	   consdev {pc|com[0123]|com[0123]kbd|auto}\n
 	   modules {enabled|disabled}\n
+#ifndef SMALL
+	   menu (reenters boot menu, if defined in boot.cfg)\n
+#endif
 	   load {path_to_module}\n
 	   multiboot [xdNx:][filename] [args]\n
 	   help|?\n
@@ -740,10 +781,25 @@ void
 command_boot(char *arg)
 {
 	char *filename;
-	int howto;
+	int howto, tell;
 
-	if (parseboot(arg, filename, howto))
-		

CVS commit: [netbsd-5] src/sys/arch/i386/stand/boot

2010-02-14 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Feb 14 14:01:08 UTC 2010

Modified Files:
src/sys/arch/i386/stand/boot [netbsd-5]: boot2.c

Log Message:
Pull up following revision(s) (requested by hubertf in ticket #1304):
sys/arch/i386/stand/boot/boot2.c: revision 1.48
When a password is set for the bootloader (installboot -o password=...),
it currently complains about an unknown command and prints a usage if the
password is entered wrong:
 ...
 Choose an option; RETURN for default; SPACE to stop countdown.
 Option 1 will be chosen in 0 seconds.
 Password: *
 Password: *
 Password: *
 unknown command
 commands are:
 boot [xdNx:][filename] [-12acdqsvxz]
  (ex. hd0a:netbsd.old -s
 ls [path]
 dev xd[N[x]]:
 consdev {pc|com[0123]|com[0123]kbd|auto}
 modules {enabled|disabled}
 load {path_to_module}
 multiboot [xdNx:][filename] [args]
 help|?
 quit
 Choose an option; RETURN for default; SPACE to stop countdown.
 Option 1 will be chosen in 0 seconds.
 ...
This is confusing, plus someone may use it to determine bits of
information about the system. What should happen instead is that the user
is informed that the password is wrong:
 ...
 Choose an option; RETURN for default; SPACE to stop countdown.
 Option 1 will be chosen in 0 seconds.
 Password: 
 Password: 
 Password: 
 Wrong password.
 Choose an option; RETURN for default; SPACE to stop countdown.
 ...
Implement the latter behaviour.


To generate a diff of this commit:
cvs rdiff -u -r1.38.4.1 -r1.38.4.2 src/sys/arch/i386/stand/boot/boot2.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/i386/stand/boot/boot2.c
diff -u src/sys/arch/i386/stand/boot/boot2.c:1.38.4.1 src/sys/arch/i386/stand/boot/boot2.c:1.38.4.2
--- src/sys/arch/i386/stand/boot/boot2.c:1.38.4.1	Sun Oct 18 16:41:28 2009
+++ src/sys/arch/i386/stand/boot/boot2.c	Sun Feb 14 14:01:08 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot2.c,v 1.38.4.1 2009/10/18 16:41:28 bouyer Exp $	*/
+/*	$NetBSD: boot2.c,v 1.38.4.2 2010/02/14 14:01:08 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -664,11 +664,23 @@
 #else
 		c = awaitkey((bootconf.timeout  0) ? 0 : bootconf.timeout, 1);
 #endif
-		if ((c != '\r')  (c != '\n')  (c != '\0') 
-		((boot_params.bp_flags  X86_BP_FLAGS_PASSWORD) == 0
-		 || check_password(boot_params.bp_password))) {
-			printf(type \?\ or \help\ for help.\n);
+		if ((c != '\r')  (c != '\n')  (c != '\0')) {
+		if ((boot_params.bp_flags  X86_BP_FLAGS_PASSWORD) == 0) {
+			/* do NOT ask for password */
 			bootmenu(); /* does not return */
+		} else {
+			/* DO ask for password */
+			if (check_password(boot_params.bp_password)) {
+			/* password ok */
+			printf(type \?\ or \help\ for help.\n);
+			bootmenu(); /* does not return */
+			} else {
+			/* bad password */
+			printf(Wrong password.\n);
+			currname = 0;
+			continue;
+			}
+		}
 		}
 
 		/*



CVS commit: [netbsd-5] src/sys/arch/i386/stand/boot

2009-10-18 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Oct 18 16:41:28 UTC 2009

Modified Files:
src/sys/arch/i386/stand/boot [netbsd-5]: boot2.c

Log Message:
Apply patch, requested by snj in ticket 1080:
sys/arch/i386/stand/boot/boot2.c: patch

- If the menuformat is not letter, do not allow letter keys to be
aliases for number keys.
- Don't treat timeouts or the return key as an invalid choice.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.4.1 src/sys/arch/i386/stand/boot/boot2.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/i386/stand/boot/boot2.c
diff -u src/sys/arch/i386/stand/boot/boot2.c:1.38 src/sys/arch/i386/stand/boot/boot2.c:1.38.4.1
--- src/sys/arch/i386/stand/boot/boot2.c:1.38	Sat Oct 11 11:06:19 2008
+++ src/sys/arch/i386/stand/boot/boot2.c	Sun Oct 18 16:41:28 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot2.c,v 1.38 2008/10/11 11:06:19 joerg Exp $	*/
+/*	$NetBSD: boot2.c,v 1.38.4.1 2009/10/18 16:41:28 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -482,11 +482,15 @@
 
 static int getchoicefrominput(char *input, int def)
 {
-	int choice;
+	int choice, usedef;
+
 	choice = -1;
-	if (*input == '\0' || *input == '\r' || *input == '\n')
+	usedef = 0;
+
+	if (*input == '\0' || *input == '\r' || *input == '\n') {
 		choice = def;
-	else if (*input = 'A'  *input  bootconf.nummenu + 'A')
+		usedef = 1;
+	} else if (*input = 'A'  *input  bootconf.nummenu + 'A')
 		choice = (*input) - 'A';
 	else if (*input = 'a'  *input  bootconf.nummenu + 'a')
 		choice = (*input) - 'a';
@@ -495,6 +499,11 @@
 		if (choice  0 || choice = bootconf.nummenu)
 			choice = -1;
 	}
+
+	if (bootconf.menuformat != MENUFORMAT_LETTER 
+	!isnum(*input)  !usedef)
+		choice = -1;
+
 	return choice;
 }