Commit Graph

519 Commits

Author SHA1 Message Date
Denis Vlasenko
671ca33aa1 init: make it NOMMU-capable
httpd: trivial compile fix
2008-02-19 14:13:20 +00:00
Denis Vlasenko
a58a637bed init: fix comments 2008-02-19 12:10:18 +00:00
Denis Vlasenko
99a61842df init: HUP should not be temporarily set to "restart",
we use it for config reload, and we have QUIT for "restart".
2008-02-19 12:08:38 +00:00
Denis Vlasenko
a37e7134f7 init: fix bug 1111: restart actions were not splitting words:
::restart:/sbin/rc restart
resulted in:
exec of '/sbin/rc restart' failed: No such file or directory
2008-02-19 02:57:07 +00:00
Denis Vlasenko
25591c322c libbb: introduce bb_signals and bb_signals_recursive,
which sets same handler for many signals. sig_catch is nuked
(bb_signals_recursive is more descriptive name).
*: use them as appropriate. 

function                                             old     new   delta
bb_signals_recursive                                   -      95     +95
bb_signals                                             -      52     +52
run_command                                          258     273     +15
svlogd_main                                         1368    1377      +9
runsv_main                                          1746    1752      +6
runsvdir_main                                       1643    1646      +3
UNSPEC_print                                          64      66      +2
time_main                                           1128    1127      -1
...
resize_main                                          246     210     -36
sig_catch                                             63       -     -63
set_fatal_sighandler                                  85      14     -71
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 5/24 up/down: 182/-548)        Total: -366 bytes
2008-02-16 22:58:56 +00:00
Denis Vlasenko
c882f341ce init: allow last line to be not terminated by '\n' 2008-01-29 09:56:21 +00:00
Bernhard Reutner-Fischer
f470196a41 - fix conflicting decls of syslog related facilitynames and prioritynames tables 2008-01-27 12:50:12 +00:00
Denis Vlasenko
680b86afbb halt: write wtmp entry if wtmp support is enabled 2008-01-24 02:28:00 +00:00
Denis Vlasenko
474d1c57c8 whitespace fixes 2008-01-07 19:06:47 +00:00
Denis Vlasenko
21e20cb4ad init: wait for orphaned children too while waiting
for sysinit-like processes (Harald Küthe <harald-tuxbox@arcor.de>)
2008-01-04 15:10:47 +00:00
Denis Vlasenko
fb0eba706c libbb: introduce and use safe_waitpid (loops in EINTR)
*: use more approproate (shorter) versions of wait()

function                                             old     new   delta
safe_waitpid                                           -      48     +48
wait_any_nohang                                        -      17     +17
send_tree                                            365     369      +4
processorstop                                        432     435      +3
text_yank                                            110     108      -2
make_human_readable_str                              202     200      -2
crond_main                                          1368    1366      -2
handle_sigchld                                        49      43      -6
reapchild                                            166     159      -7
custom                                               260     250     -10
checkscript                                          191     177     -14
wait_nohang                                           17       -     -17
wait_pid                                              43       -     -43
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 2/7 up/down: 72/-103)           Total: -31 bytes
2008-01-02 19:55:04 +00:00
Denis Vlasenko
d55268d0d4 init: don't spawn tons of waiting children, one is enough
init: shrink signal disabling code
init: rename some functions
   text    data     bss     dec     hex filename
 778657     832    7344  786833   c0191 busybox_old
 778445     832    7344  786621   c00bd busybox_unstripped
2007-12-26 18:32:58 +00:00
Denis Vlasenko
5adfa44101 init: sometimes, #ifdefs are cleaner. 2007-12-25 16:08:53 +00:00
Mike Frysinger
bb50fdfe07 convert #if to if -- let gcc optimize away dead code for us 2007-12-25 04:30:14 +00:00
Denis Vlasenko
ec5631b6d6 init: add FEATURE_KILL_REMOVED (Eugene Bordenkircher <eugebo@gmail.com>)
init: slight size optimization
2007-12-25 01:08:58 +00:00
Denis Vlasenko
d7e2e127a9 cttyhack: add missing ';'
init: remove pointless access() check
2007-12-10 08:40:29 +00:00
Denis Vlasenko
2afabe8b83 init: remove superfluous forks and messing up with argv[0]
cttyhack: add stealing of ctty
2007-12-10 07:06:04 +00:00
Denis Vlasenko
70ab28f907 syslogd: use DEV_CONSOLE consistently
init: remove obsolete comment
2007-11-18 05:43:05 +00:00
Denis Vlasenko
f6ccc62c70 init: fix bug 1584: improper check for fork error 2007-11-10 01:57:35 +00:00
Denis Vlasenko
6bef3d1d22 fbset: fix buglet where we were using wrong pointer
readahead: stop using stdio.h
*: style fixes
2007-11-06 03:05:54 +00:00
Denis Vlasenko
9b49a5ed85 add -fvisibility=hidden to CC flags, mark XXX_main functions
EXTERNALLY_VISIBLE. 5% size reduction of libbusybox.so
2007-10-11 10:05:36 +00:00
Denis Vlasenko
0c97c9d437 'simple' error message functions by Loic Grenie <loic.grenie@gmail.com>.
263 bytes saved.
2007-10-01 11:58:38 +00:00
Denis Vlasenko
96e1b38586 introduce and use close_on_exec_on(fd). -50 bytes. 2007-09-30 23:50:48 +00:00
Denis Vlasenko
818322b9b1 *: kill bb_get_last_path_component, replace with two functions
(one which strips trailing slash and one which does not)
wget: straighten out as a result of above change
   text    data     bss     dec     hex filename
   5056       1       0    5057    13c1 busybox.t4/networking/wget.o
   5022       0       0    5022    139e busybox.t5/networking/wget.o
