From 600927014b78e4247e36bbc554c188c7a3cca40e Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 21 Sep 1995 04:01:40 +0000 Subject: Wed Sep 20 18:02:03 1995 Roland McGrath * locale/locale.c: Include errno.h. * locale/localedef.c: Likewise. Tue Sep 19 00:02:06 1995 Roland McGrath * Makefile (distclean-1): Remove config.cache, config.log, config.h. (parent-mostlyclean): Remove all flavors of the parent library. * misc/mntent.c (getmntent): Skip multiple whitespace chars between fields. * hurd/hurdstartup.c (_hurd_startup): If RPC returns EXEC_STACK_ARGS flag, get args from stack. If args on stack but have info from RPC, relocate args on stack to make space for struct hurd_startup_data. * elf/dl-object.c: Include errno.h. * posix/execvp.c: Likewise. * dirent/scandir.c: Likewise. * sysdeps/posix/system.c: Likewise. * sysdeps/generic/setenv.c: Likewise. * stdlib/msort.c: Likewise. * stdio/memstream.c: Likewise. * stdio/fclose.c: Likewise. * stdio/getdelim.c: Likewise. * stdio/setvbuf.c: Likewise. * sysdeps/ieee754/ldexp.c: Likewise. * locale/locfile-parse.c: Likewise. * stdlib/lcong48_r.c: Don't check for null argument; let it fault. * stdlib/seed48_r.c: Likewise. * stdlib/srand48_r.c: Likewise. * stdlib/jrand48_r.c: Likewise. * stdlib/nrand48_r.c: Likewise. * misc/search.h: Many decls for hsearch functions. --- hurd/hurdstartup.c | 63 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 21 deletions(-) (limited to 'hurd/hurdstartup.c') diff --git a/hurd/hurdstartup.c b/hurd/hurdstartup.c index 61b8cdf42b..28ce40bbed 100644 --- a/hurd/hurdstartup.c +++ b/hurd/hurdstartup.c @@ -99,13 +99,13 @@ _hurd_startup (void **argptr, void (*main) (int *data)) __mach_port_deallocate (__mach_task_self (), in_bootstrap); } - if (err || in_bootstrap == MACH_PORT_NULL) + if (err || in_bootstrap == MACH_PORT_NULL || (data.flags & EXEC_STACK_ARGS)) { /* Either we have no bootstrap port, or the RPC to the exec server - failed. Try to snarf the args in the canonical Mach way. + failed, or whoever started us up passed the flag saying args are + on the stack. Try to snarf the args in the canonical Mach way. Hopefully either they will be on the stack as expected, or the - stack will be zeros so we don't crash. Set all our other - variables to have empty information. */ + stack will be zeros so we don't crash. */ argcptr = (int *) argptr; argc = argcptr[0]; @@ -114,26 +114,12 @@ _hurd_startup (void **argptr, void (*main) (int *data)) envc = 0; while (envp[envc]) ++envc; - - data.flags = 0; - args = env = NULL; - argslen = envlen = 0; - data.dtable = NULL; - data.dtablesize = 0; - data.portarray = NULL; - data.portarraysize = 0; - data.intarray = NULL; - data.intarraysize = 0; } else - argv = envp = NULL; - - - /* Turn the block of null-separated strings we were passed for the - arguments and environment into vectors of pointers to strings. */ - - if (! argv) { + /* Turn the block of null-separated strings we were passed for the + arguments and environment into vectors of pointers to strings. */ + /* Count up the arguments so we can allocate ARGV. */ argc = _hurd_split_args (args, argslen, NULL); /* Count up the environment variables so we can allocate ENVP. */ @@ -155,6 +141,41 @@ _hurd_startup (void **argptr, void (*main) (int *data)) _hurd_split_args (env, envlen, envp); } + if (err || in_bootstrap == MACH_PORT_NULL) + { + /* Either we have no bootstrap port, or the RPC to the exec server + failed. Set all our other variables to have empty information. */ + + data.flags = 0; + args = env = NULL; + argslen = envlen = 0; + data.dtable = NULL; + data.dtablesize = 0; + data.portarray = NULL; + data.portarraysize = 0; + data.intarray = NULL; + data.intarraysize = 0; + } + else if ((void *) &envp[envc + 1] == argv[0]) + { + /* The arguments arrived on the stack from the kernel, but our + protocol requires some space after them for a `struct + hurd_startup_data'. Move them. */ + struct + { + int count; + char *argv[argc + 1]; + char *envp[envc + 1]; + struct hurd_startup_data data; + } *args = alloca (sizeof *args); + if ((void *) &args[1] == (void *) argcptr) + args = alloca (-((char *) &args->data - (char *) args)); + memmove (args, argcptr, (char *) &args->data - (char *) args); + argcptr = (void *) args; + argv = args->argv; + envp = args->envp; + } + { struct hurd_startup_data *d = (void *) &envp[envc + 1]; -- cgit v1.2.3