[Top][All Lists]

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

Re: Getting rid of serverboot

From: Neal H Walfield
Subject: Re: Getting rid of serverboot
Date: Thu, 23 Aug 2001 14:57:50 +0200
User-agent: Mutt/1.3.18i

> I've committed the hurd changes I described earlier, which need testing.

All basically works well, however, there are a few tweaks that I think
are worthwhile.

First, I have not yet written the code to break up the multiboot command
line into var=arg pairs, however, I did a small modification so that we
fill in the root boot script variable and not root-device in the
(new) serverboot-less case.

Also, when loading the modules, Mach will now print the module string to
indicating what module it is executing.  This is important as we will
now be able to differentiate mach hangs and ext2fs.static et al dying
(currently, the last message on the screen in the detection of com ports
and this can be quite confusing).

Here is a change log entry for this:

2001-08-22  Neal H Walfield  <neal@cs.uml.edu>

        * kern/bootstrap.c (bootstrap_create): Fill in the bootstrap
        variable root, not root-device.
        Print the module's string when loading it.


I have added a compatibility flag to ext2fs.static so that we can
continue to use bootflags (i.e. it is a hidden alias).  This permits the
compatibility mode to work without any modification.

There was also a bug in the new option handling code.


2001-08-22  Neal H Walfield  <neal@cs.uml.edu>

        * opts-std-startup.c (startup_options): New compatibility
        option: bootflags, a hidden alias to multi-boot-command-line.
        (parse_startup_opt): Bug fix.

> The changes are in diskfs to replace --bootflags with 
> --multiboot-command-line,
> to replace the -i/-d bootflags switches with the --boot-init-program and
> --boot-debug-pause options respectively, and to pass the chopped-up
> command line words as arguments to init instead of passing bootflags.
> In init, removed -K and made it instead expect its arguments to form the
> kernel command line, and made it pass its arguments to runsystem.
> In runsystem, made it expect those arguments instead of ${MULTIBOOT_CMDLINE}.

init also needed a few changes.  First of all, as init now receives the
entire multiboot command line and it is suppose to pass it on to the
startup scripts, it must not fail when parsing the arguments; rather,
it must just ignore anything that it does not understand.

Also, it would be nice to be able to see any output.  Therefore, I
propose that we initialize the standard streams before parsing the
arguments.  It would be nice to be able to do this in libdiskfs also,
however, we have a slight problem as the device master port is in the
arguments itself.  I need to give this a bit more thought; suggestions
are welcome.


2001-08-22  Neal H Walfield  <neal@cs.uml.edu>

        * init.c (main): Be sure that we have a console before we try to
        do anything.
        When calling argp_parse, pass in ARGP_NO_ERRS|ARGP_NO_EXIT as we
        are expecting a multiboot command line and we will most surely
        not recognize all of the arguments.

> Please test that a newly built hurd with an updated boot script still works
> with boot (sub-hurd) and serverboot, as well as the new kernel boot script
> support.  Be sure to check with ps that the kernel command line shows up 
> right.

In order to boot in a subhurd, I had to make a few changes to the option
parsing and the boot script variables, i.e. they need to be updated to
use the new nomenclature.


2001-08-22  Neal H Walfield  <neal@cs.uml.edu>

        * boot.c (options): Rename pause to boot-debug-pause.
        (main): Do not set the boot script variable root-device, set
        root.  Likewise, set kernel-command-line, not boot-args.
        When failing, be a bit cleaner when outputting the error

> Probably we should add an option to boot to set ${kernel-command-line},
> and set it by default based on boot's own args ("$argv[0] -s root=foobar").

This would be nice, however, the libstore parser currently consumes all
of the arguments (it assumes that they are all stores meant to be
concatenated); thus, this would first have to first be changed.

