aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-10-12 13:47:15 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2010-10-12 13:47:15 +0200
commitb1db09be5a19f814ed5dc7e0ab095c3355926da6 (patch)
tree382ba65d4a9194cb1b694e4240a0cf005bf567f1
parentd4d289acf5eb59ebae414f9aae8a74de30dce36a (diff)
downloadbusybox-w32-b1db09be5a19f814ed5dc7e0ab095c3355926da6.tar.gz
busybox-w32-b1db09be5a19f814ed5dc7e0ab095c3355926da6.tar.bz2
busybox-w32-b1db09be5a19f814ed5dc7e0ab095c3355926da6.zip
init/*: move applet/kbuild/config/help bits into applet source files
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r--include/applets.src.h7
-rw-r--r--include/usage.src.h169
-rw-r--r--init/Config.src127
-rw-r--r--init/Kbuild.src4
-rw-r--r--init/bootchartd.c4
-rw-r--r--init/halt.c62
-rw-r--r--init/init.c231
-rw-r--r--init/mesg.c18
8 files changed, 315 insertions, 307 deletions
diff --git a/include/applets.src.h b/include/applets.src.h
index 6a14a6588..545d3c5c2 100644
--- a/include/applets.src.h
+++ b/include/applets.src.h
@@ -72,7 +72,6 @@ IF_BASENAME(APPLET_NOFORK(basename, basename, _BB_DIR_USR_BIN, _BB_SUID_DROP, ba
72IF_BBCONFIG(APPLET(bbconfig, _BB_DIR_BIN, _BB_SUID_DROP)) 72IF_BBCONFIG(APPLET(bbconfig, _BB_DIR_BIN, _BB_SUID_DROP))
73IF_BEEP(APPLET(beep, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 73IF_BEEP(APPLET(beep, _BB_DIR_USR_BIN, _BB_SUID_DROP))
74IF_BLKID(APPLET(blkid, _BB_DIR_SBIN, _BB_SUID_DROP)) 74IF_BLKID(APPLET(blkid, _BB_DIR_SBIN, _BB_SUID_DROP))
75IF_BOOTCHARTD(APPLET(bootchartd, _BB_DIR_SBIN, _BB_SUID_DROP))
76IF_BRCTL(APPLET(brctl, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) 75IF_BRCTL(APPLET(brctl, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
77IF_BZIP2(APPLET(bzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 76IF_BZIP2(APPLET(bzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP))
78IF_CAL(APPLET(cal, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 77IF_CAL(APPLET(cal, _BB_DIR_USR_BIN, _BB_SUID_DROP))
@@ -165,7 +164,6 @@ IF_GETSEBOOL(APPLET(getsebool, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
165IF_GETTY(APPLET(getty, _BB_DIR_SBIN, _BB_SUID_DROP)) 164IF_GETTY(APPLET(getty, _BB_DIR_SBIN, _BB_SUID_DROP))
166IF_GUNZIP(APPLET(gunzip, _BB_DIR_BIN, _BB_SUID_DROP)) 165IF_GUNZIP(APPLET(gunzip, _BB_DIR_BIN, _BB_SUID_DROP))
167IF_GZIP(APPLET(gzip, _BB_DIR_BIN, _BB_SUID_DROP)) 166IF_GZIP(APPLET(gzip, _BB_DIR_BIN, _BB_SUID_DROP))
168IF_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_DROP))
169IF_HD(APPLET_NOEXEC(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_DROP, hd)) 167IF_HD(APPLET_NOEXEC(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_DROP, hd))
170IF_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_DROP)) 168IF_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_DROP))
171IF_HEAD(APPLET_NOEXEC(head, head, _BB_DIR_USR_BIN, _BB_SUID_DROP, head)) 169IF_HEAD(APPLET_NOEXEC(head, head, _BB_DIR_USR_BIN, _BB_SUID_DROP, head))
@@ -181,7 +179,6 @@ IF_IFENSLAVE(APPLET(ifenslave, _BB_DIR_SBIN, _BB_SUID_DROP))
181IF_IFPLUGD(APPLET(ifplugd, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 179IF_IFPLUGD(APPLET(ifplugd, _BB_DIR_USR_BIN, _BB_SUID_DROP))
182IF_IFUPDOWN(APPLET_ODDNAME(ifup, ifupdown, _BB_DIR_SBIN, _BB_SUID_DROP, ifup)) 180IF_IFUPDOWN(APPLET_ODDNAME(ifup, ifupdown, _BB_DIR_SBIN, _BB_SUID_DROP, ifup))
183IF_INETD(APPLET(inetd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) 181IF_INETD(APPLET(inetd, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
184IF_INIT(APPLET(init, _BB_DIR_SBIN, _BB_SUID_DROP))
185IF_INOTIFYD(APPLET(inotifyd, _BB_DIR_SBIN, _BB_SUID_DROP)) 182IF_INOTIFYD(APPLET(inotifyd, _BB_DIR_SBIN, _BB_SUID_DROP))
186IF_INSMOD(APPLET(insmod, _BB_DIR_SBIN, _BB_SUID_DROP)) 183IF_INSMOD(APPLET(insmod, _BB_DIR_SBIN, _BB_SUID_DROP))
187IF_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe)) 184IF_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe))
@@ -212,7 +209,6 @@ IF_LENGTH(APPLET_NOFORK(length, length, _BB_DIR_USR_BIN, _BB_SUID_DROP, length))
212IF_LESS(APPLET(less, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 209IF_LESS(APPLET(less, _BB_DIR_USR_BIN, _BB_SUID_DROP))
213IF_SETARCH(APPLET_ODDNAME(linux32, setarch, _BB_DIR_BIN, _BB_SUID_DROP, linux32)) 210IF_SETARCH(APPLET_ODDNAME(linux32, setarch, _BB_DIR_BIN, _BB_SUID_DROP, linux32))
214IF_SETARCH(APPLET_ODDNAME(linux64, setarch, _BB_DIR_BIN, _BB_SUID_DROP, linux64)) 211IF_SETARCH(APPLET_ODDNAME(linux64, setarch, _BB_DIR_BIN, _BB_SUID_DROP, linux64))
215IF_FEATURE_INITRD(APPLET_ODDNAME(linuxrc, init, _BB_DIR_ROOT, _BB_SUID_DROP, linuxrc))
216IF_LN(APPLET_NOEXEC(ln, ln, _BB_DIR_BIN, _BB_SUID_DROP, ln)) 212IF_LN(APPLET_NOEXEC(ln, ln, _BB_DIR_BIN, _BB_SUID_DROP, ln))
217IF_LOAD_POLICY(APPLET(load_policy, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) 213IF_LOAD_POLICY(APPLET(load_policy, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
218IF_LOADFONT(APPLET(loadfont, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) 214IF_LOADFONT(APPLET(loadfont, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
@@ -241,7 +237,6 @@ IF_MAN(APPLET(man, _BB_DIR_SBIN, _BB_SUID_DROP))
241IF_MATCHPATHCON(APPLET(matchpathcon, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) 237IF_MATCHPATHCON(APPLET(matchpathcon, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
242IF_MD5SUM(APPLET_NOEXEC(md5sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_DROP, md5sum)) 238IF_MD5SUM(APPLET_NOEXEC(md5sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_DROP, md5sum))
243IF_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_DROP)) 239IF_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_DROP))
244IF_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_DROP))
245IF_MICROCOM(APPLET(microcom, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 240IF_MICROCOM(APPLET(microcom, _BB_DIR_USR_BIN, _BB_SUID_DROP))
246IF_MKDIR(APPLET_NOFORK(mkdir, mkdir, _BB_DIR_BIN, _BB_SUID_DROP, mkdir)) 241IF_MKDIR(APPLET_NOFORK(mkdir, mkdir, _BB_DIR_BIN, _BB_SUID_DROP, mkdir))
247IF_MKFS_VFAT(APPLET_ODDNAME(mkdosfs, mkfs_vfat, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_vfat)) 242IF_MKFS_VFAT(APPLET_ODDNAME(mkdosfs, mkfs_vfat, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_vfat))
@@ -284,7 +279,6 @@ IF_PIPE_PROGRESS(APPLET(pipe_progress, _BB_DIR_BIN, _BB_SUID_DROP))
284IF_PIVOT_ROOT(APPLET(pivot_root, _BB_DIR_SBIN, _BB_SUID_DROP)) 279IF_PIVOT_ROOT(APPLET(pivot_root, _BB_DIR_SBIN, _BB_SUID_DROP))
285IF_PKILL(APPLET_ODDNAME(pkill, pgrep, _BB_DIR_USR_BIN, _BB_SUID_DROP, pkill)) 280IF_PKILL(APPLET_ODDNAME(pkill, pgrep, _BB_DIR_USR_BIN, _BB_SUID_DROP, pkill))
286IF_POPMAILDIR(APPLET(popmaildir, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) 281IF_POPMAILDIR(APPLET(popmaildir, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
287IF_HALT(APPLET_ODDNAME(poweroff, halt, _BB_DIR_SBIN, _BB_SUID_DROP, poweroff))
288IF_PRINTENV(APPLET_NOFORK(printenv, printenv, _BB_DIR_BIN, _BB_SUID_DROP, printenv)) 282IF_PRINTENV(APPLET_NOFORK(printenv, printenv, _BB_DIR_BIN, _BB_SUID_DROP, printenv))
289IF_PRINTF(APPLET_NOFORK(printf, printf, _BB_DIR_USR_BIN, _BB_SUID_DROP, printf)) 283IF_PRINTF(APPLET_NOFORK(printf, printf, _BB_DIR_USR_BIN, _BB_SUID_DROP, printf))
290IF_PS(APPLET(ps, _BB_DIR_BIN, _BB_SUID_DROP)) 284IF_PS(APPLET(ps, _BB_DIR_BIN, _BB_SUID_DROP))
@@ -297,7 +291,6 @@ IF_READAHEAD(APPLET(readahead, _BB_DIR_USR_BIN, _BB_SUID_DROP))
297IF_READLINK(APPLET(readlink, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 291IF_READLINK(APPLET(readlink, _BB_DIR_USR_BIN, _BB_SUID_DROP))
298IF_READPROFILE(APPLET(readprofile, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) 292IF_READPROFILE(APPLET(readprofile, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
299IF_REALPATH(APPLET(realpath, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 293IF_REALPATH(APPLET(realpath, _BB_DIR_USR_BIN, _BB_SUID_DROP))
300IF_HALT(APPLET_ODDNAME(reboot, halt, _BB_DIR_SBIN, _BB_SUID_DROP, reboot))
301IF_REFORMIME(APPLET(reformime, _BB_DIR_BIN, _BB_SUID_DROP)) 294IF_REFORMIME(APPLET(reformime, _BB_DIR_BIN, _BB_SUID_DROP))
302IF_RENICE(APPLET(renice, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 295IF_RENICE(APPLET(renice, _BB_DIR_USR_BIN, _BB_SUID_DROP))
303IF_RESET(APPLET(reset, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 296IF_RESET(APPLET(reset, _BB_DIR_USR_BIN, _BB_SUID_DROP))
diff --git a/include/usage.src.h b/include/usage.src.h
index 555250366..084427cc0 100644
--- a/include/usage.src.h
+++ b/include/usage.src.h
@@ -1515,36 +1515,6 @@ INSERT
1515 "$ ls -la /tmp/busybox*\n" \ 1515 "$ ls -la /tmp/busybox*\n" \
1516 "-rw-rw-r-- 1 andersen andersen 554058 Apr 14 17:49 /tmp/busybox.tar.gz\n" 1516 "-rw-rw-r-- 1 andersen andersen 554058 Apr 14 17:49 /tmp/busybox.tar.gz\n"
1517 1517
1518#define halt_trivial_usage \
1519 "[-d DELAY] [-n] [-f]" IF_FEATURE_WTMP(" [-w]")
1520#define halt_full_usage "\n\n" \
1521 "Halt the system\n" \
1522 "\nOptions:" \
1523 "\n -d SEC Delay interval" \
1524 "\n -n Do not sync" \
1525 "\n -f Force (don't go through init)" \
1526 IF_FEATURE_WTMP( \
1527 "\n -w Only write a wtmp record" \
1528 )
1529
1530#define poweroff_trivial_usage \
1531 "[-d DELAY] [-n] [-f]"
1532#define poweroff_full_usage "\n\n" \
1533 "Halt and shut off power\n" \
1534 "\nOptions:" \
1535 "\n -d SEC Delay interval" \
1536 "\n -n Do not sync" \
1537 "\n -f Force (don't go through init)" \
1538
1539#define reboot_trivial_usage \
1540 "[-d DELAY] [-n] [-f]"
1541#define reboot_full_usage "\n\n" \
1542 "Reboot the system\n" \
1543 "\nOptions:" \
1544 "\n -d SEC Delay interval" \
1545 "\n -n Do not sync" \
1546 "\n -f Force (don't go through init)" \
1547
1548#define hdparm_trivial_usage \ 1518#define hdparm_trivial_usage \
1549 "[OPTIONS] [DEVICE]" 1519 "[OPTIONS] [DEVICE]"
1550#define hdparm_full_usage "\n\n" \ 1520#define hdparm_full_usage "\n\n" \
@@ -1863,138 +1833,6 @@ INSERT
1863 "\n -R N Pause services after N connects/min" \ 1833 "\n -R N Pause services after N connects/min" \
1864 "\n (default: 0 - disabled)" \ 1834 "\n (default: 0 - disabled)" \
1865 1835
1866#define init_trivial_usage \
1867 ""
1868#define init_full_usage "\n\n" \
1869 "Init is the parent of all processes"
1870
1871#define init_notes_usage \
1872"This version of init is designed to be run only by the kernel.\n" \
1873"\n" \
1874"BusyBox init doesn't support multiple runlevels. The runlevels field of\n" \
1875"the /etc/inittab file is completely ignored by BusyBox init. If you want\n" \
1876"runlevels, use sysvinit.\n" \
1877"\n" \
1878"BusyBox init works just fine without an inittab. If no inittab is found,\n" \
1879"it has the following default behavior:\n" \
1880"\n" \
1881" ::sysinit:/etc/init.d/rcS\n" \
1882" ::askfirst:/bin/sh\n" \
1883" ::ctrlaltdel:/sbin/reboot\n" \
1884" ::shutdown:/sbin/swapoff -a\n" \
1885" ::shutdown:/bin/umount -a -r\n" \
1886" ::restart:/sbin/init\n" \
1887"\n" \
1888"if it detects that /dev/console is _not_ a serial console, it will also run:\n" \
1889"\n" \
1890" tty2::askfirst:/bin/sh\n" \
1891" tty3::askfirst:/bin/sh\n" \
1892" tty4::askfirst:/bin/sh\n" \
1893"\n" \
1894"If you choose to use an /etc/inittab file, the inittab entry format is as follows:\n" \
1895"\n" \
1896" <id>:<runlevels>:<action>:<process>\n" \
1897"\n" \
1898" <id>:\n" \
1899"\n" \
1900" WARNING: This field has a non-traditional meaning for BusyBox init!\n" \
1901" The id field is used by BusyBox init to specify the controlling tty for\n" \
1902" the specified process to run on. The contents of this field are\n" \
1903" appended to \"/dev/\" and used as-is. There is no need for this field to\n" \
1904" be unique, although if it isn't you may have strange results. If this\n" \
1905" field is left blank, the controlling tty is set to the console. Also\n" \
1906" note that if BusyBox detects that a serial console is in use, then only\n" \
1907" entries whose controlling tty is either the serial console or /dev/null\n" \
1908" will be run. BusyBox init does nothing with utmp. We don't need no\n" \
1909" stinkin' utmp.\n" \
1910"\n" \
1911" <runlevels>:\n" \
1912"\n" \
1913" The runlevels field is completely ignored.\n" \
1914"\n" \
1915" <action>:\n" \
1916"\n" \
1917" Valid actions include: sysinit, respawn, askfirst, wait,\n" \
1918" once, restart, ctrlaltdel, and shutdown.\n" \
1919"\n" \
1920" The available actions can be classified into two groups: actions\n" \
1921" that are run only once, and actions that are re-run when the specified\n" \
1922" process exits.\n" \
1923"\n" \
1924" Run only-once actions:\n" \
1925"\n" \
1926" 'sysinit' is the first item run on boot. init waits until all\n" \
1927" sysinit actions are completed before continuing. Following the\n" \
1928" completion of all sysinit actions, all 'wait' actions are run.\n" \
1929" 'wait' actions, like 'sysinit' actions, cause init to wait until\n" \
1930" the specified task completes. 'once' actions are asynchronous,\n" \
1931" therefore, init does not wait for them to complete. 'restart' is\n" \
1932" the action taken to restart the init process. By default this should\n" \
1933" simply run /sbin/init, but can be a script which runs pivot_root or it\n" \
1934" can do all sorts of other interesting things. The 'ctrlaltdel' init\n" \
1935" actions are run when the system detects that someone on the system\n" \
1936" console has pressed the CTRL-ALT-DEL key combination. Typically one\n" \
1937" wants to run 'reboot' at this point to cause the system to reboot.\n" \
1938" Finally the 'shutdown' action specifies the actions to taken when\n" \
1939" init is told to reboot. Unmounting filesystems and disabling swap\n" \
1940" is a very good here.\n" \
1941"\n" \
1942" Run repeatedly actions:\n" \
1943"\n" \
1944" 'respawn' actions are run after the 'once' actions. When a process\n" \
1945" started with a 'respawn' action exits, init automatically restarts\n" \
1946" it. Unlike sysvinit, BusyBox init does not stop processes from\n" \
1947" respawning out of control. The 'askfirst' actions acts just like\n" \
1948" respawn, except that before running the specified process it\n" \
1949" displays the line \"Please press Enter to activate this console.\"\n" \
1950" and then waits for the user to press enter before starting the\n" \
1951" specified process.\n" \
1952"\n" \
1953" Unrecognized actions (like initdefault) will cause init to emit an\n" \
1954" error message, and then go along with its business. All actions are\n" \
1955" run in the order they appear in /etc/inittab.\n" \
1956"\n" \
1957" <process>:\n" \
1958"\n" \
1959" Specifies the process to be executed and its command line.\n" \
1960"\n" \
1961"Example /etc/inittab file:\n" \
1962"\n" \
1963" # This is run first except when booting in single-user mode\n" \
1964" #\n" \
1965" ::sysinit:/etc/init.d/rcS\n" \
1966" \n" \
1967" # /bin/sh invocations on selected ttys\n" \
1968" #\n" \
1969" # Start an \"askfirst\" shell on the console (whatever that may be)\n" \
1970" ::askfirst:-/bin/sh\n" \
1971" # Start an \"askfirst\" shell on /dev/tty2-4\n" \
1972" tty2::askfirst:-/bin/sh\n" \
1973" tty3::askfirst:-/bin/sh\n" \
1974" tty4::askfirst:-/bin/sh\n" \
1975" \n" \
1976" # /sbin/getty invocations for selected ttys\n" \
1977" #\n" \
1978" tty4::respawn:/sbin/getty 38400 tty4\n" \
1979" tty5::respawn:/sbin/getty 38400 tty5\n" \
1980" \n" \
1981" \n" \
1982" # Example of how to put a getty on a serial line (for a terminal)\n" \
1983" #\n" \
1984" #::respawn:/sbin/getty -L ttyS0 9600 vt100\n" \
1985" #::respawn:/sbin/getty -L ttyS1 9600 vt100\n" \
1986" #\n" \
1987" # Example how to put a getty on a modem line\n" \
1988" #::respawn:/sbin/getty 57600 ttyS2\n" \
1989" \n" \
1990" # Stuff to do when restarting the init process\n" \
1991" ::restart:/sbin/init\n" \
1992" \n" \
1993" # Stuff to do before rebooting\n" \
1994" ::ctrlaltdel:/sbin/reboot\n" \
1995" ::shutdown:/bin/umount -a -r\n" \
1996" ::shutdown:/sbin/swapoff -a\n"
1997
1998#define inotifyd_trivial_usage \ 1836#define inotifyd_trivial_usage \
1999 "PROG FILE1[:MASK]..." 1837 "PROG FILE1[:MASK]..."
2000#define inotifyd_full_usage "\n\n" \ 1838#define inotifyd_full_usage "\n\n" \
@@ -2651,13 +2489,6 @@ INSERT
2651 "the last line match .* to override this.)\n\n" \ 2489 "the last line match .* to override this.)\n\n" \
2652 ) 2490 )
2653 2491
2654#define mesg_trivial_usage \
2655 "[y|n]"
2656#define mesg_full_usage "\n\n" \
2657 "Control write access to your terminal\n" \
2658 " y Allow write access to your terminal\n" \
2659 " n Disallow write access to your terminal"
2660
2661#define microcom_trivial_usage \ 2492#define microcom_trivial_usage \
2662 "[-d DELAY] [-t TIMEOUT] [-s SPEED] [-X] TTY" 2493 "[-d DELAY] [-t TIMEOUT] [-s SPEED] [-X] TTY"
2663#define microcom_full_usage "\n\n" \ 2494#define microcom_full_usage "\n\n" \
diff --git a/init/Config.src b/init/Config.src
index 2cac3573e..5767c93f0 100644
--- a/init/Config.src
+++ b/init/Config.src
@@ -7,131 +7,4 @@ menu "Init Utilities"
7 7
8INSERT 8INSERT
9 9
10config INIT
11 bool "init"
12 default y
13 select FEATURE_SYSLOG
14 help
15 init is the first program run when the system boots.
16
17config FEATURE_USE_INITTAB
18 bool "Support reading an inittab file"
19 default y
20 depends on INIT
21 help
22 Allow init to read an inittab file when the system boot.
23
24config FEATURE_KILL_REMOVED
25 bool "Support killing processes that have been removed from inittab"
26 default n
27 depends on FEATURE_USE_INITTAB
28 help
29 When respawn entries are removed from inittab and a SIGHUP is
30 sent to init, this option will make init kill the processes
31 that have been removed.
32
33config FEATURE_KILL_DELAY
34 int "How long to wait between TERM and KILL (0 - send TERM only)" if FEATURE_KILL_REMOVED
35 range 0 1024
36 default 0
37 depends on FEATURE_KILL_REMOVED
38 help
39 With nonzero setting, init sends TERM, forks, child waits N
40 seconds, sends KILL and exits. Setting it too high is unwise
41 (child will hang around for too long and could actually kill
42 the wrong process!)
43
44config FEATURE_INIT_SCTTY
45 bool "Run commands with leading dash with controlling tty"
46 default y
47 depends on INIT
48 help
49 If this option is enabled, init will try to give a controlling
50 tty to any command which has leading hyphen (often it's "-/bin/sh").
51 More precisely, init will do "ioctl(STDIN_FILENO, TIOCSCTTY, 0)".
52 If device attached to STDIN_FILENO can be a ctty but is not yet
53 a ctty for other session, it will become this process' ctty.
54 This is not the traditional init behavour, but is often what you want
55 in an embedded system where the console is only accessed during
56 development or for maintenance.
57 NB: using cttyhack applet may work better.
58
59config FEATURE_INIT_SYSLOG
60 bool "Enable init to write to syslog"
61 default y
62 depends on INIT
63
64config FEATURE_EXTRA_QUIET
65 bool "Be _extra_ quiet on boot"
66 default y
67 depends on INIT
68 help
69 Prevent init from logging some messages to the console during boot.
70
71config FEATURE_INIT_COREDUMPS
72 bool "Support dumping core for child processes (debugging only)"
73 default y
74 depends on INIT
75 help
76 If this option is enabled and the file /.init_enable_core
77 exists, then init will call setrlimit() to allow unlimited
78 core file sizes. If this option is disabled, processes
79 will not generate any core files.
80
81config FEATURE_INITRD
82 bool "Support running init from within an initrd (not initramfs)"
83 default y
84 depends on INIT
85 help
86 Legacy support for running init under the old-style initrd. Allows
87 the name linuxrc to act as init, and it doesn't assume init is PID 1.
88
89 This does not apply to initramfs, which runs /init as PID 1 and
90 requires no special support.
91
92config INIT_TERMINAL_TYPE
93 string "Initial terminal type"
94 default "linux"
95 depends on INIT
96 help
97 This is the initial value set by init for the TERM environment
98 variable. This variable is used by programs which make use of
99 extended terminal capabilities.
100
101 Note that on Linux, init attempts to detect serial terminal and
102 sets TERM to "vt102" if one is found.
103
104config HALT
105 bool "poweroff, halt, and reboot"
106 default y
107 help
108 Stop all processes and either halt, reboot, or power off the system.
109
110config FEATURE_CALL_TELINIT
111 bool "Call telinit on shutdown and reboot"
112 default y
113 depends on HALT && !INIT
114 help
115 Call an external program (normally telinit) to facilitate
116 a switch to a proper runlevel.
117
118 This option is only available if you selected halt and friends,
119 but did not select init.
120
121config TELINIT_PATH
122 string "Path to telinit executable"
123 default "/sbin/telinit"
124 depends on FEATURE_CALL_TELINIT
125 help
126 When busybox halt and friends have to call external telinit
127 to facilitate proper shutdown, this path is to be used when
128 locating telinit executable.
129
130config MESG
131 bool "mesg"
132 default y
133 help
134 Mesg controls access to your terminal by others. It is typically
135 used to allow or disallow other users to write to your terminal
136
137endmenu 10endmenu
diff --git a/init/Kbuild.src b/init/Kbuild.src
index 32dd5a045..6b4fb7470 100644
--- a/init/Kbuild.src
+++ b/init/Kbuild.src
@@ -7,7 +7,3 @@
7lib-y:= 7lib-y:=
8 8
9INSERT 9INSERT
10lib-$(CONFIG_HALT) += halt.o
11lib-$(CONFIG_INIT) += init.o
12lib-$(CONFIG_MESG) += mesg.o
13lib-$(CONFIG_BOOTCHARTD) += bootchartd.o
diff --git a/init/bootchartd.c b/init/bootchartd.c
index f14d5c0fd..5a1b3e8e8 100644
--- a/init/bootchartd.c
+++ b/init/bootchartd.c
@@ -3,6 +3,10 @@
3 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 3 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
4 */ 4 */
5 5
6//applet:IF_BOOTCHARTD(APPLET(bootchartd, _BB_DIR_SBIN, _BB_SUID_DROP))
7
8//kbuild:lib-$(CONFIG_BOOTCHARTD) += bootchartd.o
9
6//config:config BOOTCHARTD 10//config:config BOOTCHARTD
7//config: bool "bootchartd" 11//config: bool "bootchartd"
8//config: default y 12//config: default y
diff --git a/init/halt.c b/init/halt.c
index 903953e80..47f1ef7b2 100644
--- a/init/halt.c
+++ b/init/halt.c
@@ -7,6 +7,68 @@
7 * Licensed under GPLv2, see file LICENSE in this source tree. 7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */ 8 */
9 9
10//applet:IF_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_DROP))
11//applet:IF_HALT(APPLET_ODDNAME(poweroff, halt, _BB_DIR_SBIN, _BB_SUID_DROP, poweroff))
12//applet:IF_HALT(APPLET_ODDNAME(reboot, halt, _BB_DIR_SBIN, _BB_SUID_DROP, reboot))
13
14//kbuild:lib-$(CONFIG_HALT) += halt.o
15
16//config:config HALT
17//config: bool "poweroff, halt, and reboot"
18//config: default y
19//config: help
20//config: Stop all processes and either halt, reboot, or power off the system.
21//config:
22//config:config FEATURE_CALL_TELINIT
23//config: bool "Call telinit on shutdown and reboot"
24//config: default y
25//config: depends on HALT && !INIT
26//config: help
27//config: Call an external program (normally telinit) to facilitate
28//config: a switch to a proper runlevel.
29//config:
30//config: This option is only available if you selected halt and friends,
31//config: but did not select init.
32//config:
33//config:config TELINIT_PATH
34//config: string "Path to telinit executable"
35//config: default "/sbin/telinit"
36//config: depends on FEATURE_CALL_TELINIT
37//config: help
38//config: When busybox halt and friends have to call external telinit
39//config: to facilitate proper shutdown, this path is to be used when
40//config: locating telinit executable.
41
42//usage:#define halt_trivial_usage
43//usage: "[-d DELAY] [-n] [-f]" IF_FEATURE_WTMP(" [-w]")
44//usage:#define halt_full_usage "\n\n"
45//usage: "Halt the system\n"
46//usage: "\nOptions:"
47//usage: "\n -d SEC Delay interval"
48//usage: "\n -n Do not sync"
49//usage: "\n -f Force (don't go through init)"
50//usage: IF_FEATURE_WTMP(
51//usage: "\n -w Only write a wtmp record"
52//usage: )
53//usage:
54//usage:#define poweroff_trivial_usage
55//usage: "[-d DELAY] [-n] [-f]"
56//usage:#define poweroff_full_usage "\n\n"
57//usage: "Halt and shut off power\n"
58//usage: "\nOptions:"
59//usage: "\n -d SEC Delay interval"
60//usage: "\n -n Do not sync"
61//usage: "\n -f Force (don't go through init)"
62//usage:
63//usage:#define reboot_trivial_usage
64//usage: "[-d DELAY] [-n] [-f]"
65//usage:#define reboot_full_usage "\n\n"
66//usage: "Reboot the system\n"
67//usage: "\nOptions:"
68//usage: "\n -d SEC Delay interval"
69//usage: "\n -n Do not sync"
70//usage: "\n -f Force (don't go through init)"
71
10#include "libbb.h" 72#include "libbb.h"
11#include "reboot.h" 73#include "reboot.h"
12 74
diff --git a/init/init.c b/init/init.c
index 5c0d11402..340731b8b 100644
--- a/init/init.c
+++ b/init/init.c
@@ -9,6 +9,237 @@
9 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
10 */ 10 */
11 11
12//applet:IF_INIT(APPLET(init, _BB_DIR_SBIN, _BB_SUID_DROP))
13//applet:IF_FEATURE_INITRD(APPLET_ODDNAME(linuxrc, init, _BB_DIR_ROOT, _BB_SUID_DROP, linuxrc))
14
15//kbuild:lib-$(CONFIG_INIT) += init.o
16
17//config:config INIT
18//config: bool "init"
19//config: default y
20//config: select FEATURE_SYSLOG
21//config: help
22//config: init is the first program run when the system boots.
23//config:
24//config:config FEATURE_USE_INITTAB
25//config: bool "Support reading an inittab file"
26//config: default y
27//config: depends on INIT
28//config: help
29//config: Allow init to read an inittab file when the system boot.
30//config:
31//config:config FEATURE_KILL_REMOVED
32//config: bool "Support killing processes that have been removed from inittab"
33//config: default n
34//config: depends on FEATURE_USE_INITTAB
35//config: help
36//config: When respawn entries are removed from inittab and a SIGHUP is
37//config: sent to init, this option will make init kill the processes
38//config: that have been removed.
39//config:
40//config:config FEATURE_KILL_DELAY
41//config: int "How long to wait between TERM and KILL (0 - send TERM only)" if FEATURE_KILL_REMOVED
42//config: range 0 1024
43//config: default 0
44//config: depends on FEATURE_KILL_REMOVED
45//config: help
46//config: With nonzero setting, init sends TERM, forks, child waits N
47//config: seconds, sends KILL and exits. Setting it too high is unwise
48//config: (child will hang around for too long and could actually kill
49//config: the wrong process!)
50//config:
51//config:config FEATURE_INIT_SCTTY
52//config: bool "Run commands with leading dash with controlling tty"
53//config: default y
54//config: depends on INIT
55//config: help
56//config: If this option is enabled, init will try to give a controlling
57//config: tty to any command which has leading hyphen (often it's "-/bin/sh").
58//config: More precisely, init will do "ioctl(STDIN_FILENO, TIOCSCTTY, 0)".
59//config: If device attached to STDIN_FILENO can be a ctty but is not yet
60//config: a ctty for other session, it will become this process' ctty.
61//config: This is not the traditional init behavour, but is often what you want
62//config: in an embedded system where the console is only accessed during
63//config: development or for maintenance.
64//config: NB: using cttyhack applet may work better.
65//config:
66//config:config FEATURE_INIT_SYSLOG
67//config: bool "Enable init to write to syslog"
68//config: default y
69//config: depends on INIT
70//config:
71//config:config FEATURE_EXTRA_QUIET
72//config: bool "Be _extra_ quiet on boot"
73//config: default y
74//config: depends on INIT
75//config: help
76//config: Prevent init from logging some messages to the console during boot.
77//config:
78//config:config FEATURE_INIT_COREDUMPS
79//config: bool "Support dumping core for child processes (debugging only)"
80//config: default y
81//config: depends on INIT
82//config: help
83//config: If this option is enabled and the file /.init_enable_core
84//config: exists, then init will call setrlimit() to allow unlimited
85//config: core file sizes. If this option is disabled, processes
86//config: will not generate any core files.
87//config:
88//config:config FEATURE_INITRD
89//config: bool "Support running init from within an initrd (not initramfs)"
90//config: default y
91//config: depends on INIT
92//config: help
93//config: Legacy support for running init under the old-style initrd. Allows
94//config: the name linuxrc to act as init, and it doesn't assume init is PID 1.
95//config:
96//config: This does not apply to initramfs, which runs /init as PID 1 and
97//config: requires no special support.
98//config:
99//config:config INIT_TERMINAL_TYPE
100//config: string "Initial terminal type"
101//config: default "linux"
102//config: depends on INIT
103//config: help
104//config: This is the initial value set by init for the TERM environment
105//config: variable. This variable is used by programs which make use of
106//config: extended terminal capabilities.
107//config:
108//config: Note that on Linux, init attempts to detect serial terminal and
109//config: sets TERM to "vt102" if one is found.
110
111//usage:#define init_trivial_usage
112//usage: ""
113//usage:#define init_full_usage "\n\n"
114//usage: "Init is the parent of all processes"
115//usage:
116//usage:#define init_notes_usage
117//usage: "This version of init is designed to be run only by the kernel.\n"
118//usage: "\n"
119//usage: "BusyBox init doesn't support multiple runlevels. The runlevels field of\n"
120//usage: "the /etc/inittab file is completely ignored by BusyBox init. If you want\n"
121//usage: "runlevels, use sysvinit.\n"
122//usage: "\n"
123//usage: "BusyBox init works just fine without an inittab. If no inittab is found,\n"
124//usage: "it has the following default behavior:\n"
125//usage: "\n"
126//usage: " ::sysinit:/etc/init.d/rcS\n"
127//usage: " ::askfirst:/bin/sh\n"
128//usage: " ::ctrlaltdel:/sbin/reboot\n"
129//usage: " ::shutdown:/sbin/swapoff -a\n"
130//usage: " ::shutdown:/bin/umount -a -r\n"
131//usage: " ::restart:/sbin/init\n"
132//usage: "\n"
133//usage: "if it detects that /dev/console is _not_ a serial console, it will also run:\n"
134//usage: "\n"
135//usage: " tty2::askfirst:/bin/sh\n"
136//usage: " tty3::askfirst:/bin/sh\n"
137//usage: " tty4::askfirst:/bin/sh\n"
138//usage: "\n"
139//usage: "If you choose to use an /etc/inittab file, the inittab entry format is as follows:\n"
140//usage: "\n"
141//usage: " <id>:<runlevels>:<action>:<process>\n"
142//usage: "\n"
143//usage: " <id>:\n"
144//usage: "\n"
145//usage: " WARNING: This field has a non-traditional meaning for BusyBox init!\n"
146//usage: " The id field is used by BusyBox init to specify the controlling tty for\n"
147//usage: " the specified process to run on. The contents of this field are\n"
148//usage: " appended to \"/dev/\" and used as-is. There is no need for this field to\n"
149//usage: " be unique, although if it isn't you may have strange results. If this\n"
150//usage: " field is left blank, the controlling tty is set to the console. Also\n"
151//usage: " note that if BusyBox detects that a serial console is in use, then only\n"
152//usage: " entries whose controlling tty is either the serial console or /dev/null\n"
153//usage: " will be run. BusyBox init does nothing with utmp. We don't need no\n"
154//usage: " stinkin' utmp.\n"
155//usage: "\n"
156//usage: " <runlevels>:\n"
157//usage: "\n"
158//usage: " The runlevels field is completely ignored.\n"
159//usage: "\n"
160//usage: " <action>:\n"
161//usage: "\n"
162//usage: " Valid actions include: sysinit, respawn, askfirst, wait,\n"
163//usage: " once, restart, ctrlaltdel, and shutdown.\n"
164//usage: "\n"
165//usage: " The available actions can be classified into two groups: actions\n"
166//usage: " that are run only once, and actions that are re-run when the specified\n"
167//usage: " process exits.\n"
168//usage: "\n"
169//usage: " Run only-once actions:\n"
170//usage: "\n"
171//usage: " 'sysinit' is the first item run on boot. init waits until all\n"
172//usage: " sysinit actions are completed before continuing. Following the\n"
173//usage: " completion of all sysinit actions, all 'wait' actions are run.\n"
174//usage: " 'wait' actions, like 'sysinit' actions, cause init to wait until\n"
175//usage: " the specified task completes. 'once' actions are asynchronous,\n"
176//usage: " therefore, init does not wait for them to complete. 'restart' is\n"
177//usage: " the action taken to restart the init process. By default this should\n"
178//usage: " simply run /sbin/init, but can be a script which runs pivot_root or it\n"
179//usage: " can do all sorts of other interesting things. The 'ctrlaltdel' init\n"
180//usage: " actions are run when the system detects that someone on the system\n"
181//usage: " console has pressed the CTRL-ALT-DEL key combination. Typically one\n"
182//usage: " wants to run 'reboot' at this point to cause the system to reboot.\n"
183//usage: " Finally the 'shutdown' action specifies the actions to taken when\n"
184//usage: " init is told to reboot. Unmounting filesystems and disabling swap\n"
185//usage: " is a very good here.\n"
186//usage: "\n"
187//usage: " Run repeatedly actions:\n"
188//usage: "\n"
189//usage: " 'respawn' actions are run after the 'once' actions. When a process\n"
190//usage: " started with a 'respawn' action exits, init automatically restarts\n"
191//usage: " it. Unlike sysvinit, BusyBox init does not stop processes from\n"
192//usage: " respawning out of control. The 'askfirst' actions acts just like\n"
193//usage: " respawn, except that before running the specified process it\n"
194//usage: " displays the line \"Please press Enter to activate this console.\"\n"
195//usage: " and then waits for the user to press enter before starting the\n"
196//usage: " specified process.\n"
197//usage: "\n"
198//usage: " Unrecognized actions (like initdefault) will cause init to emit an\n"
199//usage: " error message, and then go along with its business. All actions are\n"
200//usage: " run in the order they appear in /etc/inittab.\n"
201//usage: "\n"
202//usage: " <process>:\n"
203//usage: "\n"
204//usage: " Specifies the process to be executed and its command line.\n"
205//usage: "\n"
206//usage: "Example /etc/inittab file:\n"
207//usage: "\n"
208//usage: " # This is run first except when booting in single-user mode\n"
209//usage: " #\n"
210//usage: " ::sysinit:/etc/init.d/rcS\n"
211//usage: " \n"
212//usage: " # /bin/sh invocations on selected ttys\n"
213//usage: " #\n"
214//usage: " # Start an \"askfirst\" shell on the console (whatever that may be)\n"
215//usage: " ::askfirst:-/bin/sh\n"
216//usage: " # Start an \"askfirst\" shell on /dev/tty2-4\n"
217//usage: " tty2::askfirst:-/bin/sh\n"
218//usage: " tty3::askfirst:-/bin/sh\n"
219//usage: " tty4::askfirst:-/bin/sh\n"
220//usage: " \n"
221//usage: " # /sbin/getty invocations for selected ttys\n"
222//usage: " #\n"
223//usage: " tty4::respawn:/sbin/getty 38400 tty4\n"
224//usage: " tty5::respawn:/sbin/getty 38400 tty5\n"
225//usage: " \n"
226//usage: " \n"
227//usage: " # Example of how to put a getty on a serial line (for a terminal)\n"
228//usage: " #\n"
229//usage: " #::respawn:/sbin/getty -L ttyS0 9600 vt100\n"
230//usage: " #::respawn:/sbin/getty -L ttyS1 9600 vt100\n"
231//usage: " #\n"
232//usage: " # Example how to put a getty on a modem line\n"
233//usage: " #::respawn:/sbin/getty 57600 ttyS2\n"
234//usage: " \n"
235//usage: " # Stuff to do when restarting the init process\n"
236//usage: " ::restart:/sbin/init\n"
237//usage: " \n"
238//usage: " # Stuff to do before rebooting\n"
239//usage: " ::ctrlaltdel:/sbin/reboot\n"
240//usage: " ::shutdown:/bin/umount -a -r\n"
241//usage: " ::shutdown:/sbin/swapoff -a\n"
242
12#include "libbb.h" 243#include "libbb.h"
13#include <syslog.h> 244#include <syslog.h>
14#include <paths.h> 245#include <paths.h>
diff --git a/init/mesg.c b/init/mesg.c
index ef5f0eb66..b560df205 100644
--- a/init/mesg.c
+++ b/init/mesg.c
@@ -7,6 +7,24 @@
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9 9
10//applet:IF_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_DROP))
11
12//kbuild:lib-$(CONFIG_MESG) += mesg.o
13
14//config:config MESG
15//config: bool "mesg"
16//config: default y
17//config: help
18//config: Mesg controls access to your terminal by others. It is typically
19//config: used to allow or disallow other users to write to your terminal
20
21//usage:#define mesg_trivial_usage
22//usage: "[y|n]"
23//usage:#define mesg_full_usage "\n\n"
24//usage: "Control write access to your terminal\n"
25//usage: " y Allow write access to your terminal\n"
26//usage: " n Disallow write access to your terminal"
27
10#include "libbb.h" 28#include "libbb.h"
11 29
12#ifdef USE_TTY_GROUP 30#ifdef USE_TTY_GROUP