Commit Graph

76 Commits

Author SHA1 Message Date
Ron Yorston
5c69ad0ecd build system: drop PLATFORM_LINUX
PLATFORM_LINUX is a hidden configuration option which is disabled by
default and enabled at over a hundred locations for features that are
deemed to be Linux specific.

The only effect of PLATFORM_LINUX is to control compilation of
libbb/match_fstype.c.  This file is only needed by mount and umount.

Remove all references to PLATFORM_LINUX and compile match_fstype.c
if mount or umount is enabled.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-13 17:12:56 +02:00
James Byrne
6937487be7 libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d437 ("'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>
2019-07-02 11:35:03 +02:00
Denys Vlasenko
5059653882 do not duplicate CONFIG_PID_FILE_PATH and ".pid" strings
text	   data	    bss	    dec	    hex	filename
 981737	    485	   7296	 989518	  f194e	busybox_old
 981704	    485	   7296	 989485	  f192d	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-03-17 19:48:39 +01:00
Denys Vlasenko
b097a84d62 config: update size information
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-28 03:20:17 +01:00
Denys Vlasenko
c16ae469ef klogd: code shrink
function                                             old     new   delta
klogd_main                                           511     486     -25

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-31 16:50:26 +02:00
Denys Vlasenko
e8073519d8 klogd: better help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-31 15:25:00 +02:00
Denys Vlasenko
72089cf6b4 config: deindent all help texts
Those two spaces after tab have no effect, and always a nuisance when editing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-21 09:50:55 +02:00
Denys Vlasenko
4eed2c6c50 Update menuconfig items with approximate applet sizes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18 22:01:24 +02:00
Denys Vlasenko
9de2e5a222 *: hopefully all setup_common_bufsiz() are in place
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 18:38:51 +02:00
Denys Vlasenko
e6a2f4cc5a libbb: make bb_common_bufsiz1 1 kbyte, add capability to use bss tail for it
The config item is FEATURE_USE_BSS_TAIL. When it is off (default):

function                                             old     new   delta
read_config                                          210     228     +18
doCommands                                          2279    2294     +15
ipneigh_list_or_flush                                763     772      +9
ipaddr_list_or_flush                                1256    1261      +5
display_process_list                                1301    1306      +5
conspy_main                                         1378    1383      +5
do_lzo_compress                                      352     355      +3
do_lzo_decompress                                    565     567      +2
push                                                  46      44      -2
inetd_main                                          2136    2134      -2
uevent_main                                          421     418      -3
addLines                                              97      92      -5
bb_common_bufsiz1                                   8193    1024   -7169
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/5 up/down: 62/-7181)        Total: -7119 bytes
   text	   data	    bss	    dec	    hex	filename
 829850	   4086	   9080	 843016	  cdd08	busybox_old
 829901	   4086	   1904	 835891	  cc133	busybox_unstripped

FEATURE_USE_BSS_TAIL=y:

read_config                                          210     228     +18
doCommands                                          2279    2294     +15
ipneigh_list_or_flush                                763     772      +9
ipaddr_list_or_flush                                1256    1261      +5
display_process_list                                1301    1306      +5
conspy_main                                         1378    1383      +5
do_lzo_compress                                      352     355      +3
do_lzo_decompress                                    565     567      +2
inetd_main                                          2136    2134      -2
bb_common_bufsiz1                                   8193       -   -8193
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 8/1 up/down: 62/-8195)        Total: -8133 bytes
   text	   data	    bss	    dec	    hex	filename
 829850	   4086	   9080	 843016	  cdd08	busybox_old
 829911	   4086	    880	 834877	  cbd3d	busybox_unstripped