Index: bootstrap.c
RCS file: /cvs/gnumach/kern/bootstrap.c,v
retrieving revision
diff -u -p -r1.3.2.9 bootstrap.c
--- bootstrap.c 2001/08/20 22:16:53
+++ bootstrap.c 2001/08/23 12:03:05
@@ -171,24 +171,27 @@ void bootstrap_create()
        if (losers)
          panic ("cannot set boot-script variable %s: %s",
                 "boot-args", boot_script_error_string (losers));
-       losers = boot_script_set_variable ("root-device", VAL_STR,
+       losers = boot_script_set_variable ("root", VAL_STR,
                                           (int) root_string);
        if (losers)
          panic ("cannot set boot-script variable %s: %s",
-                "root-device", boot_script_error_string (losers));
+                "root", boot_script_error_string (losers));
       for (i = 0; i < boot_info.mods_count; ++i)
          char *line = (char*)phystokv(bmods[i].string);
-         int err = boot_script_parse_line (&bmods[i], line);
+         int err;
+         printf ("Executing %s", line);
+         err = boot_script_parse_line (&bmods[i], line);
          if (err)
-             printf ("ERROR: %s in multiboot module string: %s\n",
-                     boot_script_error_string (err), line);
+             printf (": ERROR: %s", boot_script_error_string (err));
+         printf ("\n");
       if (losers)
        panic ("%d of %d boot script commands could not be parsed",
@@ -605,7 +608,7 @@ user_bootstrap_compat()
         * Argument list is
         * "bootstrap -<boothowto> <host_port> <device_port> <root_name>"
-$0 ${boot-args} ${host-port} ${device-port} ${root-device} $(task-create) 
+$0 ${boot-args} ${host-port} ${device-port} ${root} $(task-create) 

Index: libdiskfs/opts-std-startup.c
RCS file: /cvs/hurd/libdiskfs/opts-std-startup.c,v
retrieving revision 1.18
diff -u -p -r1.18 opts-std-startup.c
--- libdiskfs/opts-std-startup.c        2001/08/20 22:41:04     1.18
+++ libdiskfs/opts-std-startup.c        2001/08/23 12:03:36
@@ -55,6 +55,7 @@ startup_options[] =
   {0,0,0,0, "Boot options:", -2},
   {"multiboot-command-line", OPT_BOOT_CMDLINE, "ARGS", 0,
    "Required for bootstrap filesystem, the multiboot kernel command line"},
+  {"bootflags", 0, 0, OPTION_ALIAS|OPTION_HIDDEN},
   {"boot-init-program",  OPT_BOOT_INIT_PROGRAM,  "FILE", 0,
    "For bootstrap filesystem, init program to run (default " _HURD_INIT ")"},
   {"boot-debug-pause",  OPT_BOOT_PAUSE,                 0, 0,
@@ -106,7 +107,7 @@ parse_startup_opt (int opt, char *arg, s
       diskfs_boot_init_program = arg; break;
     case OPT_BOOT_PAUSE:
-      _diskfs_boot_pause = 1;
+      _diskfs_boot_pause = 1; break;
     case 'C':
       _diskfs_chroot_directory = arg; break;
Index: init.c
RCS file: /cvs/hurd/init/init.c,v
retrieving revision 1.125
diff -u -p -r1.125 init.c
--- init.c      2001/08/20 23:13:15     1.125
+++ init.c      2001/08/23 12:40:24
@@ -517,35 +517,43 @@ int
 main (int argc, char **argv, char **envp)
   volatile int err;
+  int systemsinit;
   int i;
   mach_port_t consdev;
   struct argp argp = { options, parse_opt, 0, doc };
+  systemsinit = (getpid () == 0);
+  if (systemsinit)
+    /* We were run by the boot strap filesystem; the first thing we need
+       todo is get a console.  */
+    {
+      /* Fetch a port to the bootstrap filesystem, the host priv and
+        master device ports, and the console.  */
+      if (task_get_bootstrap_port (mach_task_self (), &bootport)
+         || fsys_getpriv (bootport, &host_priv, &device_master, &fstask)
+         || device_open (device_master, D_WRITE, "console", &consdev))
+       crash_mach ();
+      wire_task_self ();
+      /* Clear our bootstrap port so our children don't inherit it.  */
+      task_set_bootstrap_port (mach_task_self (), MACH_PORT_NULL);
+      stderr = stdout = mach_open_devstream (consdev, "w");
+      stdin = mach_open_devstream (consdev, "r");
+      if (stdout == NULL || stdin == NULL)
+       crash_mach ();
+      setbuf (stdout, NULL);
+    }
   /* Parse the arguments */
-  argp_parse (&argp, argc, argv, 0, 0, 0);
+  argp_parse (&argp, argc, argv, ARGP_NO_ERRS|ARGP_NO_EXIT, 0, 0);
-  if (getpid () > 0)
+  if (! systemsinit)
     error (2, 0, "can only be run by bootstrap filesystem");
   global_argv = argv;
-  /* Fetch a port to the bootstrap filesystem, the host priv and
-     master device ports, and the console.  */
-  if (task_get_bootstrap_port (mach_task_self (), &bootport)
-      || fsys_getpriv (bootport, &host_priv, &device_master, &fstask)
-      || device_open (device_master, D_WRITE, "console", &consdev))
-    crash_mach ();
-  wire_task_self ();
-  /* Clear our bootstrap port so our children don't inherit it.  */
-  task_set_bootstrap_port (mach_task_self (), MACH_PORT_NULL);
-  stderr = stdout = mach_open_devstream (consdev, "w");
-  stdin = mach_open_devstream (consdev, "r");
-  if (stdout == NULL || stdin == NULL)
-    crash_mach ();
-  setbuf (stdout, NULL);
   err = argz_create (envp, &startup_envz, &startup_envz_len);
   assert_perror (err);
Index: boot/boot.c
RCS file: /cvs/hurd/boot/boot.c,v
retrieving revision 1.100
diff -u -p -r1.100 boot.c
--- boot/boot.c 2001/08/17 04:47:55     1.100
+++ boot/boot.c 2001/08/23 12:03:31
@@ -398,7 +398,7 @@ static struct argp_option options[] =
     "Root of a directory tree in which to find files specified in BOOT-SCRIPT" 
   { "single-user", 's', 0, 0,
     "Boot in single user mode" },
-  { "pause" ,      'd', 0, 0,
+  { "boot-debug-pause" ,      'd', 0, 0,
     "Pause for user confirmation at various times during booting" },
   { "isig",      'I', 0, 0,
     "Do not disable terminal signals, so you can suspend and interrupt boot."},
@@ -516,8 +516,9 @@ main (int argc, char **argv, char **envp
                                (int) privileged_host_port)
       || boot_script_set_variable ("device-port", VAL_PORT,
                                   (int) pseudo_master_device_port)
-      || boot_script_set_variable ("root-device", VAL_STR, (int) bootdevice)
-      || boot_script_set_variable ("boot-args", VAL_STR, (int) bootstrap_args))
+      || boot_script_set_variable ("kernel-command-line", VAL_STR,
+                                  (int) bootstrap_args)
+      || boot_script_set_variable ("root", VAL_STR, (int) bootdevice))
       static const char msg[] = "error setting variable";
@@ -612,10 +613,11 @@ main (int argc, char **argv, char **envp
     err = boot_script_exec ();
     if (err)
-       char *str = boot_script_error_string (err);
-       int i = strlen (str);
+       char buf[1024];
-       write (2, str, i);
+       snprintf (buf, sizeof (buf) - 1, "boot_script_exec: %s\n", 
+                 boot_script_error_string (err));
+       write (2, buf, strlen (buf));
        host_exit (1);
     free (buf);

Attachment: pgpdtwO5MRZUt.pgp
Description: PGP signature

reply via email to

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