bug-grub
[Top][All Lists]
Advanced

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

Patch... allows "configfile" command to load secondary configfile.


From: Michael Breuer
Subject: Patch... allows "configfile" command to load secondary configfile.
Date: Mon, 04 Mar 2002 13:22:49 -0500
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1

Attached is a small patch to grub 0.91 (I can't get into CVS from here). This patch allows the "configfile" and "root" commands to be embedded in a configfile. The patch also prevents "open_preset_menu" from returning true more than once (comments in stage2.c suggest that this cannot happen, but the "open_preset_menu" function did not behave as noted).

Note: Embedding "configfile" and "root" commands in a configfile allow for run-time determination of boot image based on external configuration files. In my case, I'm looking to load the "configfile" from a tftp server. The initial configfile (loaded from the local drive) configures the network card & tftp server (we don't support bootp or dhcp), then issues a configfile <nd>/..../configfile command to continue the boot process. Alternate config files may be selected depending on which tftp servers are accessible.




diff -urN grub-0.91/stage2/builtins.c grub-0.91.patched/stage2/builtins.c
--- grub-0.91/stage2/builtins.c Wed Jan  2 18:23:30 2002
+++ grub-0.91.patched/stage2/builtins.c Wed Feb 27 16:38:55 2002
@@ -751,7 +751,7 @@
 {
   "configfile",
   configfile_func,
-  BUILTIN_CMDLINE,
+  BUILTIN_MENU | BUILTIN_CMDLINE,
   "configfile FILE",
   "Load FILE as the configuration file."
 };
@@ -3030,7 +3030,7 @@
 {
   "root",
   root_func,
-  BUILTIN_CMDLINE,
+  BUILTIN_MENU | BUILTIN_CMDLINE,
   "root [DEVICE [HDBIAS]]",
   "Set the current \"root device\" to the device DEVICE, then"
   " attempt to mount it to get the partition size (for passing the"
diff -urN grub-0.91/stage2/stage2.c grub-0.91.patched/stage2/stage2.c
--- grub-0.91/stage2/stage2.c   Mon Jan  7 21:56:45 2002
+++ grub-0.91.patched/stage2/stage2.c   Mon Mar  4 13:00:28 2002
@@ -35,14 +35,17 @@
 static int
 open_preset_menu (void)
 {
+/* Preset menu can only be used on initial entry... we must force this */
+static int preset_used=0;
 #ifdef GRUB_UTIL
   /* Unless the user explicitly requests to use the preset menu,
      always opening the preset menu fails in the grub shell.  */
   if (! use_preset_menu)
     return 0;
 #endif /* GRUB_UTIL */
-  
   preset_menu_offset = 0;
+  if (preset_used) return 0;
+  preset_used=1;
   return preset_menu != 0;
 }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]