xref: /openbsd-src/sys/kern/init_main.c (revision 2b0358df1d88d06ef4139321dd05bd5e05d91eaf)
1 /*	$OpenBSD: init_main.c,v 1.158 2009/03/05 19:52:24 kettenis Exp $	*/
2 /*	$NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $	*/
3 
4 /*
5  * Copyright (c) 1995 Christopher G. Demetriou.  All rights reserved.
6  * Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993
7  *	The Regents of the University of California.  All rights reserved.
8  * (c) UNIX System Laboratories, Inc.
9  * All or some portions of this file are derived from material licensed
10  * to the University of California by American Telephone and Telegraph
11  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
12  * the permission of UNIX System Laboratories, Inc.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  * 1. Redistributions of source code must retain the above copyright
18  *    notice, this list of conditions and the following disclaimer.
19  * 2. Redistributions in binary form must reproduce the above copyright
20  *    notice, this list of conditions and the following disclaimer in the
21  *    documentation and/or other materials provided with the distribution.
22  * 3. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *
38  *	@(#)init_main.c	8.9 (Berkeley) 1/21/94
39  */
40 
41 #include <sys/param.h>
42 #include <sys/core.h>
43 #include <sys/filedesc.h>
44 #include <sys/file.h>
45 #include <sys/errno.h>
46 #include <sys/exec.h>
47 #include <sys/kernel.h>
48 #include <sys/kthread.h>
49 #include <sys/mount.h>
50 #include <sys/proc.h>
51 #include <sys/resourcevar.h>
52 #include <sys/signalvar.h>
53 #include <sys/systm.h>
54 #include <sys/namei.h>
55 #include <sys/vnode.h>
56 #include <sys/tty.h>
57 #include <sys/conf.h>
58 #include <sys/buf.h>
59 #include <sys/device.h>
60 #include <sys/socketvar.h>
61 #include <sys/lockf.h>
62 #include <sys/protosw.h>
63 #include <sys/reboot.h>
64 #include <sys/user.h>
65 #ifdef SYSVSHM
66 #include <sys/shm.h>
67 #endif
68 #ifdef SYSVSEM
69 #include <sys/sem.h>
70 #endif
71 #ifdef SYSVMSG
72 #include <sys/msg.h>
73 #endif
74 #include <sys/domain.h>
75 #include <sys/mbuf.h>
76 #include <sys/pipe.h>
77 #include <sys/workq.h>
78 
79 #include <sys/syscall.h>
80 #include <sys/syscallargs.h>
81 
82 #include <dev/rndvar.h>
83 
84 #include <ufs/ufs/quota.h>
85 
86 #include <machine/cpu.h>
87 
88 #include <uvm/uvm.h>
89 
90 #include <net/if.h>
91 #include <net/raw_cb.h>
92 
93 #if defined(CRYPTO)
94 #include <crypto/cryptodev.h>
95 #include <crypto/cryptosoft.h>
96 #endif
97 
98 #if defined(NFSSERVER) || defined(NFSCLIENT)
99 extern void nfs_init(void);
100 #endif
101 
102 #include "vscsi.h"
103 #include "softraid.h"
104 
105 const char	copyright[] =
106 "Copyright (c) 1982, 1986, 1989, 1991, 1993\n"
107 "\tThe Regents of the University of California.  All rights reserved.\n"
108 "Copyright (c) 1995-2009 OpenBSD. All rights reserved.  http://www.OpenBSD.org\n";
109 
110 /* Components of the first process -- never freed. */
111 struct	session session0;
112 struct	pgrp pgrp0;
113 struct	proc proc0;
114 struct	process process0;
115 struct	pcred cred0;
116 struct	plimit limit0;
117 struct	vmspace vmspace0;
118 struct	sigacts sigacts0;
119 struct	proc *initproc;
120 
121 int	cmask = CMASK;
122 extern	struct user *proc0paddr;
123 
124 struct	vnode *rootvp, *swapdev_vp;
125 int	boothowto;
126 struct	timeval boottime;
127 int	ncpus =  1;
128 __volatile int start_init_exec;		/* semaphore for start_init() */
129 
130 #if !defined(NO_PROPOLICE)
131 long	__guard[8];
132 #endif
133 
134 /* XXX return int so gcc -Werror won't complain */
135 int	main(void *);
136 void	check_console(struct proc *);
137 void	start_init(void *);
138 void	start_cleaner(void *);
139 void	start_update(void *);
140 void	start_reaper(void *);
141 void	init_crypto(void);
142 void	init_exec(void);
143 void	kqueue_init(void);
144 void	workq_init(void);
145 
146 extern char sigcode[], esigcode[];
147 #ifdef SYSCALL_DEBUG
148 extern char *syscallnames[];
149 #endif
150 
151 struct emul emul_native = {
152 	"native",
153 	NULL,
154 	sendsig,
155 	SYS_syscall,
156 	SYS_MAXSYSCALL,
157 	sysent,
158 #ifdef SYSCALL_DEBUG
159 	syscallnames,
160 #else
161 	NULL,
162 #endif
163 	0,
164 	copyargs,
165 	setregs,
166 	NULL,
167 	coredump_trad,
168 	sigcode,
169 	esigcode,
170 	EMUL_ENABLED | EMUL_NATIVE,
171 };
172 
173 
174 /*
175  * System startup; initialize the world, create process 0, mount root
176  * filesystem, and fork to create init and pagedaemon.  Most of the
177  * hard work is done in the lower-level initialization routines including
178  * startup(), which does memory initialization and autoconfiguration.
179  */
180 /* XXX return int, so gcc -Werror won't complain */
181 int
182 main(void *framep)
183 {
184 	struct proc *p;
185 	struct pdevinit *pdev;
186 	struct timeval rtv;
187 	quad_t lim;
188 	int s, i;
189 	extern struct pdevinit pdevinit[];
190 	extern void scheduler_start(void);
191 	extern void disk_init(void);
192 	extern void endtsleep(void *);
193 	extern void realitexpire(void *);
194 
195 	/*
196 	 * Initialize the current process pointer (curproc) before
197 	 * any possible traps/probes to simplify trap processing.
198 	 */
199 	curproc = p = &proc0;
200 	p->p_cpu = curcpu();
201 
202 	/*
203 	 * Initialize timeouts.
204 	 */
205 	timeout_startup();
206 
207 	/*
208 	 * Attempt to find console and initialize
209 	 * in case of early panic or other messages.
210 	 */
211 	config_init();		/* init autoconfiguration data structures */
212 	consinit();
213 
214 	printf("%s\n", copyright);
215 
216 	KERNEL_LOCK_INIT();
217 
218 	uvm_init();
219 	disk_init();		/* must come before autoconfiguration */
220 	tty_init();		/* initialise tty's */
221 	cpu_startup();
222 
223 	/*
224 	 * Initialize mbuf's.  Do this now because we might attempt to
225 	 * allocate mbufs or mbuf clusters during autoconfiguration.
226 	 */
227 	mbinit();
228 
229 	/* Initialize sockets. */
230 	soinit();
231 
232 	/*
233 	 * Initialize process and pgrp structures.
234 	 */
235 	procinit();
236 
237 	/* Initialize file locking. */
238 	lf_init();
239 
240 	/*
241 	 * Initialize filedescriptors.
242 	 */
243 	filedesc_init();
244 
245 	/*
246 	 * Initialize pipes.
247 	 */
248 	pipe_init();
249 
250 	/*
251 	 * Initialize kqueues.
252 	 */
253 	kqueue_init();
254 
255 	/*
256 	 * Create process 0 (the swapper).
257 	 */
258 
259 	process0.ps_mainproc = p;
260 	TAILQ_INIT(&process0.ps_threads);
261 	TAILQ_INSERT_TAIL(&process0.ps_threads, p, p_thr_link);
262 	process0.ps_refcnt = 1;
263 	p->p_p = &process0;
264 
265 	LIST_INSERT_HEAD(&allproc, p, p_list);
266 	p->p_pgrp = &pgrp0;
267 	LIST_INSERT_HEAD(PIDHASH(0), p, p_hash);
268 	LIST_INSERT_HEAD(PGRPHASH(0), &pgrp0, pg_hash);
269 	LIST_INIT(&pgrp0.pg_members);
270 	LIST_INSERT_HEAD(&pgrp0.pg_members, p, p_pglist);
271 
272 	pgrp0.pg_session = &session0;
273 	session0.s_count = 1;
274 	session0.s_leader = p;
275 
276 	atomic_setbits_int(&p->p_flag, P_SYSTEM | P_NOCLDWAIT);
277 	p->p_stat = SONPROC;
278 	p->p_nice = NZERO;
279 	p->p_emul = &emul_native;
280 	bcopy("swapper", p->p_comm, sizeof ("swapper"));
281 
282 	/* Init timeouts. */
283 	timeout_set(&p->p_sleep_to, endtsleep, p);
284 	timeout_set(&p->p_realit_to, realitexpire, p);
285 
286 	/* Create credentials. */
287 	cred0.p_refcnt = 1;
288 	p->p_cred = &cred0;
289 	p->p_ucred = crget();
290 	p->p_ucred->cr_ngroups = 1;	/* group 0 */
291 
292 	/* Initialize signal state for process 0. */
293 	signal_init();
294 	p->p_sigacts = &sigacts0;
295 	siginit(p);
296 
297 	/* Create the file descriptor table. */
298 	p->p_fd = fdinit(NULL);
299 
300 	/* Create the limits structures. */
301 	p->p_p->ps_limit = &limit0;
302 	for (i = 0; i < nitems(p->p_rlimit); i++)
303 		limit0.pl_rlimit[i].rlim_cur =
304 		    limit0.pl_rlimit[i].rlim_max = RLIM_INFINITY;
305 	limit0.pl_rlimit[RLIMIT_NOFILE].rlim_cur = NOFILE;
306 	limit0.pl_rlimit[RLIMIT_NOFILE].rlim_max = MIN(NOFILE_MAX,
307 	    (maxfiles - NOFILE > NOFILE) ?  maxfiles - NOFILE : NOFILE);
308 	limit0.pl_rlimit[RLIMIT_NPROC].rlim_cur = MAXUPRC;
309 	lim = ptoa(uvmexp.free);
310 	limit0.pl_rlimit[RLIMIT_RSS].rlim_max = lim;
311 	limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_max = lim;
312 	limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = lim / 3;
313 	limit0.p_refcnt = 1;
314 
315 	/* Allocate a prototype map so we have something to fork. */
316 	uvmspace_init(&vmspace0, pmap_kernel(), round_page(VM_MIN_ADDRESS),
317 	    trunc_page(VM_MAX_ADDRESS), TRUE, TRUE);
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 	/* Initialize run queues */
334 	sched_init_runqueues();
335 	sleep_queue_init();
336 	sched_init_cpu(curcpu());
337 
338 	/* Initialize work queues */
339 	workq_init();
340 
341 	/* Configure the devices */
342 	cpu_configure();
343 
344 	/* Configure virtual memory system, set vm rlimits. */
345 	uvm_init_limits(p);
346 
347 	/* Initialize the file systems. */
348 #if defined(NFSSERVER) || defined(NFSCLIENT)
349 	nfs_init();			/* initialize server/shared data */
350 #endif
351 	vfsinit();
352 
353 	/* Start real time and statistics clocks. */
354 	initclocks();
355 
356 	/* Lock the kernel on behalf of proc0. */
357 	KERNEL_PROC_LOCK(p);
358 
359 #ifdef SYSVSHM
360 	/* Initialize System V style shared memory. */
361 	shminit();
362 #endif
363 
364 #ifdef SYSVSEM
365 	/* Initialize System V style semaphores. */
366 	seminit();
367 #endif
368 
369 #ifdef SYSVMSG
370 	/* Initialize System V style message queues. */
371 	msginit();
372 #endif
373 
374 	/* Attach pseudo-devices. */
375 	randomattach();
376 	for (pdev = pdevinit; pdev->pdev_attach != NULL; pdev++)
377 		if (pdev->pdev_count > 0)
378 			(*pdev->pdev_attach)(pdev->pdev_count);
379 
380 #ifdef CRYPTO
381 	swcr_init();
382 #endif /* CRYPTO */
383 
384 	/*
385 	 * Initialize protocols.  Block reception of incoming packets
386 	 * until everything is ready.
387 	 */
388 	s = splnet();
389 	ifinit();
390 	domaininit();
391 	if_attachdomain();
392 	splx(s);
393 
394 #ifdef GPROF
395 	/* Initialize kernel profiling. */
396 	kmstartup();
397 #endif
398 
399 #if !defined(NO_PROPOLICE)
400 	{
401 		volatile long newguard[8];
402 
403 		arc4random_buf((long *)newguard, sizeof(newguard));
404 
405 		for (i = nitems(__guard) - 1; i; i--)
406 			__guard[i] = newguard[i];
407 	}
408 #endif
409 
410 	/* init exec and emul */
411 	init_exec();
412 
413 	/* Start the scheduler */
414 	scheduler_start();
415 
416 	/*
417 	 * Create process 1 (init(8)).  We do this now, as Unix has
418 	 * historically had init be process 1, and changing this would
419 	 * probably upset a lot of people.
420 	 *
421 	 * Note that process 1 won't immediately exec init(8), but will
422 	 * wait for us to inform it that the root file system has been
423 	 * mounted.
424 	 */
425 	if (fork1(p, SIGCHLD, FORK_FORK, NULL, 0, start_init, NULL, NULL,
426 	    &initproc))
427 		panic("fork init");
428 
429 	/*
430 	 * Create any kernel threads whose creation was deferred because
431 	 * initproc had not yet been created.
432 	 */
433 	kthread_run_deferred_queue();
434 
435 	/*
436 	 * Now that device driver threads have been created, wait for
437 	 * them to finish any deferred autoconfiguration.  Note we don't
438 	 * need to lock this semaphore, since we haven't booted any
439 	 * secondary processors, yet.
440 	 */
441 	while (config_pending)
442 		(void) tsleep((void *)&config_pending, PWAIT, "cfpend", 0);
443 
444 	dostartuphooks();
445 
446 #if NVSCSI > 0
447 	config_rootfound("vscsi", NULL);
448 #endif
449 #if NSOFTRAID > 0
450 	config_rootfound("softraid", NULL);
451 #endif
452 
453 	/* Configure root/swap devices */
454 	diskconf();
455 
456 	if (mountroot == NULL || ((*mountroot)() != 0))
457 		panic("cannot mount root");
458 
459 	CIRCLEQ_FIRST(&mountlist)->mnt_flag |= MNT_ROOTFS;
460 
461 	/* Get the vnode for '/'.  Set p->p_fd->fd_cdir to reference it. */
462 	if (VFS_ROOT(CIRCLEQ_FIRST(&mountlist), &rootvnode))
463 		panic("cannot find root vnode");
464 	p->p_fd->fd_cdir = rootvnode;
465 	VREF(p->p_fd->fd_cdir);
466 	VOP_UNLOCK(rootvnode, 0, p);
467 	p->p_fd->fd_rdir = NULL;
468 
469 	/*
470 	 * Now that root is mounted, we can fixup initproc's CWD
471 	 * info.  All other processes are kthreads, which merely
472 	 * share proc0's CWD info.
473 	 */
474 	initproc->p_fd->fd_cdir = rootvnode;
475 	VREF(initproc->p_fd->fd_cdir);
476 	initproc->p_fd->fd_rdir = NULL;
477 
478 	/*
479 	 * Now can look at time, having had a chance to verify the time
480 	 * from the file system.  Reset p->p_rtime as it may have been
481 	 * munched in mi_switch() after the time got set.
482 	 */
483 #ifdef __HAVE_TIMECOUNTER
484 	microtime(&boottime);
485 #else
486 	boottime = mono_time = time;
487 #endif
488 	LIST_FOREACH(p, &allproc, p_list) {
489 		p->p_stats->p_start = boottime;
490 		microuptime(&p->p_cpu->ci_schedstate.spc_runtime);
491 		p->p_rtime.tv_sec = p->p_rtime.tv_usec = 0;
492 	}
493 
494 	uvm_swap_init();
495 
496 	/* Create the pageout daemon kernel thread. */
497 	if (kthread_create(uvm_pageout, NULL, NULL, "pagedaemon"))
498 		panic("fork pagedaemon");
499 
500 	/* Create the reaper daemon kernel thread. */
501 	if (kthread_create(start_reaper, NULL, NULL, "reaper"))
502 		panic("fork reaper");
503 
504 	/* Create the cleaner daemon kernel thread. */
505 	if (kthread_create(start_cleaner, NULL, NULL, "cleaner"))
506 		panic("fork cleaner");
507 
508 	/* Create the update daemon kernel thread. */
509 	if (kthread_create(start_update, NULL, NULL, "update"))
510 		panic("fork update");
511 
512 	/* Create the aiodone daemon kernel thread. */
513 	if (kthread_create(uvm_aiodone_daemon, NULL, NULL, "aiodoned"))
514 		panic("fork aiodoned");
515 
516 #ifdef CRYPTO
517 	/* Create the crypto kernel thread. */
518 	init_crypto();
519 #endif /* CRYPTO */
520 
521 	microtime(&rtv);
522 	srandom((u_int32_t)(rtv.tv_sec ^ rtv.tv_usec) ^ arc4random());
523 
524 	randompid = 1;
525 
526 #if defined(MULTIPROCESSOR)
527 	/* Boot the secondary processors. */
528 	cpu_boot_secondary_processors();
529 #endif
530 
531 	domountroothooks();
532 
533 	/*
534 	 * Okay, now we can let init(8) exec!  It's off to userland!
535 	 */
536 	start_init_exec = 1;
537 	wakeup((void *)&start_init_exec);
538 
539 	/* The scheduler is an infinite loop. */
540 	uvm_scheduler();
541 	/* NOTREACHED */
542 }
543 
544 /*
545  * List of paths to try when searching for "init".
546  */
547 static char *initpaths[] = {
548 	"/sbin/init",
549 	"/sbin/oinit",
550 	"/sbin/init.bak",
551 	NULL,
552 };
553 
554 void
555 check_console(struct proc *p)
556 {
557 	struct nameidata nd;
558 	int error;
559 
560 	NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/dev/console", p);
561 	error = namei(&nd);
562 	if (error) {
563 		if (error == ENOENT)
564 			printf("warning: /dev/console does not exist\n");
565 		else
566 			printf("warning: /dev/console error %d\n", error);
567 	} else
568 		vrele(nd.ni_vp);
569 }
570 
571 /*
572  * Start the initial user process; try exec'ing each pathname in "initpaths".
573  * The program is invoked with one argument containing the boot flags.
574  */
575 void
576 start_init(void *arg)
577 {
578 	struct proc *p = arg;
579 	vaddr_t addr;
580 	struct sys_execve_args /* {
581 		syscallarg(const char *) path;
582 		syscallarg(char *const *) argp;
583 		syscallarg(char *const *) envp;
584 	} */ args;
585 	int options, error;
586 	long i;
587 	register_t retval[2];
588 	char flags[4], *flagsp;
589 	char **pathp, *path, *ucp, **uap, *arg0, *arg1 = NULL;
590 
591 	/*
592 	 * Now in process 1.
593 	 */
594 
595 	/*
596 	 * Wait for main() to tell us that it's safe to exec.
597 	 */
598 	while (start_init_exec == 0)
599 		(void) tsleep((void *)&start_init_exec, PWAIT, "initexec", 0);
600 
601 	check_console(p);
602 
603 	/*
604 	 * Need just enough stack to hold the faked-up "execve()" arguments.
605 	 */
606 #ifdef MACHINE_STACK_GROWS_UP
607 	addr = USRSTACK;
608 #else
609 	addr = USRSTACK - PAGE_SIZE;
610 #endif
611 	if (uvm_map(&p->p_vmspace->vm_map, &addr, PAGE_SIZE,
612 	    NULL, UVM_UNKNOWN_OFFSET, 0,
613 	    UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_ALL, UVM_INH_COPY,
614 	    UVM_ADV_NORMAL, UVM_FLAG_FIXED|UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW)))
615 		panic("init: couldn't allocate argument space");
616 	p->p_vmspace->vm_maxsaddr = (caddr_t)addr;
617 
618 	for (pathp = &initpaths[0]; (path = *pathp) != NULL; pathp++) {
619 #ifdef MACHINE_STACK_GROWS_UP
620 		ucp = (char *)addr;
621 #else
622 		ucp = (char *)(addr + PAGE_SIZE);
623 #endif
624 		/*
625 		 * Construct the boot flag argument.
626 		 */
627 		flagsp = flags;
628 		*flagsp++ = '-';
629 		options = 0;
630 
631 		if (boothowto & RB_SINGLE) {
632 			*flagsp++ = 's';
633 			options = 1;
634 		}
635 #ifdef notyet
636 		if (boothowto & RB_FASTBOOT) {
637 			*flagsp++ = 'f';
638 			options = 1;
639 		}
640 #endif
641 
642 		/*
643 		 * Move out the flags (arg 1), if necessary.
644 		 */
645 		if (options != 0) {
646 			*flagsp++ = '\0';
647 			i = flagsp - flags;
648 #ifdef DEBUG
649 			printf("init: copying out flags `%s' %d\n", flags, i);
650 #endif
651 #ifdef MACHINE_STACK_GROWS_UP
652 			arg1 = ucp;
653 			(void)copyout((caddr_t)flags, (caddr_t)ucp, i);
654 			ucp += i;
655 #else
656 			(void)copyout((caddr_t)flags, (caddr_t)(ucp -= i), i);
657 			arg1 = ucp;
658 #endif
659 		}
660 
661 		/*
662 		 * Move out the file name (also arg 0).
663 		 */
664 		i = strlen(path) + 1;
665 #ifdef DEBUG
666 		printf("init: copying out path `%s' %d\n", path, i);
667 #endif
668 #ifdef MACHINE_STACK_GROWS_UP
669 		arg0 = ucp;
670 		(void)copyout((caddr_t)path, (caddr_t)ucp, i);
671 		ucp += i;
672 		ucp = (caddr_t)ALIGN((u_long)ucp);
673 		uap = (char **)ucp + 3;
674 #else
675 		(void)copyout((caddr_t)path, (caddr_t)(ucp -= i), i);
676 		arg0 = ucp;
677 		uap = (char **)((u_long)ucp & ~ALIGNBYTES);
678 #endif
679 
680 		/*
681 		 * Move out the arg pointers.
682 		 */
683 		i = 0;
684 		copyout(&i, (caddr_t)--uap, sizeof(register_t)); /* terminator */
685 		if (options != 0)
686 			copyout(&arg1, (caddr_t)--uap, sizeof(register_t));
687 		copyout(&arg0, (caddr_t)--uap, sizeof(register_t));
688 
689 		/*
690 		 * Point at the arguments.
691 		 */
692 		SCARG(&args, path) = arg0;
693 		SCARG(&args, argp) = uap;
694 		SCARG(&args, envp) = NULL;
695 
696 		/*
697 		 * Now try to exec the program.  If can't for any reason
698 		 * other than it doesn't exist, complain.
699 		 */
700 		if ((error = sys_execve(p, &args, retval)) == 0) {
701 			KERNEL_PROC_UNLOCK(p);
702 			return;
703 		}
704 		if (error != ENOENT)
705 			printf("exec %s: error %d\n", path, error);
706 	}
707 	printf("init: not found\n");
708 	panic("no init");
709 }
710 
711 void
712 start_update(void *arg)
713 {
714 	sched_sync(curproc);
715 	/* NOTREACHED */
716 }
717 
718 void
719 start_cleaner(void *arg)
720 {
721 	buf_daemon(curproc);
722 	/* NOTREACHED */
723 }
724 
725 void
726 start_reaper(void *arg)
727 {
728 	reaper();
729 	/* NOTREACHED */
730 }
731