init_main.c revision 1.209 1 /* $NetBSD: init_main.c,v 1.209 2002/10/23 09:14:12 jdolecek Exp $ */
2
3 /*
4 * Copyright (c) 1995 Christopher G. Demetriou. All rights reserved.
5 * Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993
6 * The Regents of the University of California. All rights reserved.
7 * (c) UNIX System Laboratories, Inc.
8 * All or some portions of this file are derived from material licensed
9 * to the University of California by American Telephone and Telegraph
10 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
11 * the permission of UNIX System Laboratories, Inc.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by the University of
24 * California, Berkeley and its contributors.
25 * 4. Neither the name of the University nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.
40 *
41 * @(#)init_main.c 8.16 (Berkeley) 5/14/95
42 */
43
44 #include <sys/cdefs.h>
45 __KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.209 2002/10/23 09:14:12 jdolecek Exp $");
46
47 #include "fs_nfs.h"
48 #include "opt_nfsserver.h"
49 #include "opt_sysv.h"
50 #include "opt_maxuprc.h"
51 #include "opt_multiprocessor.h"
52 #include "opt_pipe.h"
53 #include "opt_syscall_debug.h"
54 #include "opt_systrace.h"
55
56 #include "rnd.h"
57
58 #include <sys/param.h>
59 #include <sys/acct.h>
60 #include <sys/filedesc.h>
61 #include <sys/file.h>
62 #include <sys/errno.h>
63 #include <sys/callout.h>
64 #include <sys/kernel.h>
65 #include <sys/mount.h>
66 #include <sys/proc.h>
67 #include <sys/kthread.h>
68 #include <sys/resourcevar.h>
69 #include <sys/signalvar.h>
70 #include <sys/systm.h>
71 #include <sys/vnode.h>
72 #include <sys/tty.h>
73 #include <sys/conf.h>
74 #include <sys/disklabel.h>
75 #include <sys/buf.h>
76 #include <sys/device.h>
77 #include <sys/disk.h>
78 #include <sys/exec.h>
79 #include <sys/socketvar.h>
80 #include <sys/protosw.h>
81 #include <sys/reboot.h>
82 #include <sys/user.h>
83 #include <sys/sysctl.h>
84 #include <sys/event.h>
85 #ifdef SYSVSHM
86 #include <sys/shm.h>
87 #endif
88 #ifdef SYSVSEM
89 #include <sys/sem.h>
90 #endif
91 #ifdef SYSVMSG
92 #include <sys/msg.h>
93 #endif
94 #ifdef SYSTRACE
95 #include <sys/systrace.h>
96 #endif
97 #include <sys/domain.h>
98 #include <sys/mbuf.h>
99 #include <sys/namei.h>
100 #if NRND > 0
101 #include <sys/rnd.h>
102 #endif
103 #ifndef PIPE_SOCKETPAIR
104 #include <sys/pipe.h>
105 #endif
106
107 #include <sys/syscall.h>
108 #include <sys/syscallargs.h>
109
110 #include <ufs/ufs/quota.h>
111
112 #include <miscfs/genfs/genfs.h>
113 #include <miscfs/syncfs/syncfs.h>
114
115 #include <machine/cpu.h>
116
117 #include <uvm/uvm.h>
118
119 #include <dev/cons.h>
120
121 #include <net/if.h>
122 #include <net/raw_cb.h>
123
124 const char copyright[] =
125 "Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002\n"
126 " The NetBSD Foundation, Inc. All rights reserved.\n"
127 "Copyright (c) 1982, 1986, 1989, 1991, 1993\n"
128 " The Regents of the University of California. All rights reserved.\n"
129 "\n";
130
131 /* Components of the first process -- never freed. */
132 struct session session0;
133 struct pgrp pgrp0;
134 struct proc proc0;
135 struct pcred cred0;
136 struct filedesc0 filedesc0;
137 struct cwdinfo cwdi0;
138 struct plimit limit0;
139 struct vmspace vmspace0;
140 struct sigacts sigacts0;
141 #ifndef curproc
142 struct proc *curproc = &proc0;
143 #endif
144 struct proc *initproc;
145
146 int cmask = CMASK;
147 extern struct user *proc0paddr;
148
149 struct vnode *rootvp, *swapdev_vp;
150 int boothowto;
151 int cold = 1; /* still working on startup */
152 struct timeval boottime;
153
154 __volatile int start_init_exec; /* semaphore for start_init() */
155
156 static void check_console(struct proc *p);
157 static void start_init(void *);
158 void main(void);
159
160 extern const struct emul emul_netbsd; /* defined in kern_exec.c */
161
162 /*
163 * System startup; initialize the world, create process 0, mount root
164 * filesystem, and fork to create init and pagedaemon. Most of the
165 * hard work is done in the lower-level initialization routines including
166 * startup(), which does memory initialization and autoconfiguration.
167 */
168 void
169 main(void)
170 {
171 struct proc *p;
172 struct pdevinit *pdev;
173 int s, error;
174 u_int i;
175 rlim_t lim;
176 extern struct pdevinit pdevinit[];
177 extern void schedcpu(void *);
178 #if defined(NFSSERVER) || defined(NFS)
179 extern void nfs_init(void);
180 #endif
181 #ifdef NVNODE_IMPLICIT
182 int usevnodes;
183 #endif
184
185 /*
186 * Initialize the current process pointer (curproc) before
187 * any possible traps/probes to simplify trap processing.
188 */
189 simple_lock_init(&proc0.p_raslock);
190 p = &proc0;
191 curproc = p;
192 p->p_cpu = curcpu();
193 /*
194 * Attempt to find console and initialize
195 * in case of early panic or other messages.
196 */
197 consinit();
198 printf("%s", copyright);
199
200 KERNEL_LOCK_INIT();
201
202 uvm_init();
203
204 /* Do machine-dependent initialization. */
205 cpu_startup();
206
207 /* Initialize callouts. */
208 callout_startup();
209
210 /*
211 * Initialize mbuf's. Do this now because we might attempt to
212 * allocate mbufs or mbuf clusters during autoconfiguration.
213 */
214 mbinit();
215
216 /* Initialize kqueues. */
217 kqueue_init();
218
219 /* Initialize sockets. */
220 soinit();
221
222 /*
223 * The following 3 things must be done before autoconfiguration.
224 */
225 disk_init(); /* initialize disk list */
226 tty_init(); /* initialize tty list */
227 #if NRND > 0
228 rnd_init(); /* initialize RNG */
229 #endif
230
231 /* Initialize the sysctl subsystem. */
232 sysctl_init();
233
234 /*
235 * Initialize process and pgrp structures.
236 */
237 procinit();
238
239 /*
240 * Create process 0 (the swapper).
241 */
242 s = proclist_lock_write();
243 LIST_INSERT_HEAD(&allproc, p, p_list);
244 LIST_INSERT_HEAD(PIDHASH(p->p_pid), p, p_hash);
245 proclist_unlock_write(s);
246
247 p->p_pgrp = &pgrp0;
248 LIST_INSERT_HEAD(PGRPHASH(0), &pgrp0, pg_hash);
249 LIST_INIT(&pgrp0.pg_members);
250 LIST_INSERT_HEAD(&pgrp0.pg_members, p, p_pglist);
251
252 pgrp0.pg_session = &session0;
253 session0.s_count = 1;
254 session0.s_sid = p->p_pid;
255 session0.s_leader = p;
256
257 /*
258 * Set P_NOCLDWAIT so that kernel threads are reparented to
259 * init(8) when they exit. init(8) can easily wait them out
260 * for us.
261 */
262 p->p_flag = P_INMEM | P_SYSTEM | P_NOCLDWAIT;
263 p->p_stat = SONPROC;
264 p->p_nice = NZERO;
265 p->p_emul = &emul_netbsd;
266 #ifdef __HAVE_SYSCALL_INTERN
267 (*p->p_emul->e_syscall_intern)(p);
268 #endif
269 strncpy(p->p_comm, "swapper", MAXCOMLEN);
270
271 callout_init(&p->p_realit_ch);
272 callout_init(&p->p_tsleep_ch);
273
274 /* Create credentials. */
275 cred0.p_refcnt = 1;
276 p->p_cred = &cred0;
277 p->p_ucred = crget();
278 p->p_ucred->cr_ngroups = 1; /* group 0 */
279
280 /* Create the file descriptor table. */
281 finit();
282 p->p_fd = &filedesc0.fd_fd;
283 fdinit1(&filedesc0);
284
285 /* Create the CWD info. */
286 p->p_cwdi = &cwdi0;
287 cwdi0.cwdi_cmask = cmask;
288 cwdi0.cwdi_refcnt = 1;
289
290 /* Create the limits structures. */
291 p->p_limit = &limit0;
292 for (i = 0; i < sizeof(p->p_rlimit)/sizeof(p->p_rlimit[0]); i++)
293 limit0.pl_rlimit[i].rlim_cur =
294 limit0.pl_rlimit[i].rlim_max = RLIM_INFINITY;
295
296 limit0.pl_rlimit[RLIMIT_NOFILE].rlim_max = maxfiles;
297 limit0.pl_rlimit[RLIMIT_NOFILE].rlim_cur =
298 maxfiles < NOFILE ? maxfiles : NOFILE;
299
300 limit0.pl_rlimit[RLIMIT_NPROC].rlim_max = maxproc;
301 limit0.pl_rlimit[RLIMIT_NPROC].rlim_cur =
302 maxproc < MAXUPRC ? maxproc : MAXUPRC;
303
304 lim = ptoa(uvmexp.free);
305 limit0.pl_rlimit[RLIMIT_RSS].rlim_max = lim;
306 limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_max = lim;
307 limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = lim / 3;
308 limit0.pl_corename = defcorename;
309 limit0.p_refcnt = 1;
310
311 /*
312 * Initialize proc0's vmspace, which uses the kernel pmap.
313 * All kernel processes (which never have user space mappings)
314 * share proc0's vmspace, and thus, the kernel pmap.
315 */
316 uvmspace_init(&vmspace0, pmap_kernel(), round_page(VM_MIN_ADDRESS),
317 trunc_page(VM_MAX_ADDRESS));
318 p->p_vmspace = &vmspace0;
319
320 p->p_addr = proc0paddr; /* XXX */
321
322 /*
323 * We continue to place resource usage info in the
324 * user struct so they're pageable.
325 */
326 p->p_stats = &p->p_addr->u_stats;
327
328 /*
329 * Charge root for one process.
330 */
331 (void)chgproccnt(0, 1);
332
333 rqinit();
334
335 /* Configure virtual memory system, set vm rlimits. */
336 uvm_init_limits(p);
337
338 /* Initialize the file systems. */
339 #if defined(NFSSERVER) || defined(NFS)
340 nfs_init(); /* initialize server/shared data */
341 #endif
342 #ifdef NVNODE_IMPLICIT
343 /*
344 * If maximum number of vnodes in namei vnode cache is not explicitly
345 * defined in kernel config, adjust the number such as we use roughly
346 * 0.5% of memory for vnode cache (but not less than NVNODE vnodes).
347 */
348 usevnodes = (ptoa((unsigned)physmem) / 200) / sizeof(struct vnode);
349 if (usevnodes > desiredvnodes)
350 desiredvnodes = usevnodes;
351 #endif
352 vfsinit();
353
354 /* Configure the system hardware. This will enable interrupts. */
355 configure();
356
357 ubc_init(); /* must be after autoconfig */
358
359 /* Lock the kernel on behalf of proc0. */
360 KERNEL_PROC_LOCK(p);
361
362 #ifdef SYSVSHM
363 /* Initialize System V style shared memory. */
364 shminit();
365 #endif
366
367 #ifdef SYSVSEM
368 /* Initialize System V style semaphores. */
369 seminit();
370 #endif
371
372 #ifdef SYSVMSG
373 /* Initialize System V style message queues. */
374 msginit();
375 #endif
376
377 /* Attach pseudo-devices. */
378 for (pdev = pdevinit; pdev->pdev_attach != NULL; pdev++)
379 (*pdev->pdev_attach)(pdev->pdev_count);
380
381 /*
382 * Initialize protocols. Block reception of incoming packets
383 * until everything is ready.
384 */
385 s = splnet();
386 ifinit();
387 domaininit();
388 if_attachdomain();
389 splx(s);
390
391 #ifdef GPROF
392 /* Initialize kernel profiling. */
393 kmstartup();
394 #endif
395
396 /* Initialize system accouting. */
397 acct_init();
398
399 #ifdef SYSTRACE
400 systrace_init();
401 #endif
402 /*
403 * Initialize signal-related data structures, and signal state
404 * for proc0.
405 */
406 signal_init();
407 p->p_sigacts = &sigacts0;
408 siginit(p);
409
410 /* Kick off timeout driven events by calling first time. */
411 schedcpu(NULL);
412
413 /*
414 * Create process 1 (init(8)). We do this now, as Unix has
415 * historically had init be process 1, and changing this would
416 * probably upset a lot of people.
417 *
418 * Note that process 1 won't immediately exec init(8), but will
419 * wait for us to inform it that the root file system has been
420 * mounted.
421 */
422 if (fork1(p, 0, SIGCHLD, NULL, 0, start_init, NULL, NULL, &initproc))
423 panic("fork init");
424
425 /*
426 * Create any kernel threads who's creation was deferred because
427 * initproc had not yet been created.
428 */
429 kthread_run_deferred_queue();
430
431 /*
432 * Now that device driver threads have been created, wait for
433 * them to finish any deferred autoconfiguration. Note we don't
434 * need to lock this semaphore, since we haven't booted any
435 * secondary processors, yet.
436 */
437 while (config_pending)
438 (void) tsleep((void *)&config_pending, PWAIT, "cfpend", 0);
439
440 /*
441 * Finalize configuration now that all real devices have been
442 * found. This needs to be done before the root device is
443 * selected, since finalization may create the root device.
444 */
445 config_finalize();
446
447 /*
448 * Now that autoconfiguration has completed, we can determine
449 * the root and dump devices.
450 */
451 cpu_rootconf();
452 cpu_dumpconf();
453
454 /* Mount the root file system. */
455 do {
456 domountroothook();
457 if ((error = vfs_mountroot())) {
458 printf("cannot mount root, error = %d\n", error);
459 boothowto |= RB_ASKNAME;
460 setroot(root_device,
461 (rootdev != NODEV) ? DISKPART(rootdev) : 0);
462 }
463 } while (error != 0);
464 mountroothook_destroy();
465
466 CIRCLEQ_FIRST(&mountlist)->mnt_flag |= MNT_ROOTFS;
467 CIRCLEQ_FIRST(&mountlist)->mnt_op->vfs_refcount++;
468
469 /*
470 * Get the vnode for '/'. Set filedesc0.fd_fd.fd_cdir to
471 * reference it.
472 */
473 if (VFS_ROOT(CIRCLEQ_FIRST(&mountlist), &rootvnode))
474 panic("cannot find root vnode");
475 cwdi0.cwdi_cdir = rootvnode;
476 VREF(cwdi0.cwdi_cdir);
477 VOP_UNLOCK(rootvnode, 0);
478 cwdi0.cwdi_rdir = NULL;
479
480 /*
481 * Now that root is mounted, we can fixup initproc's CWD
482 * info. All other processes are kthreads, which merely
483 * share proc0's CWD info.
484 */
485 initproc->p_cwdi->cwdi_cdir = rootvnode;
486 VREF(initproc->p_cwdi->cwdi_cdir);
487 initproc->p_cwdi->cwdi_rdir = NULL;
488
489 /*
490 * Now can look at time, having had a chance to verify the time
491 * from the file system. Reset p->p_rtime as it may have been
492 * munched in mi_switch() after the time got set.
493 */
494 proclist_lock_read();
495 s = splsched();
496 for (p = LIST_FIRST(&allproc); p != NULL;
497 p = LIST_NEXT(p, p_list)) {
498 p->p_stats->p_start = mono_time = boottime = time;
499 if (p->p_cpu != NULL)
500 p->p_cpu->ci_schedstate.spc_runtime = time;
501 p->p_rtime.tv_sec = p->p_rtime.tv_usec = 0;
502 }
503 splx(s);
504 proclist_unlock_read();
505
506 /* Create the pageout daemon kernel thread. */
507 uvm_swap_init();
508 if (kthread_create1(uvm_pageout, NULL, NULL, "pagedaemon"))
509 panic("fork pagedaemon");
510
511 /* Create the process reaper kernel thread. */
512 if (kthread_create1(reaper, NULL, NULL, "reaper"))
513 panic("fork reaper");
514
515 /* Create the filesystem syncer kernel thread. */
516 if (kthread_create1(sched_sync, NULL, NULL, "ioflush"))
517 panic("fork syncer");
518
519 /* Create the aiodone daemon kernel thread. */
520 if (kthread_create1(uvm_aiodone_daemon, NULL, NULL, "aiodoned"))
521 panic("fork aiodoned");
522
523 #if defined(MULTIPROCESSOR)
524 /* Boot the secondary processors. */
525 cpu_boot_secondary_processors();
526 #endif
527
528 /* Initialize exec structures */
529 exec_init(1);
530
531 #ifndef PIPE_SOCKETPAIR
532 /* Initialize pipe structures */
533 pipe_init();
534 #endif
535
536 /*
537 * Okay, now we can let init(8) exec! It's off to userland!
538 */
539 start_init_exec = 1;
540 wakeup((void *)&start_init_exec);
541
542 /* The scheduler is an infinite loop. */
543 uvm_scheduler();
544 /* NOTREACHED */
545 }
546
547 static void
548 check_console(struct proc *p)
549 {
550 struct nameidata nd;
551 int error;
552
553 NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/dev/console", p);
554 error = namei(&nd);
555 if (error == 0)
556 vrele(nd.ni_vp);
557 else if (error == ENOENT)
558 printf("warning: no /dev/console\n");
559 else
560 printf("warning: lookup /dev/console: error %d\n", error);
561 }
562
563 /*
564 * List of paths to try when searching for "init".
565 */
566 static const char *initpaths[] = {
567 "/sbin/init",
568 "/sbin/oinit",
569 "/sbin/init.bak",
570 NULL,
571 };
572
573 /*
574 * Start the initial user process; try exec'ing each pathname in "initpaths".
575 * The program is invoked with one argument containing the boot flags.
576 */
577 static void
578 start_init(void *arg)
579 {
580 struct proc *p = arg;
581 vaddr_t addr;
582 struct sys_execve_args /* {
583 syscallarg(const char *) path;
584 syscallarg(char * const *) argp;
585 syscallarg(char * const *) envp;
586 } */ args;
587 int options, i, error;
588 register_t retval[2];
589 char flags[4], *flagsp;
590 const char *path, *slash;
591 char *ucp, **uap, *arg0, *arg1 = NULL;
592 char ipath[129];
593 int ipx, len;
594
595 /*
596 * Now in process 1.
597 */
598 strncpy(p->p_comm, "init", MAXCOMLEN);
599
600 /*
601 * Wait for main() to tell us that it's safe to exec.
602 */
603 while (start_init_exec == 0)
604 (void) tsleep((void *)&start_init_exec, PWAIT, "initexec", 0);
605
606 /*
607 * This is not the right way to do this. We really should
608 * hand-craft a descriptor onto /dev/console to hand to init,
609 * but that's a _lot_ more work, and the benefit from this easy
610 * hack makes up for the "good is the enemy of the best" effect.
611 */
612 check_console(p);
613
614 /*
615 * Need just enough stack to hold the faked-up "execve()" arguments.
616 */
617 addr = USRSTACK - PAGE_SIZE;
618 if (uvm_map(&p->p_vmspace->vm_map, &addr, PAGE_SIZE,
619 NULL, UVM_UNKNOWN_OFFSET, 0,
620 UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_COPY,
621 UVM_ADV_NORMAL,
622 UVM_FLAG_FIXED|UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW)) != 0)
623 panic("init: couldn't allocate argument space");
624 p->p_vmspace->vm_maxsaddr = (caddr_t)addr;
625
626 ipx = 0;
627 while (1) {
628 if (boothowto & RB_ASKNAME) {
629 printf("init path");
630 if (initpaths[ipx])
631 printf(" (default %s)", initpaths[ipx]);
632 printf(": ");
633 len = cngetsn(ipath, sizeof(ipath)-1);
634 if (len == 0) {
635 if (initpaths[ipx])
636 path = initpaths[ipx++];
637 else
638 continue;
639 } else {
640 ipath[len] = '\0';
641 path = ipath;
642 }
643 } else {
644 if ((path = initpaths[ipx++]) == NULL)
645 break;
646 }
647
648 ucp = (char *)(addr + PAGE_SIZE);
649
650 /*
651 * Construct the boot flag argument.
652 */
653 flagsp = flags;
654 *flagsp++ = '-';
655 options = 0;
656
657 if (boothowto & RB_SINGLE) {
658 *flagsp++ = 's';
659 options = 1;
660 }
661 #ifdef notyet
662 if (boothowto & RB_FASTBOOT) {
663 *flagsp++ = 'f';
664 options = 1;
665 }
666 #endif
667
668 /*
669 * Move out the flags (arg 1), if necessary.
670 */
671 if (options != 0) {
672 *flagsp++ = '\0';
673 i = flagsp - flags;
674 #ifdef DEBUG
675 printf("init: copying out flags `%s' %d\n", flags, i);
676 #endif
677 (void)copyout((caddr_t)flags, (caddr_t)(ucp -= i), i);
678 arg1 = ucp;
679 }
680
681 /*
682 * Move out the file name (also arg 0).
683 */
684 i = strlen(path) + 1;
685 #ifdef DEBUG
686 printf("init: copying out path `%s' %d\n", path, i);
687 #else
688 if (boothowto & RB_ASKNAME || path != initpaths[0])
689 printf("init: trying %s\n", path);
690 #endif
691 (void)copyout((caddr_t)path, (caddr_t)(ucp -= i), i);
692 arg0 = ucp;
693
694 /*
695 * Move out the arg pointers.
696 */
697 uap = (char **)((long)ucp & ~ALIGNBYTES);
698 (void)suword((caddr_t)--uap, 0); /* terminator */
699 if (options != 0)
700 (void)suword((caddr_t)--uap, (long)arg1);
701 slash = strrchr(path, '/');
702 if (slash)
703 (void)suword((caddr_t)--uap,
704 (long)arg0 + (slash + 1 - path));
705 else
706 (void)suword((caddr_t)--uap, (long)arg0);
707
708 /*
709 * Point at the arguments.
710 */
711 SCARG(&args, path) = arg0;
712 SCARG(&args, argp) = uap;
713 SCARG(&args, envp) = NULL;
714
715 /*
716 * Now try to exec the program. If can't for any reason
717 * other than it doesn't exist, complain.
718 */
719 error = sys_execve(p, &args, retval);
720 if (error == 0 || error == EJUSTRETURN) {
721 KERNEL_PROC_UNLOCK(p);
722 return;
723 }
724 printf("exec %s: error %d\n", path, error);
725 }
726 printf("init: not found\n");
727 panic("no init");
728 }
729