Port-i386 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Patch for boot loader: "menu" command



> On Thu, Jul 25, 2013 at 02:24:29PM +0200, Havard Eidnes wrote:
>> Now, there are probably several ways to go around mending this.
>> Some of them are:
>>
>> 1) provide a way to display the contents of boot.cfg (but need to
>>    prevent showing the "contents of /netbsd"...)
>> 2) provide a way to recall and edit one of the boot commands from
>>    boot.cfg (sounds complicated, and more than I intended to chew
>>    off in this round)
>> 3) provide a way to re-enter the boot menu you dropped from in
>>    the first step in the procedure above, and then allow to
>>    select one of the boot methods already specified in boot.cfg
>
> How about change "boot" to use whatever boot.cfg says is the default
> boot option, and "boot ...anything..." to be the override-the-menu
> command?

How does the attached look?  It should implement the suggested idea.

Regards,

- Håvard
? boot/boot2.c.menu
Index: boot/boot2.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/boot/boot2.c,v
retrieving revision 1.58
diff -u -r1.58 boot2.c
--- boot/boot2.c        4 Aug 2012 03:51:27 -0000       1.58
+++ boot/boot2.c        25 Jul 2013 23:06:28 -0000
@@ -439,6 +439,11 @@
                bootit(filename, howto, tell);
        } else {
                int i;
+
+#ifndef SMALL
+               if (bootconf.nummenu > 0)
+                       bootdefault();
+#endif
                for (i = 0; i < NUMNAMES; i++) {
                        bootit(names[i][0], howto, tell);
                        bootit(names[i][1], howto, tell);
Index: lib/bootmenu.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/lib/bootmenu.c,v
retrieving revision 1.10
diff -u -r1.10 bootmenu.c
--- lib/bootmenu.c      18 Aug 2011 13:20:04 -0000      1.10
+++ lib/bootmenu.c      25 Jul 2013 23:06:28 -0000
@@ -41,6 +41,8 @@
 
 #define isnum(c) ((c) >= '0' && (c) <= '9')
 
+static void docommandchoice(int);
+
 extern struct x86_boot_params boot_params;
 extern const char bootprog_name[], bootprog_rev[], bootprog_kernrev[];
 
@@ -297,11 +299,47 @@
        return choice;
 }
 
+static 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)
+{
+
+       if (bootconf.nummenu > 0)
+               docommandchoice(bootconf.def);
+}
+
 void
 doboottypemenu(void)
 {
        int choice;
-       char input[80], *ic, *oc;
+       char input[80];
 
        printf("\n");
        /* Display menu */
@@ -357,27 +395,7 @@
                        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);
                }
 
        }
Index: lib/bootmenu.h
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/lib/bootmenu.h,v
retrieving revision 1.2
diff -u -r1.2 bootmenu.h
--- lib/bootmenu.h      13 Dec 2008 23:30:54 -0000      1.2
+++ lib/bootmenu.h      25 Jul 2013 23:06:28 -0000
@@ -36,6 +36,7 @@
 
 void parsebootconf(const char *);
 void doboottypemenu(void);
+void bootdefault(void);
 int atoi(const char *);
 
 struct bootconf_def {


Home | Main Index | Thread Index | Old Index