FIXME: setup_common_bufsiz() calls are missing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 17:39:11 +02:00
Kylie McClain
40eea690c7 Fix compiling with musl's utmp stubs
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>
2016-02-01 01:36:05 +01:00
Denys Vlasenko
d34f300db6 sysklogd/*: convert to new-style "one file" applets
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-18 22:40:09 +02:00
Peter Korsgaard
d189b598b4 klogd: handle multi-char log levels
Since Linux 3.5 (7ff9554bb5: printk: convert byte-buffer to variable-length
record buffer), klog buffer can now contain log lines with multi-char
loglevel indicators (<[0-9]+>) - So use strtoul to parse it.

function                                             old     new   delta
klogd_main                                           490     525     +35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 35/0)               Total: 35 bytes

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-01-05 21:03:19 -05:00
Anthony G. Basile
12677acf0a CONFIG_PID_FILE_PATH: new configuration option for pidfile paths
We set a default path for the directory where pidfiles are create
when FEATURE_PIDFILE is selected.  The default has no effect on
applets which must specify a pidfile path on the command line to
run, and it can be overridden by applets which optionally allow
the user to specify the pidfile path.

We also add pidfile write/remove support for klogd, ntpd and watchdog.
For syslogd, we add a missing remove_pidfile() for better cleanup
on daemon exit.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-12-19 15:53:33 -05:00
Denys Vlasenko
66426760be *: remove "Options:" string from help texts
function                                             old     new   delta
packed_usage                                       28706   28623     -83

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-05 03:58:28 +02:00
Denys Vlasenko
aeab42e3f4 syslogd,klogd: better help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-25 11:58:56 +02:00
Pere Orga
5bc8c005a8 move remaining help text from include/usage.src.h
Signed-off-by: Pere Orga <gotrunks@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-11 03:29:49 +02:00
Denys Vlasenko
8b6b472f4e klogd: fix the problem of delayed handling of ^C and SIGTERM
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-07 10:57:26 +01:00
Denys Vlasenko
0016bcee37 klogd: do not log partial lines
function                                             old     new   delta
overlapping_strcpy                                    15      18      +3
klogd_main                                           438     436      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-19 23:07:49 +02:00
Denys Vlasenko
0ef64bdb40 *: make GNU licensing statement forms more regular
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>
2010-08-16 20:14:46 +02:00
Jeremie Koenig
63c2e7ecc0 klogd: make it work on non-linux systems
The klogctl() interface allows changing the console loglevel, but is
Linux-specific. The more portable method of reading from _PATH_KLOG is
added as an alternative.

Adapted from the Debian kFreeBSD patch at:
http://svn.debian.org/viewsvn/d-i/people/slackydeb/kfreebsd/busybox/1.14/debian/klogd.diff

Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-01 03:01:44 +02:00
Denis Vlasenko
58a88916b9 klogd: fix small buglet in previous commit 2008-11-19 09:35:00 +00:00
Denis Vlasenko
2e7dc5d37b klogctl: fix a problem where we don't terminate read data with '\0'
and then misinterpret it. Code shrink while at it.

function                                             old     new   delta
klogd_main                                           404     362     -42
2008-11-19 07:59:49 +00:00
Denis Vlasenko
93d0776a96 watchdog: WDIOC_SETTIMEOUT accepts seconds, not milliseconds
klogd: handle many lines at once, by Steve Bennett (steveb AT workware.net.au)
2008-10-04 16:40:17 +00:00
Denis Vlasenko
a60f84ebf0 *: rename ATTRIBUTE_XXX to just XXX. 2008-07-05 09:18:54 +00:00
Denis Vlasenko
7bdf0c82da klogd: make help text more understandable
klogd: by using a register instead of global variable, shrink code a bit

function                                             old     new   delta
klogd_main                                           372     362     -10
packed_usage                                       24504   24486     -18
   text    data     bss     dec     hex filename
 808464     642    7180  816286   c749e busybox_old
 808422     642    7180  816244   c7474 busybox_unstripped
2008-06-06 16:08:04 +00:00
Denis Vlasenko
68404f13d4 *: add -Wunused-parameter; fix resulting breakage
function                                             old     new   delta
procps_scan                                         1265    1298     +33
aliascmd                                             278     283      +5
parse_file_cmd                                       116     120      +4
dname_enc                                            373     377      +4
setcmd                                                90      93      +3
execcmd                                               57      60      +3
count_lines                                           72      74      +2
process_command_subs                                 340     339      -1
test_main                                            409     407      -2
mknod_main                                           179     177      -2
handle_incoming_and_exit                            2653    2651      -2
argstr                                              1312    1310      -2
shiftcmd                                             131     128      -3
exitcmd                                               46      43      -3
dotcmd                                               297     294      -3
breakcmd                                              86      83      -3
evalpipe                                             353     349      -4
evalcommand                                         1180    1176      -4
evalcmd                                              109     105      -4
send_tree                                            374     369      -5
mkfifo_main                                           82      77      -5
evalsubshell                                         152     147      -5
typecmd                                               75      69      -6
letcmd                                                61      55      -6
add_cmd                                             1190    1183      -7
main                                                 891     883      -8
ash_main                                            1415    1407      -8
parse_stream                                        1377    1367     -10
alloc_procps_scan                                     55       -     -55
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 7/21 up/down: 54/-148)          Total: -94 bytes
   text    data     bss     dec     hex filename
 797195     658    7428  805281   c49a1 busybox_old
 797101     658    7428  805187   c4943 busybox_unstripped
2008-03-17 09:00:54 +00:00
Denis Vlasenko
400d8bb45e less,klogd,syslogd,nc,tcpudp: exit on signal by killing itself, not exit(1)
*: minor shrink
2008-02-24 13:36:01 +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
Bernhard Reutner-Fischer
f470196a41 - fix conflicting decls of syslog related facilitynames and prioritynames tables 2008-01-27 12:50:12 +00:00
Denis Vlasenko
7e3a5f58bc dmesg,klogd: make code more readable
libbb: explain why we declare klogctl
libbb: move defs around so that order makes more sense
2007-11-16 20:18: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
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
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
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
5a142025d3 move everything to new NOMMU helpers, except udhcp 2007-03-26 13:20:54 +00:00
Denis Vlasenko
9067f13be0 NOMMU re-exec trick shuld not depend on existence of "don't daemonize"
option for every affected applet (and dnsd, for example, don't have one).
Thus rework re-exec support to not require it. Code got smaller too.
2007-03-24 12:11:17 +00:00
Denis Vlasenko
c84520d73d klogd: code de-obfuscation with small code size reduction 2007-02-17 14:12:10 +00:00
Denis Vlasenko
06af216528 suppress warnings about easch <applet>_main() having
no preceding prototype
2007-02-03 17:28:39 +00:00
Bernhard Reutner-Fischer
8fc4011992 - shrink klogd a tiny bit.
Compile tested only, would have sent it to the list for review but they don't show up in the ML archives :-/
   text    data     bss     dec     hex filename
    533       0       0     533     215 sysklogd/klogd.o.orig
    530       0       0     530     212 sysklogd/klogd.o
2007-01-09 15:46:36 +00:00
Denis Vlasenko
e428e9d43b klogd: small optimizations
(btw, I looked into syslogd... that's frightening!)
2007-01-04 03:07:57 +00:00
Denis Vlasenko
1385899416 attempt to regularize atoi mess. 2006-10-08 12:49:22 +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
Rob Landley
d921b2ecc0 Remove bb_ prefixes from xfuncs.c (and a few other places), consolidate
things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only
had one user), clean up lots of #includes...  General cleanup pass.  What I've
been doing for the last couple days.

And it conflicts!  I've removed httpd.c from this checkin due to somebody else
touching that file.  It builds for me.  I have to catch a bus.  (Now you know
why I'm looking forward to Mercurial.)
2006-08-03 15:41: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
595159f38c - shrink klogd a bit
text    data     bss     dec     hex filename
    569       0       0     569     239 sysklogd/klogd.o.orig
    537       0       0     537     219 sysklogd/klogd.o
2006-05-31 12:22:13 +00:00
Bernhard Reutner-Fischer
c418d482ba - s/defined(__uClinux__)/BB_NOMMU/
This needs a second pass to:
+ add bb_daemon(unsigned char no_chdir, unsigned char no_close, const char*flag)
+ eventually globally export argc and argv, so we don't need to pass it to
  bb_daemon().
2006-05-31 10:19:51 +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
Bernhard Reutner-Fischer
2c99851181 - patch from Denis Vlasenko to add and use bb_xdaemon() 2006-04-12 18:09:26 +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