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