xref: /openbsd-src/sys/kern/init_main.c (revision 4c1e55dc91edd6e69ccc60ce855900fbc12cf34f)
1 /*	$OpenBSD: init_main.c,v 1.183 2012/06/13 22:47:39 ariane 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 #include <net/netisr.h>
93 
94 #if defined(CRYPTO)
95 #include <crypto/cryptodev.h>
96 #include <crypto/cryptosoft.h>
97 #endif
98 
99 #if defined(NFSSERVER) || defined(NFSCLIENT)
100 extern void nfs_init(void);
101 #endif
102 
103 #include "mpath.h"
104 #include "vscsi.h"
105 #include "softraid.h"
106 
107 const char	copyright[] =
108 "Copyright (c) 1982, 1986, 1989, 1991, 1993\n"
109 "\tThe Regents of the University of California.  All rights reserved.\n"
110 "Copyright (c) 1995-2012 OpenBSD. All rights reserved.  http://www.OpenBSD.org\n";
111 
112 /* Components of the first process -- never freed. */
113 struct	session session0;
114 struct	pgrp pgrp0;
115 struct	proc proc0;
116 struct	process process0;
117 struct	pcred cred0;
118 struct	plimit limit0;
119 struct	vmspace vmspace0;
120 struct	sigacts sigacts0;
121 struct	proc *initproc;
122 struct	proc *reaperproc;
123 
124 int	cmask = CMASK;
125 extern	struct user *proc0paddr;
126 
127 struct	vnode *rootvp, *swapdev_vp;
128 int	boothowto;
129 struct	timeval boottime;
130 int	ncpus =  1;
131 int	ncpusfound = 1;			/* number of cpus we find */
132 __volatile int start_init_exec;		/* semaphore for start_init() */
133 
134 #if !defined(NO_PROPOLICE)
135 long	__guard[8];
136 #endif
137 
138 /* XXX return int so gcc -Werror won't complain */
139 int	main(void *);
140 void	check_console(struct proc *);
141 void	start_init(void *);
142 void	start_cleaner(void *);
143 void	start_update(void *);
144 void	start_reaper(void *);
145 void	crypto_init(void);
146 void	init_exec(void);
147 void	kqueue_init(void);
148 void	workq_init(void);
149 
150 extern char sigcode[], esigcode[];
151 #ifdef SYSCALL_DEBUG
152 extern char *syscallnames[];
153 #endif
154 
155 struct emul emul_native = {
156 	"native",
157 	NULL,
158 	sendsig,
159 	SYS_syscall,
160 	SYS_MAXSYSCALL,
161 	sysent,
162 #ifdef SYSCALL_DEBUG
163 	syscallnames,
164 #else
165 	NULL,
166 #endif
167 	0,
168 	copyargs,
169 	setregs,
170 	NULL,
171 	coredump_trad,
172 	sigcode,
173 	esigcode,
174 	EMUL_ENABLED | EMUL_NATIVE,
175 };
176 
177 
178 /*
179  * System startup; initialize the world, create process 0, mount root
180  * filesystem, and fork to create init and pagedaemon.  Most of the
181  * hard work is done in the lower-level initialization routines including
182  * startup(), which does memory initialization and autoconfiguration.
183  */
184 /* XXX return int, so gcc -Werror won't complain */
185 int
186 main(void *framep)
187 {
188 	struct proc *p;
189 	struct process *pr;
190 	struct pdevinit *pdev;
191 	struct timeval rtv;
192 	quad_t lim;
193 	int s, i;
194 	extern struct pdevinit pdevinit[];
195 	extern void disk_init(void);
196 
197 	/*
198 	 * Initialize the current process pointer (curproc) before
199 	 * any possible traps/probes to simplify trap processing.
200 	 */
201 	curproc = p = &proc0;
202 	p->p_cpu = curcpu();
203 
204 	/*
205 	 * Initialize timeouts.
206 	 */
207 	timeout_startup();
208 
209 	/*
210 	 * Attempt to find console and initialize
211 	 * in case of early panic or other messages.
212 	 */
213 	config_init();		/* init autoconfiguration data structures */
214 	consinit();
215 
216 	printf("%s\n", copyright);
217 
218 	KERNEL_LOCK_INIT();
219 	SCHED_LOCK_INIT();
220 
221 	random_init();
222 
223 	uvm_init();
224 	disk_init();		/* must come before autoconfiguration */
225 	tty_init();		/* initialise tty's */
226 	cpu_startup();
227 
228 	/*
229 	 * Initialize mbuf's.  Do this now because we might attempt to
230 	 * allocate mbufs or mbuf clusters during autoconfiguration.
231 	 */
232 	mbinit();
233 
234 	/* Initialize sockets. */
235 	soinit();
236 
237 	/*
238 	 * Initialize process and pgrp structures.
239 	 */
240 	procinit();
241 
242 	/* Initialize file locking. */
243 	lf_init();
244 
245 	/*
246 	 * Initialize filedescriptors.
247 	 */
248 	filedesc_init();
249 
250 	/*
251 	 * Initialize pipes.
252 	 */
253 	pipe_init();
254 
255 	/*
256 	 * Initialize kqueues.
257 	 */
258 	kqueue_init();
259 
260 	/*
261 	 * Create process 0 (the swapper).
262 	 */
263 
264 	process0.ps_mainproc = p;
265 	TAILQ_INIT(&process0.ps_threads);
266 	TAILQ_INSERT_TAIL(&process0.ps_threads, p, p_thr_link);
267 	process0.ps_refcnt = 1;
268 	p->p_p = pr = &process0;
269 
270 	/* Set the default routing table/domain. */
271 	process0.ps_rtableid = 0;
272 
273 	LIST_INSERT_HEAD(&allproc, p, p_list);
274 	pr->ps_pgrp = &pgrp0;
275 	LIST_INSERT_HEAD(PIDHASH(0), p, p_hash);
276 	LIST_INSERT_HEAD(PGRPHASH(0), &pgrp0, pg_hash);
277 	LIST_INIT(&pgrp0.pg_members);
278 	LIST_INSERT_HEAD(&pgrp0.pg_members, pr, ps_pglist);
279 
280 	pgrp0.pg_session = &session0;
281 	session0.s_count = 1;
282 	session0.s_leader = pr;
283 
284 	atomic_setbits_int(&p->p_flag, P_SYSTEM);
285 	p->p_stat = SONPROC;
286 	pr->ps_nice = NZERO;
287 	p->p_emul = &emul_native;
288 	bcopy("swapper", p->p_comm, sizeof ("swapper"));
289 
290 	/* Init timeouts. */
291 	timeout_set(&p->p_sleep_to, endtsleep, p);
292 	timeout_set(&pr->ps_realit_to, realitexpire, pr);
293 
294 	/* Create credentials. */
295 	p->p_cred = &cred0;
296 	p->p_ucred = crget();
297 	p->p_ucred->cr_ngroups = 1;	/* group 0 */
298 
299 	/* Initialize signal state for process 0. */
300 	signal_init();
301 	p->p_sigacts = &sigacts0;
302 	siginit(p);
303 
304 	/* Create the file descriptor table. */
305 	p->p_fd = fdinit(NULL);
306 
307 	/* Create the limits structures. */
308 	pr->ps_limit = &limit0;
309 	for (i = 0; i < nitems(p->p_rlimit); i++)
310 		limit0.pl_rlimit[i].rlim_cur =
311 		    limit0.pl_rlimit[i].rlim_max = RLIM_INFINITY;
312 	limit0.pl_rlimit[RLIMIT_NOFILE].rlim_cur = NOFILE;
313 	limit0.pl_rlimit[RLIMIT_NOFILE].rlim_max = MIN(NOFILE_MAX,
314 	    (maxfiles - NOFILE > NOFILE) ?  maxfiles - NOFILE : NOFILE);
315 	limit0.pl_rlimit[RLIMIT_NPROC].rlim_cur = MAXUPRC;
316 	lim = ptoa(uvmexp.free);
317 	limit0.pl_rlimit[RLIMIT_RSS].rlim_max = lim;
318 	limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_max = lim;
319 	limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = lim / 3;
320 	limit0.p_refcnt = 1;
321 
322 	/* Allocate a prototype map so we have something to fork. */
323 	uvmspace_init(&vmspace0, pmap_kernel(), round_page(VM_MIN_ADDRESS),
324 	    trunc_page(VM_MAX_ADDRESS), TRUE, TRUE);
325 	p->p_vmspace = &vmspace0;
326 
327 	p->p_addr = proc0paddr;				/* XXX */
328 
329 	/*
330 	 * Charge root for one process.
331 	 */
332 	(void)chgproccnt(0, 1);
333 
334 	/* Initialize run queues */
335 	sched_init_runqueues();
336 	sleep_queue_init();
337 	sched_init_cpu(curcpu());
338 
339 	/* Initialize work queues */
340 	workq_init();
341 
342 	random_start();
343 
344 	/* Initialize the interface/address trees */
345 	ifinit();
346 
347 	/* Configure the devices */
348 	cpu_configure();
349 
350 	/* Configure virtual memory system, set vm rlimits. */
351 	uvm_init_limits(p);
352 
353 	/* Initialize the file systems. */
354 #if defined(NFSSERVER) || defined(NFSCLIENT)
355 	nfs_init();			/* initialize server/shared data */
356 #endif
357 	vfsinit();
358 
359 	/* Start real time and statistics clocks. */
360 	initclocks();
361 
362 	/* Lock the kernel on behalf of proc0. */
363 	KERNEL_LOCK();
364 
365 #ifdef SYSVSHM
366 	/* Initialize System V style shared memory. */
367 	shminit();
368 #endif
369 
370 #ifdef SYSVSEM
371 	/* Initialize System V style semaphores. */
372 	seminit();
373 #endif
374 
375 #ifdef SYSVMSG
376 	/* Initialize System V style message queues. */
377 	msginit();
378 #endif
379 
380 	/* Attach pseudo-devices. */
381 	for (pdev = pdevinit; pdev->pdev_attach != NULL; pdev++)
382 		if (pdev->pdev_count > 0)
383 			(*pdev->pdev_attach)(pdev->pdev_count);
384 
385 #ifdef CRYPTO
386 	crypto_init();
387 	swcr_init();
388 #endif /* CRYPTO */
389 
390 	/*
391 	 * Initialize protocols.  Block reception of incoming packets
392 	 * until everything is ready.
393 	 */
394 	s = splnet();
395 	netisr_init();
396 	domaininit();
397 	if_attachdomain();
398 	splx(s);
399 
400 #ifdef GPROF
401 	/* Initialize kernel profiling. */
402 	kmstartup();
403 #endif
404 
405 #if !defined(NO_PROPOLICE)
406 	{
407 		volatile long newguard[8];
408 
409 		arc4random_buf((long *)newguard, sizeof(newguard));
410 
411 		for (i = nitems(__guard) - 1; i; i--)
412 			__guard[i] = newguard[i];
413 	}
414 #endif
415 
416 	/* init exec and emul */
417 	init_exec();
418 
419 	/* Start the scheduler */
420 	scheduler_start();
421 
422 	/*
423 	 * Create process 1 (init(8)).  We do this now, as Unix has
424 	 * historically had init be process 1, and changing this would
425 	 * probably upset a lot of people.
426 	 *
427 	 * Note that process 1 won't immediately exec init(8), but will
428 	 * wait for us to inform it that the root file system has been
429 	 * mounted.
430 	 */
431 	if (fork1(p, SIGCHLD, FORK_FORK, NULL, 0, start_init, NULL, NULL,
432 	    &initproc))
433 		panic("fork init");
434 
435 	/*
436 	 * Create any kernel threads whose creation was deferred because
437 	 * initproc had not yet been created.
438 	 */
439 	kthread_run_deferred_queue();
440 
441 	/*
442 	 * Now that device driver threads have been created, wait for
443 	 * them to finish any deferred autoconfiguration.  Note we don't
444 	 * need to lock this semaphore, since we haven't booted any
445 	 * secondary processors, yet.
446 	 */
447 	while (config_pending)
448 		(void) tsleep((void *)&config_pending, PWAIT, "cfpend", 0);
449 
450 	dostartuphooks();
451 
452 #if NMPATH > 0
453 	config_rootfound("mpath", NULL);
454 #endif
455 #if NVSCSI > 0
456 	config_rootfound("vscsi", NULL);
457 #endif
458 #if NSOFTRAID > 0
459 	config_rootfound("softraid", NULL);
460 #endif
461 
462 	/* Configure root/swap devices */
463 	diskconf();
464 
465 	if (mountroot == NULL || ((*mountroot)() != 0))
466 		panic("cannot mount root");
467 
468 	CIRCLEQ_FIRST(&mountlist)->mnt_flag |= MNT_ROOTFS;
469 
470 	/* Get the vnode for '/'.  Set p->p_fd->fd_cdir to reference it. */
471 	if (VFS_ROOT(CIRCLEQ_FIRST(&mountlist), &rootvnode))
472 		panic("cannot find root vnode");
473 	p->p_fd->fd_cdir = rootvnode;
474 	vref(p->p_fd->fd_cdir);
475 	VOP_UNLOCK(rootvnode, 0, p);
476 	p->p_fd->fd_rdir = NULL;
477 
478 	/*
479 	 * Now that root is mounted, we can fixup initproc's CWD
480 	 * info.  All other processes are kthreads, which merely
481 	 * share proc0's CWD info.
482 	 */
483 	initproc->p_fd->fd_cdir = rootvnode;
484 	vref(initproc->p_fd->fd_cdir);
485 	initproc->p_fd->fd_rdir = NULL;
486 
487 	/*
488 	 * Now can look at time, having had a chance to verify the time
489 	 * from the file system.  Reset p->p_rtime as it may have been
490 	 * munched in mi_switch() after the time got set.
491 	 */
492 #ifdef __HAVE_TIMECOUNTER
493 	microtime(&boottime);
494 #else
495 	boottime = mono_time = time;
496 #endif
497 	LIST_FOREACH(p, &allproc, p_list) {
498 		p->p_p->ps_start = boottime;
499 		microuptime(&p->p_cpu->ci_schedstate.spc_runtime);
500 		p->p_rtime.tv_sec = p->p_rtime.tv_usec = 0;
501 	}
502 
503 	uvm_swap_init();
504 
505 	/* Create the pageout daemon kernel thread. */
506 	if (kthread_create(uvm_pageout, NULL, NULL, "pagedaemon"))
507 		panic("fork pagedaemon");
508 
509 	/* Create the reaper daemon kernel thread. */
510 	if (kthread_create(start_reaper, NULL, &reaperproc, "reaper"))
511 		panic("fork reaper");
512 
513 	/* Create the cleaner daemon kernel thread. */
514 	if (kthread_create(start_cleaner, NULL, NULL, "cleaner"))
515 		panic("fork cleaner");
516 
517 	/* Create the update daemon kernel thread. */
518 	if (kthread_create(start_update, NULL, NULL, "update"))
519 		panic("fork update");
520 
521 	/* Create the aiodone daemon kernel thread. */
522 	if (kthread_create(uvm_aiodone_daemon, NULL, NULL, "aiodoned"))
523 		panic("fork aiodoned");
524 
525 	microtime(&rtv);
526 	srandom((u_int32_t)(rtv.tv_sec ^ rtv.tv_usec) ^ arc4random());
527 
528 	randompid = 1;
529 
530 #if defined(MULTIPROCESSOR)
531 	/* Boot the secondary processors. */
532 	cpu_boot_secondary_processors();
533 #endif
534 
535 	domountroothooks();
536 
537 	/*
538 	 * Okay, now we can let init(8) exec!  It's off to userland!
539 	 */
540 	start_init_exec = 1;
541 	wakeup((void *)&start_init_exec);
542 
543         /*
544          * proc0: nothing to do, back to sleep
545          */
546         while (1)
547                 tsleep(&proc0, PVM, "scheduler", 0);
548 	/* NOTREACHED */
549 }
550 
551 /*
552  * List of paths to try when searching for "init".
553  */
554 static char *initpaths[] = {
555 	"/sbin/init",
556 	"/sbin/oinit",
557 	"/sbin/init.bak",
558 	NULL,
559 };
560 
561 void
562 check_console(struct proc *p)
563 {
564 	struct nameidata nd;
565 	int error;
566 
567 	NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/dev/console", p);
568 	error = namei(&nd);
569 	if (error) {
570 		if (error == ENOENT)
571 			printf("warning: /dev/console does not exist\n");
572 		else
573 			printf("warning: /dev/console error %d\n", error);
574 	} else
575 		vrele(nd.ni_vp);
576 }
577 
578 /*
579  * Start the initial user process; try exec'ing each pathname in "initpaths".
580  * The program is invoked with one argument containing the boot flags.
581  */
582 void
583 start_init(void *arg)
584 {
585 	struct proc *p = arg;
586 	vaddr_t addr;
587 	struct sys_execve_args /* {
588 		syscallarg(const char *) path;
589 		syscallarg(char *const *) argp;
590 		syscallarg(char *const *) envp;
591 	} */ args;
592 	int options, error;
593 	long i;
594 	register_t retval[2];
595 	char flags[4], *flagsp;
596 	char **pathp, *path, *ucp, **uap, *arg0, *arg1 = NULL;
597 
598 	/*
599 	 * Now in process 1.
600 	 */
601 
602 	/*
603 	 * Wait for main() to tell us that it's safe to exec.
604 	 */
605 	while (start_init_exec == 0)
606 		(void) tsleep((void *)&start_init_exec, PWAIT, "initexec", 0);
607 
608 	check_console(p);
609 
610 	/* process 0 ignores SIGCHLD, but we can't */
611 	p->p_sigacts->ps_flags = 0;
612 
613 	/*
614 	 * Need just enough stack to hold the faked-up "execve()" arguments.
615 	 */
616 #ifdef MACHINE_STACK_GROWS_UP
617 	addr = USRSTACK;
618 #else
619 	addr = USRSTACK - PAGE_SIZE;
620 #endif
621 	if (uvm_map(&p->p_vmspace->vm_map, &addr, PAGE_SIZE,
622 	    NULL, UVM_UNKNOWN_OFFSET, 0,
623 	    UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_ALL, UVM_INH_COPY,
624 	    UVM_ADV_NORMAL, UVM_FLAG_FIXED|UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW)))
625 		panic("init: couldn't allocate argument space");
626 	p->p_vmspace->vm_maxsaddr = (caddr_t)addr;
627 
628 	for (pathp = &initpaths[0]; (path = *pathp) != NULL; pathp++) {
629 #ifdef MACHINE_STACK_GROWS_UP
630 		ucp = (char *)addr;
631 #else
632 		ucp = (char *)(addr + PAGE_SIZE);
633 #endif
634 		/*
635 		 * Construct the boot flag argument.
636 		 */
637 		flagsp = flags;
638 		*flagsp++ = '-';
639 		options = 0;
640 
641 		if (boothowto & RB_SINGLE) {
642 			*flagsp++ = 's';
643 			options = 1;
644 		}
645 #ifdef notyet
646 		if (boothowto & RB_FASTBOOT) {
647 			*flagsp++ = 'f';
648 			options = 1;
649 		}
650 #endif
651 
652 		/*
653 		 * Move out the flags (arg 1), if necessary.
654 		 */
655 		if (options != 0) {
656 			*flagsp++ = '\0';
657 			i = flagsp - flags;
658 #ifdef DEBUG
659 			printf("init: copying out flags `%s' %d\n", flags, i);
660 #endif
661 #ifdef MACHINE_STACK_GROWS_UP
662 			arg1 = ucp;
663 			(void)copyout((caddr_t)flags, (caddr_t)ucp, i);
664 			ucp += i;
665 #else
666 			(void)copyout((caddr_t)flags, (caddr_t)(ucp -= i), i);
667 			arg1 = ucp;
668 #endif
669 		}
670 
671 		/*
672 		 * Move out the file name (also arg 0).
673 		 */
674 		i = strlen(path) + 1;
675 #ifdef DEBUG
676 		printf("init: copying out path `%s' %d\n", path, i);
677 #endif
678 #ifdef MACHINE_STACK_GROWS_UP
679 		arg0 = ucp;
680 		(void)copyout((caddr_t)path, (caddr_t)ucp, i);
681 		ucp += i;
682 		ucp = (caddr_t)ALIGN((u_long)ucp);
683 		uap = (char **)ucp + 3;
684 #else
685 		(void)copyout((caddr_t)path, (caddr_t)(ucp -= i), i);
686 		arg0 = ucp;
687 		uap = (char **)((u_long)ucp & ~ALIGNBYTES);
688 #endif
689 
690 		/*
691 		 * Move out the arg pointers.
692 		 */
693 		i = 0;
694 		copyout(&i, (caddr_t)--uap, sizeof(register_t)); /* terminator */
695 		if (options != 0)
696 			copyout(&arg1, (caddr_t)--uap, sizeof(register_t));
697 		copyout(&arg0, (caddr_t)--uap, sizeof(register_t));
698 
699 		/*
700 		 * Point at the arguments.
701 		 */
702 		SCARG(&args, path) = arg0;
703 		SCARG(&args, argp) = uap;
704 		SCARG(&args, envp) = NULL;
705 
706 		/*
707 		 * Now try to exec the program.  If can't for any reason
708 		 * other than it doesn't exist, complain.
709 		 */
710 		if ((error = sys_execve(p, &args, retval)) == 0) {
711 			KERNEL_UNLOCK();
712 			return;
713 		}
714 		if (error != ENOENT)
715 			printf("exec %s: error %d\n", path, error);
716 	}
717 	printf("init: not found\n");
718 	panic("no init");
719 }
720 
721 void
722 start_update(void *arg)
723 {
724 	sched_sync(curproc);
725 	/* NOTREACHED */
726 }
727 
728 void
729 start_cleaner(void *arg)
730 {
731 	buf_daemon(curproc);
732 	/* NOTREACHED */
733 }
734 
735 void
736 start_reaper(void *arg)
737 {
738 	reaper();
739 	/* NOTREACHED */
740 }
741