2007-09-24 18:27:04 +00:00
Denis Vlasenko
fe7cd642b0 don't pass argc in getopt32, it's superfluous
(add/remove: 0/0 grow/shrink: 12/131 up/down: 91/-727) Total: -636 bytes
   text    data     bss     dec     hex filename
 773469    1058   11092  785619   bfcd3 busybox_old
 772644    1058   11092  784794   bf99a busybox_unstripped
2007-08-18 15:32:12 +00:00
Denis Vlasenko
6ca409e0e4 trylink: produce even more info about final link stage
trylink: explain how to modify link and drastically decrease amount
  of padding (unfortunately, needs hand editing ATM).
*: add ALIGN1 / ALIGN2 to global strings and arrays of bytes and shorts

size saving: 0.5k
2007-08-12 20:58:27 +00:00
Denis Vlasenko
d8540f71ac init: make sure fd 0,1,2 are not closed, + related optimizations.
init_main                                            929     920      -9
bb_daemonize_or_rexec                                145     127     -18
2007-06-14 07:53:06 +00:00
Denis Vlasenko
ca525b4f24 *: BB_BANNER -> bb_banner (it is not a const or #define)!
correct_password: explain in detail why it is ok to use bb_banner
fsck_minix: make it print bb version, not it's own (outdated/irrelevant) one

Marginal size difference:
   text    data     bss     dec     hex filename
 679119    2700   15632  697451   aa46b busybox_old
 679091    2700   15632  697423   aa44f busybox_unstripped
2007-06-13 12:27:17 +00:00
Denis Vlasenko
f5f75c5e82 remove nearly-duplicate PATHs in several places
function                                             old     new   delta
bb_PATH_root_path                                      -      35     +35
varunset                                              60      58      -2
arith                                               2042    2033      -9
bb_default_root_login_path                            30       -     -30
.rodata                                           128794  128762     -32
which_main                                           152     117     -35
defpathvar                                            40       -     -40
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 0/4 up/down: 35/-148)          Total: -113 bytes
2007-06-12 22:35:19 +00:00
Denis Vlasenko
9a7d38fe24 delete tons of extra #includes 2007-05-31 22:42:12 +00:00
Denis Vlasenko
b6adbf1be2 usage.c: remove reference to busybox.h
*: s/include "busybox.h"/include "libbb.h"
2007-05-26 19:00:18 +00:00
Denis Vlasenko
51742f4bb0 style fixes. No code changes 2007-04-12 00:32:05 +00:00
Bernhard Reutner-Fischer
febe3c4211 - sed -e "s/char[[:space:]]*\*[[:space:]]*argv\[\]/char **argv/g" 2007-04-04 20:52:03 +00:00
Denis Vlasenko
219d14d514 random style fixes (extra spaces deleted) 2007-03-24 15:40:16 +00:00
Denis Vlasenko
ccd412da09 decouple INIT and SYSLOGD (patch by Eric Spakman E.Spakman@inter.nl.net) 2007-03-05 19:55:30 +00:00
Denis Vlasenko
d238a477b7 init: fix handling of stdio file descriptors 2007-03-05 19:22:04 +00:00
Denis Vlasenko
966bb43766 init: de-indent a block of code 2007-02-27 19:20:33 +00:00
Denis Vlasenko
b716754199 init: trivial compile fix 2007-02-27 19:20:00 +00:00
Denis Vlasenko
7a2ca5e111 init: stop doing silly things with the console (-400 bytes)
init_shared.[ch]: unused, thus deleted
2007-02-21 00:15:20 +00:00
Denis Vlasenko
ec27feb045 init: code readability enhancements; very small code changes 2007-02-17 15:52:02 +00:00
Bernhard Reutner-Fischer
d818dcc72a - whitespace cleanup and add a possible shrinkage suggestion 2007-02-16 17:17:07 +00:00
Denis Vlasenko
06af216528 suppress warnings about easch <applet>_main() having
no preceding prototype
2007-02-03 17:28:39 +00:00
Denis Vlasenko
4c97863109 assorted fixes for bugs found with randomconfig 2007-02-03 03:31:13 +00:00
Denis Vlasenko
e968fcd562 lineedit: add missing #if/#endif
init: fix warnings
2007-02-03 02:42:47 +00:00
Denis Vlasenko
4921b54f37 Add BB_EXEC[LV]P() which encapsulate FEATURE_EXEC_PREFER_APPLETS
(patch from Gabriel L. Somlo <somlo@cmu.edu>)
2007-02-03 02:17:41 +00:00
Denis Vlasenko
06c0a71d23 preparatory patch for -Wwrite-strings #3 2007-01-29 22:51:44 +00:00
Denis Vlasenko
b6aae0f381 preparatory patch for -Wwrite-strings #2 2007-01-29 22:51:25 +00:00
Denis Vlasenko
2f0c0d0b88 Introduce FEATURE_EXEC_PREFER_APPLETS = "re-execute our own
executable if we asked to exec someting with argv[0] == known_applet"
Use it in init. Also respect PATH in init, remove explicit "/sbin" etc
from exec. Patch by Gabriel L. Somlo <somlo@cmu.edu>
2007-01-21 00:41:04 +00:00
Denis Vlasenko
9b1381fd2f convert calloc to xzalloc
fix sleep-on-die option
2007-01-03 02:56:00 +00:00
Denis Vlasenko
bf0a201008 style fixes
last xcalloc replaced by xzalloc
2006-12-26 10:42:51 +00:00
Denis Vlasenko
bf66fbc8e2 introduce LONE_CHAR (optimized strcmp with one-char string) 2006-12-21 13:23:14 +00:00
Denis Vlasenko
35fb512728 PID should be stored in pid_t, not int or long.
find_pid_by_name() was returning 0 or -1 in last array element,
but -1 was never checked. We can use just 0 intead.
2006-11-01 09:16:49 +00:00
Denis Vlasenko
dca0b707c0 reshuffle libbb.h contents so that order of decls makes sense
Found bad typo in largefile support :)
2006-10-27 09:05:02 +00:00
Denis Vlasenko
e1a0d486e4 message string changes, mostly for consistency, also -32 bytes in .rodata 2006-10-20 13:28:22 +00:00
Denis Vlasenko
ea62077b85 add open_read_close() and similar stuff 2006-10-14 02:23:43 +00:00
Denis Vlasenko
1385899416 attempt to regularize atoi mess. 2006-10-08 12:49:22 +00:00
Denis Vlasenko
7d219aab70 build system overhaul 2006-10-05 10:17:08 +00:00
Denis Vlasenko
8f8f268cfd bb_applet_name -> applet_name 2006-10-03 21:00:43 +00:00
Denis Vlasenko
67b23e6043 getopt_ulflags -> getopt32.
It is impossible to formulate sane ABI based on
size of ulong because it can be 32-bit or 64-bit.
Basically it means that you cannot portably use
more that 32 option chars in one call anyway...
Make it explicit.
2006-10-03 21:00:06 +00:00
Denis Vlasenko
ce97960a6e usage.h: remove ugly tricks. We have USE_FEATURE_xxx now.
Few bugs are now exposed...
2006-09-27 23:31:08 +00:00
Rob Landley
e9a7a6212b Change license statements (and clean up headers) on some of the files that
Erik or I are primary copyright holders on.
2006-09-22 02:52:41 +00:00
Denis Vlasenko
049d6b8c08 Add CONFIG_FEATURE_SYSLOG which controls whether
bb_xx_msg will ever try to send output to syslog.
Add "select CONFIG_FEATURE_SYSLOG" to relevant applets.
This allows to omit syslog code if we do not have
any syslog-capable applets in the build.
2006-09-07 06:02:39 +00:00
Rob Landley
88621d7398 Svn 16007 broke the build under gcc 4.0.3. This fixes up some of the damage
(the e2fsprogs directory is too twisty and evil to easily fix, but I plan
to rewrite it anyway so I'll just bump that up in priority a bit).
2006-08-29 19:41:06 +00:00
Rob Landley
534374755d Cleaup read() and write() variants, plus a couple of new functions like
xlseek and fdlength() for the new mkswap.
2006-07-16 08:14:35 +00:00
Rob Landley
cba1b96735 Patch from Shaun Jackman to set environment variable RUNLEVEL equal to
init's argv[1], so if you append "single" to your kernel command line and
the kernel doesn't parse it, RUNLELEL=single.

Plus a few unrelated header cleanups while I was in the area...
2006-07-09 17:28:17 +00:00
"Robert P. J. Day"
edd9ca5743 More removal of "#if 0" content. 2006-07-01 14:52:12 +00:00
Bernhard Reutner-Fischer
e15d7573a1 - move #include busybox.h to the very top so we pull in the config
and eventual platform specific includes in early.
2006-06-02 20:56:16 +00:00
Bernhard Reutner-Fischer
cf1f2ace39 - fix CONFIG_DEBUG_INIT compile failure 2006-06-02 10:43:17 +00:00
Paul Fox
d112f8fa5e make halt and poweroff messages more accurate (i.e., claim "we're about to",
rather than "it's done", and combine with reboot handler to save space.
2006-06-01 13:17:49 +00:00
Bernhard Reutner-Fischer
9a5686b605 - fix IMA compile error i introduced when adding this untested snippet. 2006-05-31 18:57:56 +00:00
Bernhard Reutner-Fischer
7ae1553980 - consolidate "Sending SIG%s to all processes"; untested..
text    data     bss     dec     hex filename
   5379      32       8    5419    152b init/init.o.oorig
   5358      32       8    5398    1516 init/init.o
2006-05-30 18:17:21 +00:00
Bernhard Reutner-Fischer
c58dbf28e0 - remove useless variable "status" from init_main.
http://www.opengroup.org/onlinepubs/009695399/functions/waitpid.html suggests
that we need not specify a status if we don't want, and we don't.
"If wait() or waitpid() return because the status of a child process is available, these functions shall return a value equal to the process ID of the child process. In this case, if the value of the argument stat_loc is not a null pointer, information shall be stored in the location pointed to by stat_loc.  "
   text    data     bss     dec     hex filename
   5391      32       8    5431    1537 init/init.o.06
   5379      32       8    5419    152b init/init.o
2006-05-30 12:16:54 +00:00
Bernhard Reutner-Fischer
3ab3080bc2 - use config_buffer for message()
- add second argument to waitfor(*action,pid); if action==NULL then use pid tor
  wait for. If an action was given, we wait for the action to finish just as
  before. In run() remove second and third occurance of the same functionality
  the waitfor() call now provides.
  Adjust the former only caller of waitfor accordingly.

PS: Not using waitfor but creating a second function used a few bytes more than
simply extending and reusing waitfor.
   text    data     bss     dec     hex filename
   5426      32       8    5466    155a init/init.o.orig
   5391      32       8    5431    1537 init/init.o
2006-05-30 12:10:29 +00:00
Bernhard Reutner-Fischer
35e1a077d6 - DEBUG_INIT -> config CONFIG_DEBUG_INIT 2006-05-29 13:08:35 +00:00
Bernhard Reutner-Fischer
76bb97c995 - landley, remove this? 2006-05-29 13:01:37 +00:00
Bernhard Reutner-Fischer
49e60b9788 - set_term() doesn't need an argument. (Like r15220 this is just compile-tested)
text    data     bss     dec     hex filename
   5432      32       8    5472    1560 init/init.o.r15220
   5426      32       8    5466    155a init/init.o
2006-05-29 12:57:52 +00:00
Bernhard Reutner-Fischer
0da069d382 - move common code into new open_new_terminal() function;
text    data     bss     dec     hex filename
 864434   10244  645892 1520570  1733ba busybox_old
 864386   10244  645892 1520522  17338a busybox_unstripped

add/remove: 1/0 grow/shrink: 0/2 up/down: 92/-143 (-51)
function                                     old     new   delta
open_new_terminal                              -      92     +92
exec_signal                                  345     276     -69
run                                         1527    1453     -74
Again, 48 != 51 so let's trust the former..
2006-05-29 12:54:16 +00:00
Rob Landley
299a6b4d7b Consolidate #include <sys/time.h> so libbb.h does it. 2006-05-27 21:42:58 +00:00
Bernhard Reutner-Fischer
d765ee5d0f - provide fallback defines for non-linux 2006-05-26 20:34:02 +00:00
Bernhard Reutner-Fischer
b180e5a766 - use portability wrapper define bb_setpgrp. 2006-05-26 14:24:56 +00:00
Bernhard Reutner-Fischer
b1629b1b2a - remove emacs layout block as suggested by Robert P.J. Day
- use shorter boilerplate while at it
2006-05-19 19:29:19 +00:00
Mike Frysinger
39440e520c pull Rules.mak from top_srcdir as pointed out by Robert P. J. Day on the mailing list 2006-05-13 02:33:09 +00:00
Mike Frysinger
2f4d91da75 fix whitespace 2006-05-13 02:27:52 +00:00
Mike Frysinger
706f8f6de5 just include fcntl.h not sys/fcntl.h 2006-04-29 04:43:31 +00:00
Rob Landley
2ec922eed5 Patch from Robert P Day: let menuconfig indent stuff for us, we don't have
to do it in Config.in.
2006-04-13 23:22:16 +00:00
Mike Frysinger
6850017a2f remove some more config code rob missed in rev 13701 cleanup as reported by Robert P. J. Day 2006-03-28 06:11:51 +00:00
Rob Landley
b3ede5abe2 More from Jan Kiszka: this is a port of the latest sysv-init SELinux patch.
It makes busybox invoke the libselinux library function to load the binary
policy right at system start-up. It was successfully tested on a mini-SELinux
system.  Note: requires recent libselinux. I'm using 1.28.
2006-03-27 23:09:12 +00:00
Rob Landley
2dd4279959 Patch from Rogelio Serrano to defer checking whether the tty exists until
we actually need to spawn something on it.
2006-03-22 17:39:13 +00:00
Bernhard Reutner-Fischer
df10094870 - revert back to r14406 2006-03-13 19:04:00 +00:00
Rob Landley
bc68cd14cc Patch from Denis Vlasenko turning static const int (which gets emitted into
the busybox binary) into enums (which don't).
2006-03-10 19:22:06 +00:00
Bernhard Reutner-Fischer
07a79e75f5 - backout using features which are not available with the previous stable
version of make (3.71.1).
2006-03-09 09:03:37 +00:00
Rob Landley
dfba741457 Robert P. Day removed 8 gazillion occurrences of "extern" on function
definitions.  (That should only be on prototypes.)
2006-03-06 20:47:33 +00:00
Bernhard Reutner-Fischer
022eb311d5 - use absolute path for top_builddir and top_srcdir.
Fixes make trying to include the very same file in an endless loop.
2006-03-02 17:33:25 +00:00
Bernhard Reutner-Fischer
5d26126b9e - fixes parallel builds (make -j)
- use less resources for the buildsystem itself
2006-03-01 22:54:48 +00:00
Rob Landley
0a7c8ef6e2 Patch from Denis Vlasenko to constify things and fix a few typos. 2006-02-22 17:01:00 +00:00
Rob Landley
d6e14d8bee Don't build directory libraries unless we're building an applet that needs it.
Cherry-picked from Devin Bayer's big MacOS X patch.
2006-02-21 19:11:35 +00:00
Rob Landley
4926d643ea Missed this in svn 13701. 2006-02-10 21:38:20 +00:00
Mike Frysinger
b38673fb9f make the build system puuuuuuuuuuurty 2006-02-02 01:41:53 +00:00
"Vladimir N. Oleynik"
1f04c9d29c removed anoinig `unused' warnings 2006-02-01 14:47:52 +00:00
Rob Landley
646129163a Re-add initrd support, unify halt/reboot/poweroff, add -n and -f options. 2006-01-30 08:31:37 +00:00
Tim Riker
c1ef7bdd8d just whitespace 2006-01-25 00:08:53 +00:00
Rob Landley
2edf52643d The whole "init is sometimes pid 3" thing is silly. Init is pid 1, anything
else is a kernel bug.  Both 2.4 and 2.6 should get this right now.  This
should fix the bug IraquiGeek is seeing (although killall still needs to
be fixed.)
2006-01-22 02:41:51 +00:00
Bernhard Reutner-Fischer
7ca61b6f33 - shared libbusybox.
- IMA compilation option (aka IPO, IPA,..)
Please holler if i broke something..
2006-01-15 14:04:57 +00:00
"Vladimir N. Oleynik"
6c35c7c976 usage bb_dev_null 2005-10-12 15:34:25 +00:00
"Vladimir N. Oleynik"
ba248206fe change strange depend to libbb.h, but require busybox.h 2005-10-06 15:18:09 +00:00
"Vladimir N. Oleynik"
8e1bd4a05b don't out \r to syslog 2005-09-29 12:55:21 +00:00
Mike Frysinger
f51d2069ff re-order a little for alphabetical 2005-09-24 23:14:11 +00:00
Mike Frysinger
62f18e1f20 use the shorter license header 2005-09-24 07:16:29 +00:00
Mike Frysinger
0d4ee68be5 use brief license line 2005-09-24 06:01:57 +00:00
Rob Landley
c3386a4304 Why have a separate CONFIG_INIT_SWAPON when we already have CONFIG_SWAPONOFF? 2005-08-30 18:50:37 +00:00
Rob Landley
7a8f6792f3 Bug system entry #1 says that when busybox doesn't have swapoff,
init shouldn't call swapoff.
2005-08-30 18:17:05 +00:00
Paul Fox
41a72ecd19 applying patch from bug 24:
0000024 03-16-05 patch: allow init to set controlling tty
2005-08-01 16:43:13 +00:00
Mike Frysinger
4d00896d05 use toplevel ARFLAGS and update default ARFLAGS to be quiet 2005-07-27 01:09:24 +00:00
Mike Frysinger
10427ab528 move var decls around a little to help gcc make smaller code 2005-07-06 05:00:48 +00:00
Mike Frysinger
e548bdff96 2005-07-04 Shaun Jackman <sjackman@gmail.com>
* init/init.c: Do not include sys/mount.h.
        (message): Use O_NONBLOCK instead of O_NDELAY.
        (console_init): Ditto.
2005-07-06 04:46:14 +00:00
Mike Frysinger
95ef16528c 2005-07-05 Shaun Jackman <sjackman@gmail.com>
* init/Config.in (CONFIG_FEATURE_INIT_SWAPON): New option.
        * init/init.c (check_memory): Disable the swapon feature unless
        CONFIG_FEATURE_INIT_SWAPON is defined.
2005-07-06 04:39:08 +00:00
Mike Frysinger
72a4c33568 rename log var to log_console so we dont override internal gcc/glibc log func 2005-07-05 02:19:20 +00:00
Mike Frysinger
a77b4f3970 jfb2 writes in Bug 119:
The init applet will restart (re-exec) itsself when it
receives a SIGHUP. However, just before it enters its
main loop, it resets SIGHUP to either re-load the inittab
(or ignore it if no inittab is used). Thus preventing
the re-exec option from being triggerable.

This patch adds a signal handler for SIGQUIT for init that
always causes init to re-exec itsself (along with killing
anything else that might be still running).
2005-04-16 08:21:34 +00:00
Eric Andersen
82baf63de5 Hiroshi Ito writes:
Hello, all.

Busybox init does not handle removed inittab entry correctly.

# I'm sorry about my poor english, but you can find
# what I would like to say from patch, isn't it?

even if you apply this path,
when yoy try to change a command line option in inittab,
you have to do following steps.
1. remove old line from initrd
2. send HUP signal to init
3. kill old proces which is invoked from init.
4. append new line to inittab
5. send HUP signal to init, again

patch is against current CVS + last patch witch I send it last.
2004-10-08 08:21:54 +00:00
Eric Andersen
2271809d75 Hiroshi Ito writes:
"kill -HUP 1" reloads inittab, and when I append one line to inittab
and send HUP signal two times, It will starts 2 process.

patch against current CVS is attached.
2004-10-08 08:17:39 +00:00
Eric Andersen
7daa076d3e egor duda writes:
Hi!

I've created a patch to busybox' build system to allow building it in
separate tree in a manner similar to kbuild from kernel version 2.6.

That is, one runs command like
'make O=/build/some/where/for/specific/target/and/options'
and everything is built in this exact directory, provided that it exists.

I understand that applyingc such invasive changes during 'release
candidates' stage of development is at best unwise. So, i'm currently
asking for comments about this patch, starting from whether such thing
is needed at all to whether it coded properly.

'make check' should work now, and one make creates Makefile in build
directory, so one can run 'make' in build directory after that.

One possible caveat is that if we build in some directory other than
source one, the source directory should be 'distclean'ed first.

egor
2004-10-08 07:46:08 +00:00
Eric Andersen
785001468d Quiet a few warnings 2004-08-27 19:55:28 +00:00
Eric Andersen
1f50e84283 Do not use vfork, as init is not vfork safe. Do not allow
askfirst when mmuless.
2004-08-16 09:29:42 +00:00
Eric Andersen
36adca81f5 Patch from Bastian Blank:
On Sat, Jun 19, 2004 at 10:57:37PM +0200, Bastian Blank wrote:
> The following patch changes klogd to use openlog/syslog themself
> instead of calling syslog_msg which always calls the triple
> openlog/syslog/closelog.

Updated patch: get rid of syslog_msg entirely. Request from Erik Andersen.

Bastian
2004-06-22 10:07:17 +00:00
Eric Andersen
0dfe4e9956 As discussed, drop minit, which was not being supported in busybox.
People wishing to use minit can obtain it and obtain support from
http://www.fefe.de/minit/
2004-05-26 10:28:32 +00:00
Glenn L McGrath
c6992feee3 Update my email address, document some of my tasks in the AUTHORS file 2004-04-25 05:11:19 +00:00
Eric Andersen
87812dc3b0 Silly me 2004-04-12 19:21:54 +00:00
Eric Andersen
4e19fa9b64 As reported by Quy Tonthat, init has problems with inittab's that
contain only actions sysinit/wait/once. It does not clean up zombies
in that case.
2004-04-12 19:17:13 +00:00
Eric Andersen
e3efc9230c Jamie Guinan writes:
It looks like latest uClibc defines ARCH_HAS_MMU, but a few busybox files
test UCLIBC_HAS_MMU, resulting in vfork() getting called instead of
fork(), etc.

Patch below.   Only tested for lash.

Cheers,
-Jamie
2004-04-12 17:59:24 +00:00
Eric Andersen
c7bda1ce65 Remove trailing whitespace. Update copyright to include 2004. 2004-03-15 08:29:22 +00:00
Glenn L McGrath
e7f2b2bf31 Thomas Geulig, remove duplicate header 2004-02-22 04:17:26 +00:00
Eric Andersen
88c916bdec Andreas Mohr writes:
the busybox menuconfig triggered my "inacceptable number of spelling mistakes"
upper level, so I decided to make a patch ;-)

I also improved some wording to describe some things in a better way.

Many thanks for an incredible piece of software!

Andreas Mohr, random OSS developer
2003-10-22 09:58:56 +00:00
Glenn L McGrath
e6ba16f830 Patch by Guillaume Morin
Fix two race conditions, as described at.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=212764
2003-09-26 10:45:55 +00:00
Eric Andersen
2205c84de4 comparison was always false due to limited range of data types.
Carefully cast to unsigned long long prior to multiply to get
the expected result.
2003-09-15 08:11:29 +00:00
Eric Andersen
81155f8fa8 Update definition of struct serial_struct, per linux-2.6.0-test5,
to avoid stack corruption problems on some 64bit architectures
when sizeof(void*) != sizeof(int).  Thanks to Atsushi Nemoto
for finding this problem.
2003-09-11 08:52:22 +00:00
Glenn L McGrath
99bd5adf99 more crond+crontab integrating with loginutil libbb functions and deleted
patch from Thomas Gleixner to init.
Viodz last_patch_108
2003-09-03 12:18:42 +00:00
Glenn L McGrath
dc4e75ef7c move all "-/bin/sh" "/bin/sh" and "sh" to libbb/messages.c file as one
constant.
Vodz last_patch_107
2003-09-02 02:36:18 +00:00
Glenn L McGrath
ce6482eace Fix overflow for machines greater than 4GB, return unsigned int to avoid
a cast and for greater accuracy.
2003-08-26 02:14:58 +00:00
Eric Andersen
9cdef5d928 Yang Xiaopeng writes:
>I'm sure that no user process use old root now,  but when run "umount
>/old_root", it says:
>   umount: /old_root: Device or resource busy
>
>I have tried to remount /proc within the new root *after* chroot, but
>get the same result.
>
>
I found the problem, I said that no user process use old root when run
my scripts, but
I'm wrong, actually there is a '3' fd open the file
"/old_root/dev/console". By adding
debug message in init/init.c, I found the problem: when init restart(in
exec_signal()),
before open the new terminal device, there is still a file opened(I
don't know which file it is), so the
terminal device(stdin) get fd '1', and the first dup(0)(stdout) return
'2', the second(stderr) return '3'.

I attach a simple patch to solve this problem.
2003-07-29 06:33:12 +00:00
Eric Andersen
a1ed06b047 Move start_stop_daemon to debianutils.
Cleanup run_parts a bit and add long opts
2003-07-26 09:16:00 +00:00
Eric Andersen
aa820dbc00 cleanup and add long options 2003-07-26 09:10:35 +00:00
Eric Andersen
d5868c1692 Patch from Thomas Gleixner to reap any zombie processes that are
reparented to init...
2003-07-26 06:25:12 +00:00
Eric Andersen
20c9f1e5e7 Several simplifications and indenting changes, per
last_patch97 from vodz
2003-07-22 17:14:10 +00:00
Eric Andersen
4c6c236781 As vodz noticed, I screwed up reboot 2003-07-22 17:04:54 +00:00
Eric Andersen
6fd0e31e87 Patch from Andrew Flegg:
Here's a pretty crude patch to reload /etc/inittab when init receives a
    SIGHUP. The mailing list archives weren't entirely clear on whether or
    not it should already happen, but didn't appear to be.

    The patch:
       * Adds a new function, reload_signal() which just calls
	 parse_inittab() and run_actions(RESPAWN)

       * Before entering the while (1) loop set up SIGHUP to call
	 reload_signal()

       * Modify new_init_action to skip the action if the same command
	 already exists on the same terminal

    This last bit means that changing already running entries is a bit
    hairy as you can end up with, for example, two shells running on the
    same virtual console. However, for solely adding/removing entries this patch
    seems to work quite well.
2003-07-22 09:48:56 +00:00
Eric Andersen
0246222351 Support reboot, halt, and poweroff independent of busybox init.
Simplify and fixup some logic.
 -Erik
2003-07-22 09:41:39 +00:00
Eric Andersen
85e5e72bc1 Remove remaining libc5 support code 2003-07-22 08:56:55 +00:00
Eric Andersen
cb81e6484d Update a bunch of docs. Run a script to update my email addr. 2003-07-14 21:21:08 +00:00
Eric Andersen
e5642119ee Patch from Thomas Cameron:
Hello all,
	    This patch adds more "Help" text to the config system.  Almost
    all applets now have a help entry.  Also, I cleaned up the spacing of
    the existing text so that things are consistent.  This patch is against
    this morning's CVS.

    Thomas Cameron
    CEI Systems, Inc.
2003-07-14 19:37:08 +00:00
Eric Andersen
fb0c6af286 Patch from Lars Kellogg-Stedman:
The attached two patches add config documentation to init/Config.in and
    fileutils/Config.in.
2003-07-14 19:18:43 +00:00
Eric Andersen
d5a2780aa2 oops 2003-07-05 08:39:47 +00:00
Eric Andersen
3c8064ff69 Daniel writes:
I've found a problem with job control when the init process is restarted.

If the system boots for the first time, I get job control on a serial terminal -
no problems. However, when I restart init by issuing "init -q", then the shell
no longer has job control.

I traced this a problem in console_init in the file init.c. What was happening
after the restart is that the first compare

    if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
	...
    } else if (ioctl(0, VT_GETSTATE, &vt) == 0) {
	...
    } else {
	... // assume /dev/console
    }

returned error and subsequently the code assumes /dev/console as the console,
which does not support job control.

Checking the errno after the first call showed that the system was complaining
about the file descriptor. This is probably because the previous init process
had closed all its file descriptors which the new init process had inherited.
2003-07-05 08:29:01 +00:00
Eric Andersen
65e20a33c2 Patch from Kent Robotti adding a bunch of needed docs!
-Erik
2003-07-05 07:52:35 +00:00
Eric Andersen
b01ed65ad2 Apply last_patch93 from vodz:
andersen@busybox.net wrote:
    >Message: 4
    >Modified Files:
    >       init.c
    >Log Message:
    >Remove code for unsupported kernel versions

    Hmm. Current init.c have check >= 2.2.0 kernel one time too.
    Ok. Last patch removed this point and move common init code to new file for
    /init dir
2003-06-27 17:08:15 +00:00
Eric Andersen
0b0d393347 Remove bdflush garbage, which is only relevant to unsupported
kernel versions
2003-06-27 05:46:29 +00:00
Glenn L McGrath
1e11c34be4 minit, a Minimal init system. 2003-05-11 14:52:39 +00:00
Eric Andersen
2c1de61023 There have been many reports of init failing to reboot and/or failing to halt
over the years.  Well I finally took the time to track this down.  It turns out
that inside linux/kernel/sys.c the kernel will call
    machine_halt();
    do_exit(0);
when halting, or will call
    machine_power_off();
    do_exit(0);

during a reboot.  Unlike sysv init, we call reboot from within the init
process, so if the call to machine_halt() or machine_power_off() returns,                                       the call to do_exit(0) will cause the kernel to panic.  Which is a very
bad thing to happen.

So I just added this little patch to fork and call the reboot
syscall from within the forked child process, thereby neatly
avoiding the problem.

But IMHO, both calls to do_exit(0) within linux/kernel/sys.c
are bugs and should be fixed.

 -Erik
2003-04-24 11:41:28 +00:00
Manuel Novoa III
cad5364599 Major coreutils update. 2003-03-19 09:13:01 +00:00
Eric Andersen
22237017a7 Fix a silly compile error, thanks to a patch from Wen-chien Jesse Sung 2003-01-23 07:08:26 +00:00
Glenn L McGrath
b4a1baa312 Correct some init issues, update email address, last_patch78 by Vladimir
N. Oleynik
2003-01-13 22:09:50 +00:00
Eric Andersen
cf1fee06a5 Odd. I never brought this forward from bb.stable. Should handle
reaping child processes better.
 -Erik
2002-12-17 09:48:16 +00:00
Glenn L McGrath
4e05b9b043 include "busybox" after the libc includes tofix compile errors 2002-12-07 23:14:40 +00:00
Eric Andersen
c9f20d9fb9 Yet another major rework of the BusyBox config system, using the considerably
modified Kbuild system I put into uClibc.  With this, there should be no more
need to modify Rules.mak since I've moved all the interesting options into the
config system.  I think I've got everything updated, but you never know, I may
have made some mistakes, so watch closely.
 -Erik
2002-12-05 08:41:41 +00:00
Glenn L McGrath
efdd0aed23 Use error_msg instead of fprintf(stderr 2002-11-28 09:40:36 +00:00
Glenn L McGrath
8f0722a53b Move readlink, mktemp, run-parts and which to a new debianutils dir. 2002-11-11 03:00:12 +00:00
Eric Andersen
f02c26f1ef I committed the fflush in the wrong spot. I should go to bed
earlier so I don't screw up such easy stuff.
 -Erik
2002-10-22 19:15:43 +00:00
Eric Andersen
5956028f6f Be absurdly careful about flushing stdout. 2002-10-22 11:45:20 +00:00
Eric Andersen
e8a90fb2bc After thinking about it, I think this patch from Matt Kraai is probably the
best way to go.  Sysvinit does not provide a controlling tty since it doesn't
even try to open ttys for apps.  We do.  So we should _try_ to provide a
controlling tty if possible, but we needn't freak out if it doesn't work.  This
way we won't need to use openvt or similar, we'll just have init do the Right
Thing(tm).
2002-10-12 04:05:48 +00:00
Eric Andersen
71ae64bdc6 last_patch61 from vodz:
New complex patch for decrease size devel version. Requires previous patch.
    Also removed small problems from dutmp and tar applets.
Also includes vodz' last_patch61_2:
    Last patch correcting comment for #endif and more integrated
    with libbb (very reduce size if used "cat" applet also).
    Requires last_patch61 for modutils/config.in.
2002-10-10 04:20:21 +00:00
Eric Andersen
6a9799020b Set the close-on-exec flag, just to be saf 2002-09-30 20:08:53 +00:00
Eric Andersen
a920871c3a Ignoring SIGCHLD causes a race leading to the occasional hang of init
when init will wait() on itself in waitfor() when the child exits before
init is scheduled to run.  Letting init hang is very seriously bad.
 -Erik
2002-09-25 15:08:40 +00:00
Eric Andersen
34fd00af5f Patch from David McCullough <davidm@snapgear.com> 2002-09-17 08:40:12 +00:00
Eric Andersen
a9cc8961ed Let people run SHUTDOWN actions prior to killing everything
-Erik
2002-09-16 06:49:06 +00:00
Glenn L McGrath
061c900176 mesg applet by Manuel Novoa III 2002-09-16 04:21:46 +00:00
Eric Andersen
186685d46f Patch from Thomas Gleixner <tglx@linutronix.de> to do
automatic child reaping to avoid zombies
2002-09-12 15:44:53 +00:00
Eric Andersen
1130976f8e Eliminate use of obsolete sys_errlist[]
-Erik
2002-08-26 21:36:32 +00:00
Glenn L McGrath
baf55a85fc Run through indent, fix comments 2002-08-22 18:22:10 +00:00
Eric Andersen
e707806894 Kill a silly warning 2002-07-29 08:00:16 +00:00
Eric Andersen
3bc2b206b0 Patch from Tim Riker to allow tty* in inittab if the tty
actually exists -- serial console is not the issue...
2002-07-29 06:39:58 +00:00
Eric Andersen
0826b6b0b3 This is last_patch48 from vodz. More cleanups, kills a bit
of dead code, fixes one blatent bug.
2002-07-03 23:50:16 +00:00
Eric Andersen
887ca79f04 Scrub pwd.h and grp.h handling so we don't have to play any
silly games.
 -Erik
2002-07-03 23:19:26 +00:00
Eric Andersen
599e3ce163 Apply last_patch47 from vodz to fix several problems, such as the ash "job
control turned off" bug, console_setup() was called with a closed file
descriptor, setsid() inconsistancy, and silly string handling bugs.   I have
modified his patch to allow the askfirst init actions to have a controlling
terminal.
2002-07-03 11:08:10 +00:00
Eric Andersen
796446718d Fix from vodz so that complex init commands actually work 2002-07-03 05:44:18 +00:00
Eric Andersen
5222d31a15 Patch from till busch <buti@gmx.at> -- unblock all signals
in exec_signal() before calling exec()
2002-07-03 05:15:23 +00:00
Eric Andersen
ff7661d9de plug fd leak noticed by Russ Dill
-Erik
2002-06-05 07:11:32 +00:00
Robert Griebl
ea1a63a201 Fix for broken handling off BusyBox's own pwd/grp implementations
[Parts of this patch may overlap with my other two patches]
2002-06-04 20:10:23 +00:00
Eric Andersen
d8636cad4d Doh! Remember to close /etc/inittab 2002-05-15 22:19:09 +00:00
Eric Andersen
1d1d2f9b18 Update some missing copyright notices 2002-04-13 08:31:59 +00:00
Eric Andersen
85208e2ab9 Completely rework the config system so that it no longer annoys me to work on
the busybox development tree.  This eliminates the use of recursive make, and
once again allows us to run 'make' in a subdirectory with the expected result.
And things are now much faster too.  Greatly improved IMHO...
 -Erik
2002-04-12 12:05:57 +00:00
Eric Andersen
c57e42b8f0 Provide a controlling tty to askfirst processes as well
-Erik
2002-03-29 00:59:44 +00:00
Eric Andersen
b0cc0a6ca8 Rewind messages to avoid weird formatting, and fix a bug with
CONFIG_FEATURE_EXTRA_QUIET, which was broken
2002-03-20 14:57:50 +00:00
Eric Andersen
0298be88ae Update init.c per my changes in the stable branch
-Erik
2002-03-05 15:12:19 +00:00
Eric Andersen
53a2299230 Patch from Russ Dill <Russ.Dill@asu.edu>. From the
start-stop-daemon man page:

-b|--background
        Typically used with programs that don't detach on their own.
        This option will force start-stop-daemon to fork before starting
        the process, and force it into the background. WARNING:
        start-stop-daemon cannot check the exit status if the process
        fails to execute for any reason. This is a last resort, and is
        only meant for programs that either make no sense forking on
        their own, or where it's not feasible to add the code for it to
        do this itself.

This is usefull for applets like watchdog
2002-01-26 09:04:45 +00:00
Eric Andersen
467a18b1d9 Teach 'init -q' that init's pid may not equal 1 2002-01-25 23:13:06 +00:00
Eric Andersen
038cbc7442 Oops. 2002-01-06 01:10:25 +00:00
Eric Andersen
c94e89d81f Do not depend on PATH or getopt arg reordering 2002-01-06 01:08:28 +00:00
Matt Kraai
1f0c43668a Remove == TRUE' tests and convert != TRUE' and `== FALSE' tests to use !. 2001-12-20 23:13:26 +00:00
Eric Andersen
fb74a45088 Vodz' last_patch31
Very minimal last corrections:

    1) busybox.c: fix warining
    2) docs/: add applets for list from pwd_grp
    3) usage.h: add -n option for route
    4) run_parts.c: many todo fix for busybox style
    5) addgroup.c: add #ifdef CONFIG_FEATURE_SHADOWPASSWDS, reduce one
    perror_msg
    6) adduser.c: fix bug "variable i not initialize" and
       add #ifdef CONFIG_FEATURE_SHADOWPASSWDS
2001-12-18 14:06:03 +00:00
Eric Andersen
730f826f25 Add in a new restart init target, triggered by SIGHUP. Patch from
Russ Dill, with adjustments by me.
 -Erik
2001-12-17 23:13:08 +00:00
Eric Andersen
b24d65659f If find_pid_by_name() had an error, it was returning -1, but storing
that into a pid_t, which is unsigned on a number archs.  Furthermore,
find_pid_by_name() would _never_ return an error if the intended proces
was "init", but instead would return 1, meaning we would fail to work
on 2.4.x kernels running an initrd...
 -Erik
2001-12-06 14:52:32 +00:00