- for (dp = bfreelist; dp < &bfreelist[BQUEUES]; dp++) {
- dp->b_forw = dp->b_back = dp->av_forw = dp->av_back = dp;
- dp->b_flags = B_HEAD;
- }
- base = bufpages / nbuf;
- residual = bufpages % nbuf;
- for (i = 0; i < nbuf; i++) {
- bp = &buf[i];
- bp->b_dev = NODEV;
- bp->b_bcount = 0;
- bp->b_rcred = NOCRED;
- bp->b_wcred = NOCRED;
- bp->b_dirtyoff = 0;
- bp->b_dirtyend = 0;
- bp->b_un.b_addr = buffers + i * MAXBSIZE;
- if (i < residual)
- bp->b_bufsize = (base + 1) * CLBYTES;
- else
- bp->b_bufsize = base * CLBYTES;
- binshash(bp, &bfreelist[BQ_AGE]);
- bp->b_flags = B_BUSY|B_INVAL;
- brelse(bp);
+ /*
+ * Need just enough stack to hold the faked-up "execve()" arguments.
+ */
+ addr = trunc_page(VM_MAX_ADDRESS - PAGE_SIZE);
+ if (vm_allocate(&p->p_vmspace->vm_map, &addr, PAGE_SIZE, FALSE) != 0)
+ panic("init: couldn't allocate argument space");
+ p->p_vmspace->vm_maxsaddr = (caddr_t)addr;
+
+ for (pathp = &initpaths[0]; (path = *pathp) != NULL; pathp++) {
+ /*
+ * Construct the boot flag argument.
+ */
+ options = 0;
+ flagsp = flags + 1;
+ ucp = (char *)USRSTACK;
+ if (boothowto & RB_SINGLE) {
+ *flagsp++ = 's';
+ options = 1;
+ }
+#ifdef notyet
+ if (boothowto & RB_FASTBOOT) {
+ *flagsp++ = 'f';
+ options = 1;
+ }
+#endif
+ /*
+ * Move out the flags (arg 1), if necessary.
+ */
+ if (options != 0) {
+ *flagsp++ = '\0';
+ i = flagsp - flags;
+ (void)copyout((caddr_t)flags, (caddr_t)(ucp -= i), i);
+ arg1 = ucp;
+ }
+
+ /*
+ * Move out the file name (also arg 0).
+ */
+ i = strlen(path) + 1;
+ (void)copyout((caddr_t)path, (caddr_t)(ucp -= i), i);
+ arg0 = ucp;
+
+ /*
+ * Move out the arg pointers.
+ */
+ uap = (char **)((long)ucp & ~ALIGNBYTES);
+ (void)suword((caddr_t)--uap, 0); /* terminator */
+ if (options != 0)
+ (void)suword((caddr_t)--uap, (long)arg1);
+ (void)suword((caddr_t)--uap, (long)arg0);
+
+ /*
+ * Point at the arguments.
+ */
+ SCARG(&args, path) = arg0;
+ SCARG(&args, argp) = uap;
+ SCARG(&args, envp) = NULL;
+
+ /*
+ * Now try to exec the program. If can't for any reason
+ * other than it doesn't exist, complain.
+ */
+ if ((error = execve(p, &args, retval)) == 0)
+ return;
+ if (error != ENOENT)
+ printf("exec %s: error %d\n", path, error);