bug-hurd
[Top][All Lists]
Advanced

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

grub


From: Roland McGrath
Subject: grub
Date: Sat, 5 Feb 2005 14:20:25 -0800

Has anyone used grub2?  Is it usable yet?

I ask because I sent in patches for some useful features for grub, and
Okuji refused to put them in.  He says only grub2 will get new features.
That seems like a bad decision to me, since everyone is using grub 0.96 and
adding simple features there can be a real help to users.  

Here is a patch for grub that I think we really might want in the debian
version if the grub maintainers continue to refuse to take it in.  This
adds the `modulelist' command so that the multiboot module loading can be
used like we intended in the original genesis of the multiboot idea, rather
than the royal pain in the ass that is regularly biting every new Hurd user.

With this, we put the canonical script into /boot/servers.boot and instead
of everyone's grub config file copying the magic command lines, they just
use:

kernel /boot/gnumach
modulelist /boot/servers.boot


Thanks,
Roland


2004-09-15  Roland McGrath  <roland@frob.com>

        * stage2/builtins.c (modulelist_func, builtin_modulelist): New.
        (builtin_table): Include it.
        * stage2/stage2.c (get_line_from_config): Make global.
        * stage2/shared.h: Declare it.
        * docs/grub.texi: Document modulelist.

--- stage2/shared.h     15 Sep 2004 22:52:31 -0000
+++ stage2/shared.h     15 Sep 2004 23:40:03 -0000
@@ -914,6 +914,7 @@
 int safe_parse_maxint (char **str_ptr, int *myint_ptr);
 int memcheck (int start, int len);
 void grub_putstr (const char *str);
+int get_line_from_config (char *cmdline, int maxlen, int read_from_file);
 
 #ifndef NO_DECOMPRESSION
 /* Compression support. */
--- stage2/stage2.c     15 Sep 2004 22:52:31 -0000
+++ stage2/stage2.c     15 Sep 2004 23:40:03 -0000
@@ -767,7 +767,7 @@
 }
 
 
-static int
+int
 get_line_from_config (char *cmdline, int maxlen, int read_from_file)
 {
   int pos = 0, literal = 0, comment = 0;
--- docs/grub.texi      24 Jun 2004 17:04:32 -0000      1.83
+++ docs/grub.texi      15 Sep 2004 23:40:03 -0000
@@ -784,7 +784,8 @@ Load the kernel image with the command @
 
 @item
 If you need modules, load them with the command @command{module}
-(@pxref{module}) or @command{modulenounzip} (@pxref{modulenounzip}).
+(@pxref{module}) or @command{modulenounzip} (@pxref{modulenounzip}),
+or from a list in a file (@pxref{modulelist}).
 
 @item
 Run the command @command{boot} (@pxref{boot}).
@@ -876,12 +877,12 @@ command @code{find /boot/gnumach} or sim
 (@pxref{find}).
 
 @item
-Load the kernel and the module, like this:
+Load the kernel and the standard modules, like this:
 
 @example
 @group
 grub> @kbd{kernel /boot/gnumach root=hd0s1}
-grub> @kbd{module /boot/serverboot}
+grub> @kbd{modulelist /boot/servers.boot}
 @end group
 @end example
 
@@ -1491,7 +1492,7 @@ Server: 192.168.110.14     Gateway: 192.
 
 grub> @kbd{root (nd)}
 grub> @kbd{kernel /tftproot/gnumach.gz root=sd0s1}
-grub> @kbd{module /tftproot/serverboot.gz}
+grub> @kbd{modulelist /tftproot/servers.boot (hd0,1)}
 grub> @kbd{boot}
 @end group
 @end example
@@ -2681,6 +2682,7 @@ you forget a command, you can run the co
 * md5crypt::                    Encrypt a password in MD5 format
 * module::                      Load a module
 * modulenounzip::               Load a module without decompression
+* modulelist::                 Load modules from a list in a file
 * pause::                       Wait for a key press
 * quit::                        Exit from the grub shell
 * reboot::                      Reboot your computer
@@ -3077,6 +3079,25 @@ decompression is disabled.
 @end deffn
 
 
+@node modulelist
+@subsection modulelist
+
+@deffn Command modulelist file [prefix]
+Read the text file @var{file} containing a list of modules to load.
+The file can contain comments and long lines continued by backslash,
+similar to the GRUB configuration file.  Once those are taken out,
+every nonempty line in the file is used as arguments to a
+@command{module} command.  (@pxref{module}.)
+
+If @var{prefix} is given, this string is prepended to each module file
+name before it is loaded from the filesystem.  However, the module
+strings delivered to the Multiboot kernel will not contain this
+prefix.  In this way you can use a generic file containing a standard
+list of module file names and argument strings, yet load those module
+files from someplace other than the root filesystem selected for GRUB.
+@end deffn
+
+
 @node pause
 @subsection pause
 
--- stage2/builtins.c   20 Jun 2004 13:48:46 -0000      1.149
+++ stage2/builtins.c   15 Sep 2004 23:40:03 -0000
@@ -2619,6 +2619,85 @@ static struct builtin builtin_module =
 };
 
 
+/* modulelist */
+static int
+modulelist_func (char *arg, int flags)
+{
+  char *const cmdline = (char *) CMDLINE_BUF;
+  int plen;
+  char *first, *p;
+
+  if (kernel_type != KERNEL_TYPE_MULTIBOOT)
+    {
+      errnum = ERR_NEED_MB_KERNEL;
+      return 1;
+    }
+
+  plen = 0;
+  for (p = arg; *p != '\0'; ++p)
+    if (*p == ' ' || *p == '\t')
+      {
+       do
+         *p++ = '\0';
+       while (*p == ' ' || *p == '\t');
+       plen = grub_strlen (p);
+       break;
+      }
+
+  if (! grub_open (arg))
+    return 1;
+
+  grub_memmove (cmdline, p, plen);
+  first = mb_cmdline;
+  while (get_line_from_config (cmdline + plen, NEW_HEAPSIZE - plen, 1))
+    {
+      int len = grub_strlen (cmdline + plen) + 1;
+      if (mb_cmdline + len > (char *) MB_CMDLINE_BUF + MB_CMDLINE_BUFLEN)
+       {
+         grub_close ();
+         errnum = ERR_WONT_FIT;
+         return 1;
+       }
+      grub_memmove (mb_cmdline, cmdline + plen, len);
+      mb_cmdline += len;
+    }
+
+  grub_close ();
+
+  /* Now we have filled up the mb_cmdline buffer, go through and
+     load all the modules.  */
+  p = first;
+  while (p < mb_cmdline)
+    {
+      int len = grub_strlen (p) + 1;
+      char *q = cmdline + plen, *s = p;
+      while (*s != '\0' && *s != ' ' && *s != '\t')
+       *q++ = *s++;
+      *q = '\0';
+      if (plen > 0)
+       grub_printf (" file %s: module %s\n", cmdline, p);
+      else
+       grub_printf (" module %s\n", p);
+      if (! load_module (cmdline, p))
+       return 1;
+      p += len;
+    }
+
+  return 0;
+}
+
+static struct builtin builtin_modulelist =
+{
+  "modulelist",
+  modulelist_func,
+  BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
+  "modulelist FILE [PREFIX]",
+  "Load boot modules named on lines in FILE for a Multiboot format boot image."
+  " Comments and blank lines are ignored and \\ continues long lines in FILE"
+  " as in config files.  Then for each line, a \"module LINE\" command is run."
+  " If PREFIX is given, it is prepended to each file name taken from FILE."
+};
+
 /* modulenounzip */
 static int
 modulenounzip_func (char *arg, int flags)
@@ -4830,6 +4909,7 @@ struct builtin *builtin_table[] =
   &builtin_md5crypt,
 #endif /* USE_MD5_PASSWORDS */
   &builtin_module,
+  &builtin_modulelist,
   &builtin_modulenounzip,
   &builtin_pager,
   &builtin_partnew,




reply via email to

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