aboutsummaryrefslogtreecommitdiff
path: root/init/init.c
Commit message (Collapse)AuthorAgeFilesLines
* libbb: introduce and use sleep1()Gravatar Denys Vlasenko2020-11-291-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | function old new delta sleep1 - 9 +9 run_shutdown_and_kill_processes 97 95 -2 restore_state_and_exit 116 114 -2 reread_partition_table 67 65 -2 flush_buffer_cache 80 78 -2 chat_main 1302 1300 -2 timeout_main 310 307 -3 telnet_main 1235 1232 -3 stop_handler 86 83 -3 process_action 1078 1075 -3 nbdclient_main 1185 1182 -3 init_main 789 786 -3 getty_main 1541 1538 -3 do_time 410 407 -3 runsv_main 1682 1677 -5 pause_and_low_level_reboot 59 54 -5 inetd_main 1917 1911 -6 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/16 up/down: 9/-50) Total: -41 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: improve handling of signals racing with each otherGravatar Denys Vlasenko2019-12-031-159/+119
| | | | | | | | | | | | | | | | | Before this change, a request to reboot could be "overwritten" by e.g. SIGHUP. function old new delta init_main 709 793 +84 packed_usage 33273 33337 +64 run_actions 109 117 +8 stop_handler 87 88 +1 check_delayed_sigs 340 335 -5 run 214 198 -16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/2 up/down: 157/-21) Total: 136 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: if tcgetattr() fails, don't even try to tcsetattr()Gravatar Denys Vlasenko2019-12-021-9/+8
| | | | | | | function old new delta set_sane_term 111 114 +3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: reduce the overhead of single parameter bb_error_msg() callsGravatar James Byrne2019-07-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower overhead call to bb_perror_msg() when only a string was being printed with no parameters. This saves space for some CPU architectures because it avoids the overhead of a call to a variadic function. However there has never been a simple version of bb_error_msg(), and since 2007 many new calls to bb_perror_msg() have been added that only take a single parameter and so could have been using bb_simple_perror_message(). This changeset introduces 'simple' versions of bb_info_msg(), bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and bb_herror_msg_and_die(), and replaces all calls that only take a single parameter, or use something like ("%s", arg), with calls to the corresponding 'simple' version. Since it is likely that single parameter calls to the variadic functions may be accidentally reintroduced in the future a new debugging config option WARN_SIMPLE_MSG has been introduced. This uses some macro magic which will cause any such calls to generate a warning, but this is turned off by default to avoid use of the unpleasant macros in normal circumstances. This is a large changeset due to the number of calls that have been replaced. The only files that contain changes other than simple substitution of function calls are libbb.h, libbb/herror_msg.c, libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c, networking/udhcp/common.h and util-linux/mdev.c additonal macros have been added for logging so that single parameter and multiple parameter logging variants exist. The amount of space saved varies considerably by architecture, and was found to be as follows (for 'defconfig' using GCC 7.4): Arm: -92 bytes MIPS: -52 bytes PPC: -1836 bytes x86_64: -938 bytes Note that for the MIPS architecture only an exception had to be made disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h) because it made these files larger on MIPS. Signed-off-by: James Byrne <james.byrne@origamienergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* config: update size informationGravatar Denys Vlasenko2018-12-281-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: hopefully fix "rebooting" in containersGravatar Denys Vlasenko2018-09-221-2/+7
| | | | | | | function old new delta pause_and_low_level_reboot 48 57 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb.h: always include sys/resource.hGravatar Denys Vlasenko2018-04-081-1/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: stop using static dataGravatar Denys Vlasenko2018-01-101-16/+24
| | | | | | | | | | | | | function old new delta init_action_list 4 - -4 new_init_action 148 142 -6 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-10) Total: -10 bytes text data bss dec hex filename 927839 481 6832 935152 e44f0 busybox_old 927833 481 6824 935138 e44e2 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: reduce the window when init can lose reboot/poweroff signalsGravatar Denys Vlasenko2017-11-021-23/+8
| | | | | | | function old new delta init_main 695 712 +17 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* use %m printf specifier where appropriateGravatar Denys Vlasenko2017-09-291-3/+5
| | | | | | | | | | | | | | | function old new delta out 85 75 -10 udhcpd_main 1472 1461 -11 open_stdio_to_tty 98 85 -13 init_exec 245 232 -13 udhcpc_main 2763 2749 -14 do_cmd 4771 4755 -16 status_line_bold_errno 32 14 -18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/7 up/down: 0/-95) Total: -95 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* regularize format of source file headers, no code changesGravatar Denys Vlasenko2017-09-181-1/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* config: deindent all help textsGravatar Denys Vlasenko2017-07-211-43/+43
| | | | | | Those two spaces after tab have no effect, and always a nuisance when editing. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Update menuconfig items with approximate applet sizesGravatar Denys Vlasenko2017-07-181-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: dont send "Sent SIGTERM to all" msg to syslog: we just TERMed it!Gravatar Denys Vlasenko2017-04-071-18/+22
| | | | | | While at it, explain FEATURE_INIT_SYSLOG Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: rename FEATURE_EXTRA_QUIET -> FEATURE_INIT_QUIETGravatar Denys Vlasenko2017-01-101-6/+4
| | | | | | The former name had no INIT anywhere in its name, sounded generic Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Big cleanup in config help and descriptionGravatar Denys Vlasenko2017-01-101-2/+2
| | | | | | | | | | | | | Redundant help texts (one which only repeats the description) are deleted. Descriptions and help texts are trimmed. Some config options are moved, even across menus. No config option _names_ are changed. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Tweak some config defaults; fix MODPROBE_SMALL ordering in "make config"Gravatar Denys Vlasenko2016-12-221-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: fix for FreeBSD console opening. Closes 9031Gravatar Denys Vlasenko2016-08-221-0/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Rename FEATURE_INITRD to LINUXRC and make it separate, not an alias to initGravatar Denys Vlasenko2016-03-311-20/+21
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: make the command-line rewrite optionalGravatar Nicolas Carrier2016-02-111-5/+22
| | | | | | | | | | | | | | | When launched as PID 1 and after parsing its arguments, init wipes all all of them except argv[0] and rewrites argv[0] to contain only "init", so that its command-line appears solely as "init" in tools such as ps. This patch adds the FEATURE_INIT_MODIFY_CMDLINE which, if set to n, will make init preserve all its arguments including argv[0], be they parsed or ignored. The original command-line used to launch init can then be retrieved in /proc/1/cmdline on Linux, for example. Signed-off-by: Nicolas Carrier <nicolas.carrier@parrot.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Fix compiling with musl's utmp stubsGravatar Kylie McClain2016-02-011-1/+0
| | | | | | | | | | | | | | | | | | | This patch fixes compiling busybox with FEATURE_UTMP and _WTMP enabled. musl, while not really support utmp/wtmp, provides stub functions, as well as variables such as _PATH_UTMP, so that programs using utmp or wtmp can still compile fine. My reasoning for this patch is that on Exherbo, I'm currently trying to get us to be able to use the same busybox config file for both glibc and musl systems, using utmp/wtmp on systems that support it, and using the stubs on musl without needing two different configs. As of latest musl git, it provides all utmp functions needed; 1.1.12 doesn't, but I sent a patch to Rich to add the utmp{,x}name functions expected to exist, which was merged into musl upstream. Signed-off-by: Kylie McClain <somasissounds@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* remove global "jmp_buf die_jmp" from !FEATURE_PREFER_APPLETS buildsGravatar Denys Vlasenko2015-10-091-2/+7
| | | | | | | | | | | | | | | | | | | | | function old new delta xfunc_has_died - 21 +21 sleep_much - 12 +12 sleep10 - 9 +9 die_func - 4 +4 fflush_stdout_and_exit 35 36 +1 builtin_type 121 119 -2 die_sleep 4 - -4 xfunc_die 60 24 -36 hush_main 1128 1011 -117 die_jmp 156 - -156 ------------------------------------------------------------------------------ (add/remove: 4/2 grow/shrink: 1/3 up/down: 47/-315) Total: -268 bytes text data bss dec hex filename 939992 992 17652 958636 ea0ac busybox_old 939880 992 17496 958368 e9fa0 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: code shrink by factoring out common update_utmp_DEAD_PROCESSGravatar Denys Vlasenko2015-01-051-5/+1
| | | | | | | | | | function old new delta update_utmp_DEAD_PROCESS - 17 +17 telnetd_main 1685 1674 -11 mark_terminated 56 45 -11 handle_sigchld 74 63 -11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: do not run shutdown/reexec actions from signal handlerGravatar Denys Vlasenko2014-11-211-20/+30
| | | | | | | | | | | | | | this is racy wrt various libc functions such as syslog() function old new delta check_delayed_sigs 182 352 +170 init_main 772 728 -44 restart_handler 74 - -74 halt_reboot_pwoff 79 - -79 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 1/1 up/down: 170/-197) Total: -27 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: do not fail build if SIGPWR is not definedGravatar Michael Tokarev2014-01-301-0/+2
| | | | | | | | | Apparently, some *BSD variants (and maybe some other OSes) does not define SIGPWR signal. So since commit 760fc6debcba8c, busybox fails to build on such platforms. Fix this. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: halt on SIGPWR tooGravatar Bogdan Purcareata2013-11-261-3/+4
| | | | | | | | | | | | Most init processes implement a handler for SIGPWR that gracefully stops all child processes when shutting down a machine. Some other technologies rely on this signal - e.g. Busybox powered LXC containers. This patch makes busybox init halt when receiving SIGPWR. Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: move nuke_str() from passwd into libbbGravatar Denys Vlasenko2013-11-191-1/+1
| | | | | | | | | | | | function old new delta nuke_str - 15 +15 ask_and_check_password_extended 215 206 -9 init_main 781 771 -10 nuke_str 27 - -27 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 0/2 up/down: 15/-46) Total: -31 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: fix illegal memory access when max message length is reachedGravatar Yuan-Hsiang Lee2013-11-031-2/+2
| | | | | Signed-off-by: Yuan-Hsiang Lee <yhlee@ubnt.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: better --help textGravatar Denys Vlasenko2013-10-121-6/+13
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: don't srop unterminated processes' entries during inittab reloadGravatar Paulius Zaleckas2013-08-161-3/+10
| | | | | | | | | | | | | This feature was removed in 72c99af It is useful when process is removed from inittab and later added back, but never terminated. It prevents init from spawning duplicate. function old new delta check_delayed_sigs 176 182 +6 Signed-off-by: Paulius Zaleckas <paulius.zaleckas@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: don't use fixed size buffer for commandGravatar Denys Vlasenko2013-08-161-9/+13
| | | | | | | | | | | | | | | We store init actions forever. 256 bytes per action means that a typical inittab of ~10 commands uses 2.5k just to remember command strings - which are usually _much_ shorter than 256 bytes. At a cost of a bit more code, it's possible to allocate only actually needed amount. function old new delta init_exec 224 248 +24 new_init_action 140 142 +2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: remove special-case code for machines with less tham 1 MB of RAM.Gravatar Denys Vlasenko2013-05-211-15/+18
| | | | | | | function old new delta init_main 920 781 -139 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* examples/inittab: fix a few incorrect statements about initGravatar Denys Vlasenko2013-03-291-8/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* whitespace cleanup. no code changesGravatar Denys Vlasenko2013-01-141-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: add a segv debugging aid, disabled by defaultGravatar Denys Vlasenko2012-01-301-0/+51
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: code shrink -4 bytesGravatar Denys Vlasenko2011-12-051-4/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: utmp update of DEAD_PROCESS was misplaced, and could be skipped. Fixing.Gravatar Denys Vlasenko2011-12-051-3/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: work around sysinfo.h versus linux/*.h problemsGravatar Denys Vlasenko2011-07-261-1/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: fix a case where execv's 1st arg was wrongGravatar Denys Vlasenko2011-03-211-0/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* move utmp.h include to libbb.hGravatar Denys Vlasenko2011-01-251-3/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* mass removal of underscores from _BB_DIR_foo and _BB_SUID_fooGravatar Denys Vlasenko2011-01-181-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: simpler handling of leading dash in commandsGravatar Denys Vlasenko2010-12-251-9/+11
| | | | | | | function old new delta init_exec 233 219 -14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: if PID!=1, show clearer error message. move usage text closer to main()Gravatar Denys Vlasenko2010-11-021-134/+137
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: do not sleep forever on usage errorsGravatar Denys Vlasenko2010-10-251-4/+13
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: do not clear CRTSCTS (fix from Debian bug 528560)Gravatar Denys Vlasenko2010-10-241-3/+6
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init/*: move applet/kbuild/config/help bits into applet source filesGravatar Denys Vlasenko2010-10-121-0/+231
| | | | Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
* *: make GNU licensing statement forms more regularGravatar Denys Vlasenko2010-08-161-1/+1
| | | | | | | This change retains "or later" state! No licensing _changes_ here, only form is adjusted (article, space between "GPL" and "v2" and so on). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init: make the initial $TERM value configurableGravatar Jeremie Koenig2010-07-191-1/+1
| | | | | Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init,halt: portability improvementsGravatar Jeremie Koenig2010-07-191-8/+8
| | | | | | | | | | | * make init and halt use the same RB_* constants for reboot() * conditionalize the Linux-specific code Inspired by init.init.diff from the Debian kFreeBSD patches at: http://svn.debian.org/viewsvn/d-i/people/slackydeb/kfreebsd/busybox/1.14/debian Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* init,loginutils: termios portability fixesGravatar Jeremie Koenig2010-07-191-1/+16
| | | | | Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>