Exemplo n.º 1
0
void init()
{
	/* Call sys_setup. This sets up the root nodes, and filedesc's 0, 1 and 2. */
	sys_setup();
	kprintf("Something stirs and something tries, and starts to climb towards the light.\n");
	/* Set some basic environment variables. These allow simple root execution, 
	 * basic terminal access, and a shell to run from */
	add_init_env("PATH=/bin/:/usr/bin/:/usr/sbin:");
	add_init_env("TERM=seaos");
	add_init_env("HOME=/");
	add_init_env("SHELL=/bin/sh");
	int ret=0;
	int pid;
	init_pid = current_task->pid+1;
	set_cpu_interrupt_flag(1);
	switch_to_user_mode();
	/* We have to be careful now. If we try to call any kernel functions
	 * without doing a system call, the processor will generate a GPF (or 
	 * a page fault) because you can't execute kernel code in ring 3!
	 * So we write simple wrapper functions for common functions that 
	 * we will need */
	ret = u_execve("/sh", (char **)stuff_to_pass, (char **)init_env);
	unset_ksf(KSF_HAVEEXECED);
	ret = u_execve("/bin/sh", (char **)stuff_to_pass, (char **)init_env);
	unset_ksf(KSF_HAVEEXECED);
	ret = u_execve("/usr/bin/sh", (char **)stuff_to_pass, (char **)init_env);
	unset_ksf(KSF_HAVEEXECED);
	printf("Failed to start the init process. Halting.\n");
	u_exit(0);
}
Exemplo n.º 2
0
static void user_mode_init(void)
{
	/* We have to be careful now. If we try to call any kernel functions
	 * without doing a system call, the processor will generate a GPF (or 
	 * a page fault) because you can't do fancy kernel stuff in ring 3!
	 * So we write simple wrapper functions for common functions that 
	 * we will need */
	char *init_env[5] = {
		"PATH=/bin/:/usr/bin/:/usr/sbin:",
		"TERM=seaos",
		"HOME=/",
		"SHELL=/bin/sh",
		NULL
	};
	int ret;
	char *init_argv[3] = {
		"init",
		root_device,
		NULL
	};
	ret = u_execve("/init", (char **)init_argv, (char **)init_env);
	printf("Failed to start the init process (err=%d). Halting.\n", -ret);
	u_exit(0);
}