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
本文介绍了一个系统的初始化脚本中关键路径和配置项的定义及使用方法。包括虚拟控制台、安全终端列表、初始化脚本位置等核心配置。还展示了如何通过检查特定文件来决定是否执行快速启动,并解释了如何根据不同的运行级别调用相应的处理程序。

被折叠的 条评论
为什么被折叠?



