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