MCPcopy Create free account
hub / github.com/F-Stack/f-stack / start_init

Function start_init

freebsd/kern/init_main.c:703–784  ·  view source on GitHub ↗

* Start the initial user process; try exec'ing each pathname in init_path. * The program is invoked with one argument containing the boot flags. */

Source from the content-addressed store, hash-verified

701 * The program is invoked with one argument containing the boot flags.
702 */
703static void
704start_init(void *dummy)
705{
706 struct image_args args;
707 int error;
708 char *var, *path;
709 char *free_init_path, *tmp_init_path;
710 struct thread *td;
711 struct proc *p;
712 struct vmspace *oldvmspace;
713
714 TSENTER(); /* Here so we don't overlap with mi_startup. */
715
716 td = curthread;
717 p = td->td_proc;
718
719 vfs_mountroot();
720
721 /* Wipe GELI passphrase from the environment. */
722 kern_unsetenv("kern.geom.eli.passphrase");
723
724 /* For Multicons, report which console is primary to both */
725 if (boothowto & RB_MULTIPLE) {
726 if (boothowto & RB_SERIAL)
727 printf("Dual Console: Serial Primary, Video Secondary\n");
728 else
729 printf("Dual Console: Video Primary, Serial Secondary\n");
730 }
731
732 if ((var = kern_getenv("init_path")) != NULL) {
733 strlcpy(init_path, var, sizeof(init_path));
734 freeenv(var);
735 }
736 free_init_path = tmp_init_path = strdup(init_path, M_TEMP);
737
738 while ((path = strsep(&tmp_init_path, ":")) != NULL) {
739 if (bootverbose)
740 printf("start_init: trying %s\n", path);
741
742 memset(&args, 0, sizeof(args));
743 error = exec_alloc_args(&args);
744 if (error != 0)
745 panic("%s: Can't allocate space for init arguments %d",
746 __func__, error);
747
748 error = exec_args_add_fname(&args, path, UIO_SYSSPACE);
749 if (error != 0)
750 panic("%s: Can't add fname %d", __func__, error);
751 error = exec_args_add_arg(&args, path, UIO_SYSSPACE);
752 if (error != 0)
753 panic("%s: Can't add argv[0] %d", __func__, error);
754 if (boothowto & RB_SINGLE)
755 error = exec_args_add_arg(&args, "-s", UIO_SYSSPACE);
756 if (error != 0)
757 panic("%s: Can't add argv[0] %d", __func__, error);
758
759 /*
760 * Now try to exec the program. If can't for any reason

Callers

nothing calls this directly

Calls 15

vfs_mountrootFunction · 0.85
kern_unsetenvFunction · 0.85
strdupFunction · 0.85
strsepFunction · 0.85
memsetFunction · 0.85
exec_alloc_argsFunction · 0.85
exec_args_add_fnameFunction · 0.85
exec_args_add_argFunction · 0.85
kern_execveFunction · 0.85
exec_cleanupFunction · 0.85
printfFunction · 0.70
kern_getenvFunction · 0.70

Tested by

no test coverage detected