Пример #1
0
/*
 *	Run through the boot processing from inittab
 */
static void boot_runlevel(void)
{
	do_for_runlevel(MASK_BOOT, INIT_SYS);
	do_for_runlevel(MASK_BOOT, INIT_BOOT);
	runlevel = default_rl;
	enter_runlevel(1 << default_rl);
}
Пример #2
0
int main(int argc, char *argv[])
{
	int fdtty1;

	signal(SIGINT, SIG_IGN);
	signal(SIGUSR1, sigusr1);

	/* remove any stale /etc/mtab file */

	unlink("/etc/mtab");

	/* clean up anything handed to us by the kernel */
	close(0);
	close(1);
	close(2);

	/* loop until we can open the first terminal */

	do {
		fdtty1 = open("/dev/tty1", O_RDWR|O_NOCTTY);
	} while (fdtty1 < 0);

	/* make stdin, stdout and stderr point to /dev/tty1 */

	if (fdtty1 != 0)
		close(0);
	dup(fdtty1);
	close(1);
	dup(fdtty1);
	close(2);
	dup(fdtty1);

	putstr("init version 0.9.0ac#1\n");

	close(open("/var/run/utmp", O_WRONLY | O_CREAT | O_TRUNC));

	load_inittab();
	parse_inittab();

	boot_runlevel();

	for (;;) {
		clear_zombies(0);
		if (dingdong) {
			uint8_t newrl;
			int fd = open("/var/run/intctl", O_RDONLY);
			if (fd != -1 && read(fd, &newrl, 1) == 1) {
				exit_runlevel(1 << runlevel, 1 << newrl);
				runlevel = newrl;
				enter_runlevel(1 << runlevel);
			}
			close(fd);
			dingdong = 0;
		}
	}
}