[comp.os.minix] PC 1.5.0 execn.c fix

cwr@pnet01.cts.com (Will Rose) (02/05/90)

When writing a ps command for 1.5.0, I found that the kernel name pointer
for files exec'd by init was not zero, as I expected, but garbage.  To save
space, init uses a libc.a routine execn.s to exec things; as far as I can
find, it's the only user of this routine.  Below is a new version of execn.c
(the patch was longer than the file) that sets up the kernel name pointer
correctly, and takes up very little more space.
 
Will Rose
 
============================= cut here ================================
echo x - execn.c
sed '/^X/s///' > execn.c << '/'
X/* execn.c:  passes only filename on the stack - Jan 90 */ 
X
X#include <lib.h>
X#define        PTRSIZE sizeof(char *)
X
Xint execn(name)
Xchar *name;                    /* pointer to file to be exec'd */
X{
X/* Special version used when there is one arg and no environment.  This call
X * is used by INIT, to avoid having to allocate ARG_MAX.  The single
X * name argument is used by the process status command.
X */
X
X  PRIVATE char stack[PTRSIZE * 16] ; /* ACK won't auto init ? */
X  PRIVATE char **cpp = (char **) stack;
X
X  *cpp++ = (char *) 1;                 /* argc */
X  *cpp++ = (char *) (PTRSIZE * 5);     /* *argv[0] */
X  *cpp++ = 0;
X  *cpp++ = 0;
X  *cpp = 0;
X
X  strcpy(stack + (PTRSIZE * 5), name); /* nb. known source, no overwrite
check */
X
X  return(callm1(MM_PROC_NR, EXEC, len(name), sizeof(stack), 0, name, stack,
NIL_PTR));
X}
/
-----------------------------------------------------------------------
"If heaven too had passions  | Will Rose
     even heaven would       | UUCP: {nosc ucsd hplabs!hp-sdd}!crash!pnet01!cw
     grow old."  -  Li Ho.   | ARPA: crash!pnet01!cwr@nosc.mil
                             | INET: cwr@pnet01.cts.com


UUCP: {nosc ucsd hplabs!hp-sdd}!crash!pnet01!cwr
ARPA: crash!pnet01!cwr@nosc.mil
INET: cwr@pnet01.cts.com