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