From e51ac98a35560a32cc26eab30569c3a3d157fb29 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 24 Aug 2001 21:30:05 +0000 Subject: 2001-08-24 Roland McGrath * kern/bootstrap.c (bootstrap_create): Make setting of boot-args and root-device no longer conditional on [! OSKIT_MACH]. (bootstrap_create) [! OSKIT_MACH]: Parse FOO=BAR words out of the multiboot command line and turn those into boot script variables. --- kern/bootstrap.c | 61 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 18 deletions(-) (limited to 'kern/bootstrap.c') diff --git a/kern/bootstrap.c b/kern/bootstrap.c index c0de921..a504115 100644 --- a/kern/bootstrap.c +++ b/kern/bootstrap.c @@ -135,6 +135,31 @@ void bootstrap_create() panic ("cannot set boot-script variable %s: %s", "kernel-command-line", boot_script_error_string (losers)); + { + /* Set the same boot script variables that the old Hurd's + serverboot did, so an old Hurd and boot script previously + used with serverboot can be used directly with this kernel. */ + + char *flag_string = alloca(1024); + char *root_string = alloca(1024); + + /* + * Get the (compatibility) boot flags and root name strings. + */ + get_compat_strings(flag_string, root_string); + + losers = boot_script_set_variable ("boot-args", VAL_STR, + (int) flag_string); + 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, + (int) root_string); + if (losers) + panic ("cannot set boot-script variable %s: %s", + "root-device", boot_script_error_string (losers)); + } + #if OSKIT_MACH { /* The oskit's "environ" array contains all the words from @@ -158,24 +183,24 @@ void bootstrap_create() } #else /* GNUmach, not oskit-mach */ { - char *flag_string = alloca(1024); - char *root_string = alloca(1024); - - /* - * Get the (compatibility) boot flags and root name strings. - */ - get_compat_strings(flag_string, root_string); - - losers = boot_script_set_variable ("boot-args", VAL_STR, - (int) flag_string); - 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, - (int) root_string); - if (losers) - panic ("cannot set boot-script variable %s: %s", - "root-device", boot_script_error_string (losers)); + /* Turn each `FOO=BAR' word in the command line into a boot script + variable ${FOO} with value BAR. This matches what we get from + oskit's environ in the oskit-mach case (above). */ + + int len = strlen (kernel_cmdline) + 1; + char *s = memcpy (alloca (len), kernel_cmdline, len); + char *word; + while ((word = strsep (&s, " \t")) != 0) + { + char *eq = strchr (word, '='); + if (eq == 0) + continue; + *eq++ = '\0'; + losers = boot_script_set_variable (word, VAL_STR, (int) eq); + if (losers) + panic ("cannot set boot-script variable %s: %s", + word, boot_script_error_string (losers)); + } } #endif -- cgit v1.2.3