Paths.h
#define VT_MASTER "/dev/tty0" /* Virtual console master */
#define CONSOLE "/dev/console" /* Logical system console */
#define SECURETTY "/etc/securetty" /* List of root terminals */
#define SDALLOW "/etc/shutdown.allow" /* Users allowed to shutdown */
#define INITTAB "/etc/inittab" /* Location of inittab */
#define INIT "/sbin/init" /* Location of init itself. */
#define NOLOGIN "/etc/nologin" /* Stop user logging in. */
#define FASTBOOT "/fastboot" /* Enable fast boot. */
#define FORCEFSCK "/forcefsck" /* Force fsck on boot */
#define SDPID "/var/run/shutdown.pid" /* PID of shutdown program */
#define SHELL "/bin/sh" /* Default shell */
#define SULOGIN "/sbin/sulogin" /* Sulogin */
#define INITSCRIPT "/etc/initscript" /* Initscript. */
#define PWRSTAT "/etc/powerstatus" /* COMPAT: SIGPWR reason (OK/BAD) */
main ->init_main ->read_inittab
strncpy(ch->id, id, sizeof(utproto.ut_id) + 1); /* Hack for different libs. */
strncpy(ch->process, process, sizeof(ch->process) - 1);
init_main -> start_if_needed ->startup ->spawn
/* See if there is an "initscript" (except in single user mode). */
if (access(INITSCRIPT, R_OK) == 0 && runlevel != 'S') {
/* Build command line using "initscript" */
args[1] = SHELL;
args[2] = INITSCRIPT;
args[3] = ch->id;
args[4] = ch->rlevel;
args[5] = "unknown";
for(f = 0; actions[f].name; f++) {
if (ch->action == actions[f].act) {
args[5] = actions[f].name;
break;
}
}
args[6] = proc;
args[7] = NULL;
initscript执行inittab中的进程。
# Execute the program.
eval exec "$4"
si::bootwait:/etc/init.d/boot
if test "$container" != "lxc" ; then
# stat does really only return tmpfs even for devtmpfs
# but testing both values anyway they change their mind
DTYPE=$(stat -f -c "%T" /dev 2>/dev/null)
if test "$DTYPE" != "tmpfs" -a "$DTYPE" != "devtmpfs"; then
echo -n "Mounting devtmpfs at /dev"
mount -n -t $DEVTMPFS -o mode=0755 $DEVTMPFS /dev
rc_status -v -r
fi