| Both sides previous revision Previous revision Next revision | Previous revision |
| docs:techref:init.detail.cc [2018/02/20 18:52] – ↷ Links adapted because of a move operation bobafetthotmail | docs:techref:init.detail.cc [2018/03/04 11:46] (current) – ↷ Links adapted because of a move operation |
|---|
| |
| - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l71|main(int argc, char **argv)]]'' in /sbin/init, line 71\\ User space life begins here. OpenWrt calls this phase "preinit". | - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l71|main(int argc, char **argv)]]'' in /sbin/init, line 71\\ User space life begins here. OpenWrt calls this phase "preinit". |
| - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l81|early()]]'' [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/early.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l92|(definition)]]\\ Mount filesystems: ''/proc'', ''/sys'', ''/sys/fs/cgroup'', ''/dev'' (a tmpfs), ''/dev/pts''\\ Populate ''/dev'' with entries from ''/sys/dev/{char;block}''\\ Open ''/dev/console'' as STDIN/STDOUT/STDERR\\ Make directories ''/tmp'' (optionally on zram), ''/tmp/run'', ''tmp/lock'', ''/tmp/state''\\ \\ This accounts for most of the filesystem layout, observed that ''/etc/fstab'' is a [[http://git.openwrt.org/?p=15.05/openwrt.git;a=blob;f=package/base-files/Makefile;hb=483dac821788b457d349233e770329186a0aa860#l161|broken symlink, line 161]], with the following additions:\\ - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=plug/coldplug.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l40|procd_coldplug()]]'' [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=state.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l105|invoked at hotplug setup time]] will recreate ''/dev'' from scratch.\\ - ''[[http://git.openwrt.org/?p=15.05/openwrt.git;a=blob;f=package/base-files/files/etc/init.d/boot;hb=483dac821788b457d349233e770329186a0aa860#l20|/etc/rc.d/S10boot]]'' will invoke ''mount_root'' to setup a writable filesystem based on extroot or jffs2 overlay or a tmpfs backed [[/inbox/snapshot|snapshot capable]] overlay, add some directories and files, and mount debugfs. | - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l81|early()]]'' [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/early.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l92|(definition)]]\\ Mount filesystems: ''/proc'', ''/sys'', ''/sys/fs/cgroup'', ''/dev'' (a tmpfs), ''/dev/pts''\\ Populate ''/dev'' with entries from ''/sys/dev/{char;block}''\\ Open ''/dev/console'' as STDIN/STDOUT/STDERR\\ Make directories ''/tmp'' (optionally on zram), ''/tmp/run'', ''tmp/lock'', ''/tmp/state''\\ \\ This accounts for most of the filesystem layout, observed that ''/etc/fstab'' is a [[http://git.openwrt.org/?p=15.05/openwrt.git;a=blob;f=package/base-files/Makefile;hb=483dac821788b457d349233e770329186a0aa860#l161|broken symlink, line 161]], with the following additions:\\ - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=plug/coldplug.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l40|procd_coldplug()]]'' [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=state.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l105|invoked at hotplug setup time]] will recreate ''/dev'' from scratch.\\ - ''[[http://git.openwrt.org/?p=15.05/openwrt.git;a=blob;f=package/base-files/files/etc/init.d/boot;hb=483dac821788b457d349233e770329186a0aa860#l20|/etc/rc.d/S10boot]]'' will invoke ''mount_root'' to setup a writable filesystem based on extroot or jffs2 overlay or a tmpfs backed [[docs:guide-user:installation:snapshot|snapshot capable]] overlay, add some directories and files, and mount debugfs. |
| - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l82|cmdline()]]'' [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l56|(definition)]]\\ Check kernel cmdline for boot parameter "''init_debug={1,2,3,4}''". | - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l82|cmdline()]]'' [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l56|(definition)]]\\ Check kernel cmdline for boot parameter "''init_debug={1,2,3,4}''". |
| - Fork ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l87|/sbin/kmodloader (/rom)/etc/modules-boot.d/]]'' [[http://git.openwrt.org/?p=project/ubox.git;a=blob;f=kmodloader.c;hb=907d046c8929fb74e5a3502a9498198695e62ad8#l830|kmodloader source]]\\ Wait up to 120 seconds for ''/sbin/kmodloader'' to probe the kernel modules declared in ''(/rom)/etc/modules-boot.d/''\\ At this point in the boot sequence, '/etc/modules-boot.d' is the one from the rom image (''/rom/etc/...'' when boot is done). The overlay filesystem is mounted later.\\ \\ kmodloader is a multicall binary, invoked as\\ '' kmodloader''\\ does \\ '' [[http://git.openwrt.org/?p=project/ubox.git;a=blob;f=kmodloader.c;hb=907d046c8929fb74e5a3502a9498198695e62ad8#l732|main_loader()]]''\\ which reads files in ''(/rom)/etc/modules-boot.d/'', looking for lines starting with the name of a module to load, optionally followed by a space and module parameters. There appear to be [[http://git.openwrt.org/?p=project/ubox.git;a=blob;f=kmodloader.c;hb=907d046c8929fb74e5a3502a9498198695e62ad8#l788|special treatment for files with names beginning with a number]]: the modules they list are immediately loaded, then modules from files with name beginning with an ascii char greater than "9" are loaded all together in a final load_modprobe call. | - Fork ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=initd/init.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l87|/sbin/kmodloader (/rom)/etc/modules-boot.d/]]'' [[http://git.openwrt.org/?p=project/ubox.git;a=blob;f=kmodloader.c;hb=907d046c8929fb74e5a3502a9498198695e62ad8#l830|kmodloader source]]\\ Wait up to 120 seconds for ''/sbin/kmodloader'' to probe the kernel modules declared in ''(/rom)/etc/modules-boot.d/''\\ At this point in the boot sequence, '/etc/modules-boot.d' is the one from the rom image (''/rom/etc/...'' when boot is done). The overlay filesystem is mounted later.\\ \\ kmodloader is a multicall binary, invoked as\\ '' kmodloader''\\ does \\ '' [[http://git.openwrt.org/?p=project/ubox.git;a=blob;f=kmodloader.c;hb=907d046c8929fb74e5a3502a9498198695e62ad8#l732|main_loader()]]''\\ which reads files in ''(/rom)/etc/modules-boot.d/'', looking for lines starting with the name of a module to load, optionally followed by a space and module parameters. There appear to be [[http://git.openwrt.org/?p=project/ubox.git;a=blob;f=kmodloader.c;hb=907d046c8929fb74e5a3502a9498198695e62ad8#l788|special treatment for files with names beginning with a number]]: the modules they list are immediately loaded, then modules from files with name beginning with an ascii char greater than "9" are loaded all together in a final load_modprobe call. |
| - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=procd.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l68|uloop_init()]]'', line 68\\ The uloop instance set up before by ''/sbin/init'' is gone. Creates a new one. | - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=procd.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l68|uloop_init()]]'', line 68\\ The uloop instance set up before by ''/sbin/init'' is gone. Creates a new one. |
| - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=procd.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l69|procd_signal()]]'', line 69 [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=signal.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l82|(definition)]], line 82.\\ Setup signal handlers. Reboot on SIGTERM or SIGINT, poweroff on SIGUSR2 or SIGUSR2. | - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=procd.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l69|procd_signal()]]'', line 69 [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=signal.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l82|(definition)]], line 82.\\ Setup signal handlers. Reboot on SIGTERM or SIGINT, poweroff on SIGUSR2 or SIGUSR2. |
| - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=procd.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l70|trigger_init()]]'', line 70 [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=service/trigger.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l319|(definition)]]\\ Procd triggers on config file/network interface changes, see [[/inbox/procd-init-scripts#procd_triggers_on_config_filenetwork_interface_changes]]\\ Initialise a run queue. An [[http://git.openwrt.org/?p=project/libubox.git;a=blob;f=examples/runqueue-example.c;hb=d1c66ef1131d14f0ed197b368d03f71b964e45f8|example]] is the sole documentation. A queued task has an uloop callback invoked when done, here sets the empty queue callback to do nothing. | - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=procd.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l70|trigger_init()]]'', line 70 [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=service/trigger.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l319|(definition)]]\\ Procd triggers on config file/network interface changes, see [[docs:guide-developer:procd-init-scripts#procd_triggers_on_config_filenetwork_interface_changes]]\\ Initialise a run queue. An [[http://git.openwrt.org/?p=project/libubox.git;a=blob;f=examples/runqueue-example.c;hb=d1c66ef1131d14f0ed197b368d03f71b964e45f8|example]] is the sole documentation. A queued task has an uloop callback invoked when done, here sets the empty queue callback to do nothing. |
| - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=procd.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l74|procd_state_next()]]'', line 74 [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=state.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l179|(definition)]]\\ Transitions from NONE to EARLY the state of a state machine implemented in ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=state.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l96|state_enter(void)]]'' used to sequence the remaining boot steps. | - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=procd.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l74|procd_state_next()]]'', line 74 [[http://git.openwrt.org/?p=project/procd.git;a=blob;f=state.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l179|(definition)]]\\ Transitions from NONE to EARLY the state of a state machine implemented in ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=state.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l96|state_enter(void)]]'' used to sequence the remaining boot steps. |
| - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=state.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l101|STATE_EARLY]]'' in ''state_enter()'' | - ''[[http://git.openwrt.org/?p=project/procd.git;a=blob;f=state.c;hb=0da5bf2ff222d1a499172a6e09507388676b5a08#l101|STATE_EARLY]]'' in ''state_enter()'' |