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