xref: /openbsd-src/sys/kern/init_main.c (revision 91f110e064cd7c194e59e019b83bb7496c1c84d4)
1 /*	$OpenBSD: init_main.c,v 1.205 2014/03/22 06:05:45 guenther 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 #include <sys/task.h>
79 
80 #include <sys/syscall.h>
81 #include <sys/syscallargs.h>
82 
83 #include <dev/rndvar.h>
84 
85 #include <ufs/ufs/quota.h>
86 
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-2014 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	timespec 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_local __attribute__((section(".openbsd.randomdata")));
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 void	taskq_init(void);
150 
151 extern char sigcode[], esigcode[];
152 #ifdef SYSCALL_DEBUG
153 extern char *syscallnames[];
154 #endif
155 
156 struct emul emul_native = {
157 	"native",
158 	NULL,
159 	sendsig,
160 	SYS_syscall,
161 	SYS_MAXSYSCALL,
162 	sysent,
163 #ifdef SYSCALL_DEBUG
164 	syscallnames,
165 #else
166 	NULL,
167 #endif
168 	0,
169 	copyargs,
170 	setregs,
171 	NULL,
172 	coredump_trad,
173 	sigcode,
174 	esigcode,
175 	EMUL_ENABLED | EMUL_NATIVE,
176 };
177 
178 
179 /*
180  * System startup; initialize the world, create process 0, mount root
181  * filesystem, and fork to create init and pagedaemon.  Most of the
182  * hard work is done in the lower-level initialization routines including
183  * startup(), which does memory initialization and autoconfiguration.
184  */
185 /* XXX return int, so gcc -Werror won't complain */
186 int
187 main(void *framep)
188 {
189 	struct proc *p;
190 	struct process *pr;
191 	struct pdevinit *pdev;
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 	uvm_init();
222 	disk_init();		/* must come before autoconfiguration */
223 	tty_init();		/* initialise tty's */
224 	cpu_startup();
225 
226 	random_start();		/* Start the flow */
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 	LIST_INSERT_HEAD(&allprocess, pr, ps_list);
270 
271 	/* Set the default routing table/domain. */
272 	process0.ps_rtableid = 0;
273 
274 	LIST_INSERT_HEAD(&allproc, p, p_list);
275 	pr->ps_pgrp = &pgrp0;
276 	LIST_INSERT_HEAD(PIDHASH(0), p, p_hash);
277 	LIST_INSERT_HEAD(PGRPHASH(0), &pgrp0, pg_hash);
278 	LIST_INIT(&pgrp0.pg_members);
279 	LIST_INSERT_HEAD(&pgrp0.pg_members, pr, ps_pglist);
280 
281 	pgrp0.pg_session = &session0;
282 	session0.s_count = 1;
283 	session0.s_leader = pr;
284 
285 	atomic_setbits_int(&p->p_flag, P_SYSTEM);
286 	p->p_stat = SONPROC;
287 	pr->ps_nice = NZERO;
288 	p->p_emul = &emul_native;
289 	bcopy("swapper", p->p_comm, sizeof ("swapper"));
290 
291 	/* Init timeouts. */
292 	timeout_set(&p->p_sleep_to, endtsleep, p);
293 	timeout_set(&pr->ps_realit_to, realitexpire, pr);
294 
295 	/* Create credentials. */
296 	p->p_cred = &cred0;
297 	p->p_ucred = crget();
298 	p->p_ucred->cr_ngroups = 1;	/* group 0 */
299 
300 	/* Initialize signal state for process 0. */
301 	signal_init();
302 	pr->ps_sigacts = &sigacts0;
303 	siginit(pr);
304 
305 	/* Create the file descriptor table. */
306 	p->p_fd = fdinit(NULL);
307 
308 	/* Create the limits structures. */
309 	pr->ps_limit = &limit0;
310 	for (i = 0; i < nitems(p->p_rlimit); i++)
311 		limit0.pl_rlimit[i].rlim_cur =
312 		    limit0.pl_rlimit[i].rlim_max = RLIM_INFINITY;
313 	limit0.pl_rlimit[RLIMIT_NOFILE].rlim_cur = NOFILE;
314 	limit0.pl_rlimit[RLIMIT_NOFILE].rlim_max = MIN(NOFILE_MAX,
315 	    (maxfiles - NOFILE > NOFILE) ?  maxfiles - NOFILE : NOFILE);
316 	limit0.pl_rlimit[RLIMIT_NPROC].rlim_cur = MAXUPRC;
317 	lim = ptoa(uvmexp.free);
318 	limit0.pl_rlimit[RLIMIT_RSS].rlim_max = lim;
319 	limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_max = lim;
320 	limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = lim / 3;
321 	limit0.p_refcnt = 1;
322 
323 	/* Allocate a prototype map so we have something to fork. */
324 	uvmspace_init(&vmspace0, pmap_kernel(), round_page(VM_MIN_ADDRESS),
325 	    trunc_page(VM_MAX_ADDRESS), TRUE, TRUE);
326 	p->p_vmspace = &vmspace0;
327 
328 	p->p_addr = proc0paddr;				/* XXX */
329 
330 	/*
331 	 * Charge root for one process.
332 	 */
333 	(void)chgproccnt(0, 1);
334 
335 	/* Initialize run queues */
336 	sched_init_runqueues();
337 	sleep_queue_init();
338 	sched_init_cpu(curcpu());
339 	p->p_cpu->ci_randseed = (arc4random() & 0x7fffffff) + 1;
340 
341 	/* Initialize work queues */
342 	workq_init();
343 	taskq_init();
344 
345 	/* Initialize the interface/address trees */
346 	ifinit();
347 
348 #if NMPATH > 0
349 	/* Attach mpath before hardware */
350 	config_rootfound("mpath", NULL);
351 #endif
352 
353 	/* Configure the devices */
354 	cpu_configure();
355 
356 	/* Configure virtual memory system, set vm rlimits. */
357 	uvm_init_limits(p);
358 
359 	/* Initialize the file systems. */
360 #if defined(NFSSERVER) || defined(NFSCLIENT)
361 	nfs_init();			/* initialize server/shared data */
362 #endif
363 	vfsinit();
364 
365 	/* Start real time and statistics clocks. */
366 	initclocks();
367 
368 	/* Lock the kernel on behalf of proc0. */
369 	KERNEL_LOCK();
370 
371 #ifdef SYSVSHM
372 	/* Initialize System V style shared memory. */
373 	shminit();
374 #endif
375 
376 #ifdef SYSVSEM
377 	/* Initialize System V style semaphores. */
378 	seminit();
379 #endif
380 
381 #ifdef SYSVMSG
382 	/* Initialize System V style message queues. */
383 	msginit();
384 #endif
385 
386 	/* Attach pseudo-devices. */
387 	for (pdev = pdevinit; pdev->pdev_attach != NULL; pdev++)
388 		if (pdev->pdev_count > 0)
389 			(*pdev->pdev_attach)(pdev->pdev_count);
390 
391 #ifdef CRYPTO
392 	crypto_init();
393 	swcr_init();
394 #endif /* CRYPTO */
395 
396 	/*
397 	 * Initialize protocols.  Block reception of incoming packets
398 	 * until everything is ready.
399 	 */
400 	s = splnet();
401 	netisr_init();
402 	domaininit();
403 	if_attachdomain();
404 	splx(s);
405 
406 #ifdef GPROF
407 	/* Initialize kernel profiling. */
408 	kmstartup();
409 #endif
410 
411 #if !defined(NO_PROPOLICE)
412 	if (__guard_local == 0) {
413 		volatile long newguard;
414 
415 		arc4random_buf((void *)&newguard, sizeof newguard);
416 		__guard_local = newguard;
417 	}
418 #endif
419 
420 	/* init exec and emul */
421 	init_exec();
422 
423 	/* Start the scheduler */
424 	scheduler_start();
425 
426 	/*
427 	 * Create process 1 (init(8)).  We do this now, as Unix has
428 	 * historically had init be process 1, and changing this would
429 	 * probably upset a lot of people.
430 	 *
431 	 * Note that process 1 won't immediately exec init(8), but will
432 	 * wait for us to inform it that the root file system has been
433 	 * mounted.
434 	 */
435 	if (fork1(p, FORK_FORK, NULL, 0, start_init, NULL, NULL,
436 	    &initproc))
437 		panic("fork init");
438 
439 	randompid = 1;
440 
441 	/*
442 	 * Create any kernel threads whose creation was deferred because
443 	 * initproc had not yet been created.
444 	 */
445 	kthread_run_deferred_queue();
446 
447 	/*
448 	 * Now that device driver threads have been created, wait for
449 	 * them to finish any deferred autoconfiguration.  Note we don't
450 	 * need to lock this semaphore, since we haven't booted any
451 	 * secondary processors, yet.
452 	 */
453 	while (config_pending)
454 		(void) tsleep((void *)&config_pending, PWAIT, "cfpend", 0);
455 
456 	dostartuphooks();
457 
458 #if NVSCSI > 0
459 	config_rootfound("vscsi", NULL);
460 #endif
461 #if NSOFTRAID > 0
462 	config_rootfound("softraid", NULL);
463 #endif
464 
465 	/* Configure root/swap devices */
466 	diskconf();
467 
468 	if (mountroot == NULL || ((*mountroot)() != 0))
469 		panic("cannot mount root");
470 
471 	TAILQ_FIRST(&mountlist)->mnt_flag |= MNT_ROOTFS;
472 
473 	/* Get the vnode for '/'.  Set p->p_fd->fd_cdir to reference it. */
474 	if (VFS_ROOT(TAILQ_FIRST(&mountlist), &rootvnode))
475 		panic("cannot find root vnode");
476 	p->p_fd->fd_cdir = rootvnode;
477 	vref(p->p_fd->fd_cdir);
478 	VOP_UNLOCK(rootvnode, 0, p);
479 	p->p_fd->fd_rdir = NULL;
480 
481 	/*
482 	 * Now that root is mounted, we can fixup initproc's CWD
483 	 * info.  All other processes are kthreads, which merely
484 	 * share proc0's CWD info.
485 	 */
486 	initproc->p_fd->fd_cdir = rootvnode;
487 	vref(initproc->p_fd->fd_cdir);
488 	initproc->p_fd->fd_rdir = NULL;
489 
490 	/*
491 	 * Now can look at time, having had a chance to verify the time
492 	 * from the file system.  Reset p->p_rtime as it may have been
493 	 * munched in mi_switch() after the time got set.
494 	 */
495 	nanotime(&boottime);
496 	LIST_FOREACH(pr, &allprocess, ps_list) {
497 		pr->ps_start = boottime;
498 		TAILQ_FOREACH(p, &pr->ps_threads, p_thr_link) {
499 			nanouptime(&p->p_cpu->ci_schedstate.spc_runtime);
500 			timespecclear(&p->p_rtime);
501 		}
502 	}
503 
504 	uvm_swap_init();
505 
506 	/* Create the pageout daemon kernel thread. */
507 	if (kthread_create(uvm_pageout, NULL, NULL, "pagedaemon"))
508 		panic("fork pagedaemon");
509 
510 	/* Create the reaper daemon kernel thread. */
511 	if (kthread_create(start_reaper, NULL, &reaperproc, "reaper"))
512 		panic("fork reaper");
513 
514 	/* Create the cleaner daemon kernel thread. */
515 	if (kthread_create(start_cleaner, NULL, NULL, "cleaner"))
516 		panic("fork cleaner");
517 
518 	/* Create the update daemon kernel thread. */
519 	if (kthread_create(start_update, NULL, NULL, "update"))
520 		panic("fork update");
521 
522 	/* Create the aiodone daemon kernel thread. */
523 	if (kthread_create(uvm_aiodone_daemon, NULL, NULL, "aiodoned"))
524 		panic("fork aiodoned");
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         /*
540          * proc0: nothing to do, back to sleep
541          */
542         while (1)
543                 tsleep(&proc0, PVM, "scheduler", 0);
544 	/* NOTREACHED */
545 }
546 
547 /*
548  * List of paths to try when searching for "init".
549  */
550 static char *initpaths[] = {
551 	"/sbin/init",
552 	"/sbin/oinit",
553 	"/sbin/init.bak",
554 	NULL,
555 };
556 
557 void
558 check_console(struct proc *p)
559 {
560 	struct nameidata nd;
561 	int error;
562 
563 	NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/dev/console", p);
564 	error = namei(&nd);
565 	if (error) {
566 		if (error == ENOENT)
567 			printf("warning: /dev/console does not exist\n");
568 		else
569 			printf("warning: /dev/console error %d\n", error);
570 	} else
571 		vrele(nd.ni_vp);
572 }
573 
574 /*
575  * Start the initial user process; try exec'ing each pathname in "initpaths".
576  * The program is invoked with one argument containing the boot flags.
577  */
578 void
579 start_init(void *arg)
580 {
581 	struct proc *p = arg;
582 	vaddr_t addr;
583 	struct sys_execve_args /* {
584 		syscallarg(const char *) path;
585 		syscallarg(char *const *) argp;
586 		syscallarg(char *const *) envp;
587 	} */ args;
588 	int options, error;
589 	long i;
590 	register_t retval[2];
591 	char flags[4], *flagsp;
592 	char **pathp, *path, *ucp, **uap, *arg0, *arg1 = NULL;
593 
594 	/*
595 	 * Now in process 1.
596 	 */
597 
598 	/*
599 	 * Wait for main() to tell us that it's safe to exec.
600 	 */
601 	while (start_init_exec == 0)
602 		(void) tsleep((void *)&start_init_exec, PWAIT, "initexec", 0);
603 
604 	check_console(p);
605 
606 	/* process 0 ignores SIGCHLD, but we can't */
607 	p->p_p->ps_sigacts->ps_flags = 0;
608 
609 	/*
610 	 * Need just enough stack to hold the faked-up "execve()" arguments.
611 	 */
612 #ifdef MACHINE_STACK_GROWS_UP
613 	addr = USRSTACK;
614 #else
615 	addr = USRSTACK - PAGE_SIZE;
616 #endif
617 	if (uvm_map(&p->p_vmspace->vm_map, &addr, PAGE_SIZE,
618 	    NULL, UVM_UNKNOWN_OFFSET, 0,
619 	    UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_ALL, UVM_INH_COPY,
620 	    UVM_ADV_NORMAL, UVM_FLAG_FIXED|UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW)))
621 		panic("init: couldn't allocate argument space");
622 	p->p_vmspace->vm_maxsaddr = (caddr_t)addr;
623 
624 	for (pathp = &initpaths[0]; (path = *pathp) != NULL; pathp++) {
625 #ifdef MACHINE_STACK_GROWS_UP
626 		ucp = (char *)addr;
627 #else
628 		ucp = (char *)(addr + PAGE_SIZE);
629 #endif
630 		/*
631 		 * Construct the boot flag argument.
632 		 */
633 		flagsp = flags;
634 		*flagsp++ = '-';
635 		options = 0;
636 
637 		if (boothowto & RB_SINGLE) {
638 			*flagsp++ = 's';
639 			options = 1;
640 		}
641 #ifdef notyet
642 		if (boothowto & RB_FASTBOOT) {
643 			*flagsp++ = 'f';
644 			options = 1;
645 		}
646 #endif
647 
648 		/*
649 		 * Move out the flags (arg 1), if necessary.
650 		 */
651 		if (options != 0) {
652 			*flagsp++ = '\0';
653 			i = flagsp - flags;
654 #ifdef DEBUG
655 			printf("init: copying out flags `%s' %d\n", flags, i);
656 #endif
657 #ifdef MACHINE_STACK_GROWS_UP
658 			arg1 = ucp;
659 			(void)copyout((caddr_t)flags, (caddr_t)ucp, i);
660 			ucp += i;
661 #else
662 			(void)copyout((caddr_t)flags, (caddr_t)(ucp -= i), i);
663 			arg1 = ucp;
664 #endif
665 		}
666 
667 		/*
668 		 * Move out the file name (also arg 0).
669 		 */
670 		i = strlen(path) + 1;
671 #ifdef DEBUG
672 		printf("init: copying out path `%s' %d\n", path, i);
673 #endif
674 #ifdef MACHINE_STACK_GROWS_UP
675 		arg0 = ucp;
676 		(void)copyout((caddr_t)path, (caddr_t)ucp, i);
677 		ucp += i;
678 		ucp = (caddr_t)ALIGN((u_long)ucp);
679 		uap = (char **)ucp + 3;
680 #else
681 		(void)copyout((caddr_t)path, (caddr_t)(ucp -= i), i);
682 		arg0 = ucp;
683 		uap = (char **)((u_long)ucp & ~ALIGNBYTES);
684 #endif
685 
686 		/*
687 		 * Move out the arg pointers.
688 		 */
689 		i = 0;
690 		copyout(&i, (caddr_t)--uap, sizeof(register_t)); /* terminator */
691 		if (options != 0)
692 			copyout(&arg1, (caddr_t)--uap, sizeof(register_t));
693 		copyout(&arg0, (caddr_t)--uap, sizeof(register_t));
694 
695 		/*
696 		 * Point at the arguments.
697 		 */
698 		SCARG(&args, path) = arg0;
699 		SCARG(&args, argp) = uap;
700 		SCARG(&args, envp) = NULL;
701 
702 		/*
703 		 * Now try to exec the program.  If can't for any reason
704 		 * other than it doesn't exist, complain.
705 		 */
706 		if ((error = sys_execve(p, &args, retval)) == 0) {
707 			KERNEL_UNLOCK();
708 			return;
709 		}
710 		if (error != ENOENT)
711 			printf("exec %s: error %d\n", path, error);
712 	}
713 	printf("init: not found\n");
714 	panic("no init");
715 }
716 
717 void
718 start_update(void *arg)
719 {
720 	sched_sync(curproc);
721 	/* NOTREACHED */
722 }
723 
724 void
725 start_cleaner(void *arg)
726 {
727 	buf_daemon(curproc);
728 	/* NOTREACHED */
729 }
730 
731 void
732 start_reaper(void *arg)
733 {
734 	reaper();
735 	/* NOTREACHED */
736 }
737