oweals/busybox.git
5 years agoexamples/udhcp/simple.script: print the filename actually changed
Rolf Eike Beer [Tue, 13 Aug 2019 15:41:56 +0000 (17:41 +0200)]
examples/udhcp/simple.script: print the filename actually changed

Signed-off-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agofind: implement -empty
Aaro Koskinen [Thu, 12 Sep 2019 10:04:13 +0000 (12:04 +0200)]
find: implement -empty

function                                             old     new   delta
func_empty                                             -     121    +121
packed_usage                                       33154   33167     +13
parse_params                                        1490    1500     +10
static.params                                        228     235      +7
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 151/0)             Total: 151 bytes

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogzip: code shrink
Denys Vlasenko [Fri, 6 Sep 2019 15:56:57 +0000 (17:56 +0200)]
gzip: code shrink

Converted a few 16-bit variables and small arrays to 32-bit.

Stopped pulling desc->FOO members into temporary local variables
in gen_bitlen(): on register-starved arches, this is a loss,
temporaries go into stack slots.

Sprinkled a few "const" on pointer arguments.

function                                             old     new   delta
pack_gzip                                            742     745      +3
gen_codes                                            101      97      -4
build_tree                                           886     833     -53
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 3/-57)             Total: -54 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoexamples/udhcp/simple.script: up interface on deconfig event
Denys Vlasenko [Thu, 5 Sep 2019 12:58:08 +0000 (14:58 +0200)]
examples/udhcp/simple.script: up interface on deconfig event

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: add a FIXME comment
Denys Vlasenko [Thu, 5 Sep 2019 12:31:49 +0000 (14:31 +0200)]
ash: add a FIXME comment

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohush: fix "set -o INVALID" affecting -e flag state
Denys Vlasenko [Thu, 5 Sep 2019 12:07:14 +0000 (14:07 +0200)]
hush: fix "set -o INVALID" affecting -e flag state

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogzip: code shrink
Denys Vlasenko [Thu, 5 Sep 2019 11:22:24 +0000 (13:22 +0200)]
gzip: code shrink

function                                             old     new   delta
gzip_main                                            267     264      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogzip: set default compression level to 6 when CONFIG_FEATURE_GZIP_LEVELS=n
Daniel Edgecumbe [Mon, 2 Sep 2019 21:09:15 +0000 (22:09 +0100)]
gzip: set default compression level to 6 when CONFIG_FEATURE_GZIP_LEVELS=n

With this change, GNU gzip -n and BusyBox gzip now produce identical output
assuming that CONFIG_GZIP_FAST=2.

>> Excuse me, but I wonder one thing: Why should we follow
>> strictly with gzip on the no-options default behavior?

> First, the default 6 compression level is a de-facto standard. BSD gzip
> and Apple gzip (on macOS) use this default as well. So there is a
> reasonable expectation that different gzip implementations act the same.
> For instance, if the default for busybox gzip becomes 9, then someone
> writing a script using busybox gzip could reasonably expect that the
> compression level will still be 9 when the same script is run on another
> system. That would be wrong. Implementations should not deviate from
> de-facto standards without a strong reason.
>
> Second, the inherent reason for this default has not gone away. While
> processor speeds have exploded since the default was set, so has the
> typical size of compressed files. Multiple gigabytes are nothing unusual
> these days. And gzip is often used for compression on the fly, precisely
> because it offers a good compromise between speed and compression ratio.
> So I believe 6 continues to be a reasonable default.

function                                             old     new   delta
deflate                                              939     927     -12

Signed-off-by: Daniel Edgecumbe <git@esotericnonsense.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogzip: set compression flags correctly as per standard
Daniel Edgecumbe [Mon, 2 Sep 2019 21:05:26 +0000 (22:05 +0100)]
gzip: set compression flags correctly as per standard

With this change and CONFIG_GZIP_FAST=2, CONFIG_FEATURE_GZIP_LEVELS=y,

GNU gzip and BusyBox gzip now produce identical output at each compression
level (excluding 1..3, as BusyBox does not implement these levels).

Signed-off-by: Daniel Edgecumbe <git@esotericnonsense.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agogzip: default level with ENABLE_FEATURE_GZIP_LEVELS should be 6
Daniel Edgecumbe [Mon, 2 Sep 2019 21:03:14 +0000 (22:03 +0100)]
gzip: default level with ENABLE_FEATURE_GZIP_LEVELS should be 6

Fixes an off-by-one that actually resulted in level 7 being used

Signed-off-by: Daniel Edgecumbe <git@esotericnonsense.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodc: Parse error & fix out of bounds read in xc_program_printString
Brian Foley [Thu, 5 Sep 2019 08:53:21 +0000 (10:53 +0200)]
dc: Parse error & fix out of bounds read in xc_program_printString

function                                             old     new   delta
xc_program_print                                     712     735     +23

Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodc: Fix segfault when executing strings generated using asciify
Brian Foley [Thu, 5 Sep 2019 08:50:13 +0000 (10:50 +0200)]
dc: Fix segfault when executing strings generated using asciify

function                                             old     new   delta
zxc_vm_process                                      6884    6891      +7

Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodc: execute shouldn't pop if stack head is not a string
Brian Foley [Thu, 5 Sep 2019 08:46:22 +0000 (10:46 +0200)]
dc: execute shouldn't pop if stack head is not a string

This matches the behaviour of both GNU dc (as specified in
its man page), and BSD dc (where stack_popstring() pops
only if the head is a string.)

Add a couple of tests to verify this behavior.

function                                             old     new   delta
zxc_vm_process                                      6882    6884      +2

Signed-off-by: Brian Foley <bpfoley@google.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc6: support stateless DHCPv6
Eivind Versvik [Sat, 24 Aug 2019 15:23:48 +0000 (17:23 +0200)]
udhcpc6: support stateless DHCPv6

-l will send Information-Request to request configuration parameters

function                                             old     new   delta
packed_usage                                       33114   33180     +66
send_d6_info_request                                   -      62     +62
udhcpc6_main                                        2534    2593     +59
udhcpc6_longopts                                     199     211     +12
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 199/0)             Total: 199 bytes

Signed-off-by: Eivind Versvik <versvikeivind@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotop: do not use previous colleced data wheh "h" toggles threads display
Denys Vlasenko [Sun, 11 Aug 2019 14:17:11 +0000 (16:17 +0200)]
top: do not use previous colleced data wheh "h" toggles threads display

This prevents first update from showing incorrect CPU usage data

function                                             old     new   delta
handle_input                                         620     643     +23

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc6: s/iphdr/ip6_hdr/
Denys Vlasenko [Fri, 9 Aug 2019 18:43:40 +0000 (20:43 +0200)]
udhcpc6: s/iphdr/ip6_hdr/

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agonmeter: do not clamp down %Nc to minimum of 10 (think nmeter "%`nproc`c")
Denys Vlasenko [Tue, 6 Aug 2019 14:56:00 +0000 (16:56 +0200)]
nmeter: do not clamp down %Nc to minimum of 10 (think nmeter "%`nproc`c")

Also, go for unsigned divisions.

function                                             old     new   delta
init_cpu                                              61      73     +12
collect_cpu                                          444     422     -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 12/-22)            Total: -10 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agostat: print nanosecond times, fix printing of empty lines
Denys Vlasenko [Sat, 3 Aug 2019 16:08:27 +0000 (18:08 +0200)]
stat: print nanosecond times, fix printing of empty lines

function                                             old     new   delta
human_time                                            36      73     +37

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: fix set -o to not show "nameless" options
Denys Vlasenko [Fri, 2 Aug 2019 14:43:36 +0000 (16:43 +0200)]
ash: fix set -o to not show "nameless" options

Patch by Martijn Dekker <martijn@inlv.org>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotar: change -a from meaning "lzma" to mean "autodetect by extension"
Denys Vlasenko [Fri, 2 Aug 2019 13:19:56 +0000 (15:19 +0200)]
tar: change -a from meaning "lzma" to mean "autodetect by extension"

function                                             old     new   delta
tar_main                                            1026    1100     +74
packed_usage                                       33311   33329     +18
tar_longopts                                         309     325     +16
vfork_compressor                                     246     210     -36
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 108/-36)            Total: 72 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotar: code shrink
Denys Vlasenko [Thu, 1 Aug 2019 13:07:21 +0000 (15:07 +0200)]
tar: code shrink

function                                             old     new   delta
writeLongname                                        226     228      +2
static.prefilled                                      48       -     -48
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 2/-48)             Total: -46 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: only catch unexpected exceptions in PS1 expansion
Ron Yorston [Mon, 29 Jul 2019 08:51:14 +0000 (09:51 +0100)]
ash: only catch unexpected exceptions in PS1 expansion

Commit d1a2fa2a4 (ash: catch error in arithmetic expansion in PS1)
catches all exceptions raised by expandarg().  Some exceptions, such as
the EXEXIT raised when command expansion is used, are expected:

   export PS1='$(echo "$ ")'

These should be processed normally or the shell hangs at the prompt.

function                                             old     new   delta
expandstr                                            344     353      +9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 9/0)                 Total: 9 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agounicode: code shrink in character width determination
Denys Vlasenko [Tue, 23 Jul 2019 09:26:54 +0000 (11:26 +0200)]
unicode: code shrink in character width determination

function                                             old     new   delta
bb_wcwidth                                           267     238     -29

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolibbb: include <crypt.h> only if necessary
Denys Vlasenko [Tue, 16 Jul 2019 13:09:06 +0000 (15:09 +0200)]
libbb: include <crypt.h> only if necessary

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agontpd: add comment about mode6, no code changes
Denys Vlasenko [Tue, 2 Jul 2019 13:03:47 +0000 (15:03 +0200)]
ntpd: add comment about mode6, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agontpd: commonalize message strings
Denys Vlasenko [Tue, 2 Jul 2019 11:10:19 +0000 (13:10 +0200)]
ntpd: commonalize message strings

function                                             old     new   delta
recv_and_process_peer_pkt                            961     973     +12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 12/0)               Total: 12 bytes
   text    data     bss     dec     hex filename
 953108     481    7288  960877   ea96d busybox_old
 953086     481    7288  960855   ea957 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolibbb: reduce the overhead of single parameter bb_error_msg() calls
James Byrne [Tue, 2 Jul 2019 09:35:03 +0000 (11:35 +0200)]
libbb: reduce the overhead of single parameter bb_error_msg() calls

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>
5 years agontpd: abort if argvs are (unexpectedly) given
Denys Vlasenko [Tue, 2 Jul 2019 09:28:18 +0000 (11:28 +0200)]
ntpd: abort if argvs are (unexpectedly) given

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agofree: include SReclaimable in cached value
Lukas Rusak [Tue, 25 Jun 2019 16:52:33 +0000 (18:52 +0200)]
free: include SReclaimable in cached value

I noticed that the 'used' values from busybox free and
procps-ng free differed so I looked into why. It turns
out that procps-ng uses the "SReclaimable" value as
part of the cached value.

This was changed in
procps-ng commit 05d751c4f076a2f0118b914c5e51cfbb4762ad8e

function                                             old     new   delta
free_main                                            633     653     +20

Signed-off-by: Lukas Rusak <lorusak@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolibbb: deal with "declaration of 'link' shadows a global declaration" warning
Denys Vlasenko [Tue, 25 Jun 2019 16:51:00 +0000 (18:51 +0200)]
libbb: deal with "declaration of 'link' shadows a global declaration" warning

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agopidof: support "pidof /path/to/binary" case
Denys Vlasenko [Sat, 15 Jun 2019 16:35:39 +0000 (18:35 +0200)]
pidof: support "pidof /path/to/binary" case

function                                             old     new   delta
find_pid_by_name                                     230     227      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoreadlink,realpath: fix a case with a symplink, closes 11021
Denys Vlasenko [Thu, 13 Jun 2019 15:08:29 +0000 (17:08 +0200)]
readlink,realpath: fix a case with a symplink, closes 11021

function                                             old     new   delta
xmalloc_realpath_coreutils                           125     201     +76

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc: fix comment, no code changes
Denys Vlasenko [Thu, 13 Jun 2019 08:02:03 +0000 (10:02 +0200)]
udhcpc: fix comment, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc6: fix aliasing warning
Denys Vlasenko [Tue, 11 Jun 2019 16:18:48 +0000 (18:18 +0200)]
udhcpc6: fix aliasing warning

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodhcpc.c: Added support for relay server parameter.
Martin Lewis [Mon, 10 Jun 2019 15:06:17 +0000 (17:06 +0200)]
dhcpc.c: Added support for relay server parameter.

Resolved a TODO by adding support for gateway_nip parameter.

function                                             old     new   delta
udhcp_run_script                                     792     835     +43

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoStart 1.32.0 development cycle
Denys Vlasenko [Mon, 10 Jun 2019 10:52:16 +0000 (12:52 +0200)]
Start 1.32.0 development cycle

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoBump version to 1.31.0 1_31_0
Denys Vlasenko [Mon, 10 Jun 2019 09:53:46 +0000 (11:53 +0200)]
Bump version to 1.31.0

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agomount,losetup: use /dev/loop-control is it exists
Denys Vlasenko [Sun, 9 Jun 2019 21:20:49 +0000 (23:20 +0200)]
mount,losetup: use /dev/loop-control is it exists

function                                             old     new   delta
get_free_loop                                          -      58     +58
set_loop                                             597     649     +52
losetup_main                                         482     476      -6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 110/-6)            Total: 104 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agostart-stop-daemon: change priority before dropping privileges
Aitor Esteve Alvarado [Thu, 7 Mar 2019 09:14:48 +0000 (10:14 +0100)]
start-stop-daemon: change priority before dropping privileges

Currently start-stop-daemon fails when using both the -c option (set uid)
and -N option (set niceness/priority) as it first drops privileges and then
tries to increase the priority. This patch changes the order of execution.

Signed-off-by: Aitor Esteve Alvarado <aesteve@singularaircraft.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotftp: allow -lc and -cl options
Denys Vlasenko [Sun, 9 Jun 2019 10:41:17 +0000 (12:41 +0200)]
tftp: allow -lc and -cl options

function                                             old     new   delta
tftp_main                                            394     396      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotftpd: revert erroneous change
Denys Vlasenko [Sun, 9 Jun 2019 09:32:23 +0000 (11:32 +0200)]
tftpd: revert erroneous change

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotftp: optional tftp-hpa compat
Denys Vlasenko [Sun, 9 Jun 2019 09:12:02 +0000 (11:12 +0200)]
tftp: optional tftp-hpa compat

function                                             old     new   delta
tftp_main                                            276     394    +118

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoexpand: add commented-out code to handle NULs
Denys Vlasenko [Sun, 9 Jun 2019 07:16:03 +0000 (09:16 +0200)]
expand: add commented-out code to handle NULs

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoexpand,unexpand: drop broken test, add FIXME comment
Denys Vlasenko [Sat, 8 Jun 2019 11:04:44 +0000 (13:04 +0200)]
expand,unexpand: drop broken test, add FIXME comment

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoawk: fix testsuite
Denys Vlasenko [Sat, 8 Jun 2019 11:00:46 +0000 (13:00 +0200)]
awk: fix testsuite

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobc: placate compiler warnings
Denys Vlasenko [Sat, 8 Jun 2019 10:58:16 +0000 (12:58 +0200)]
bc: placate compiler warnings

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: code shrink
Denys Vlasenko [Sat, 8 Jun 2019 10:57:07 +0000 (12:57 +0200)]
vi: code shrink

function                                             old     new   delta
colon                                               2852    2846      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobc: placate compiler warnings
Denys Vlasenko [Sat, 8 Jun 2019 10:39:30 +0000 (12:39 +0200)]
bc: placate compiler warnings

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobrctl: placate compiler warnings
Denys Vlasenko [Sat, 8 Jun 2019 10:35:06 +0000 (12:35 +0200)]
brctl: placate compiler warnings

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoblockdev: add usage comment, no code changes
Denys Vlasenko [Sat, 8 Jun 2019 06:57:11 +0000 (08:57 +0200)]
blockdev: add usage comment, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: .js is "application/javascript", not "application/x-javascript"
Denys Vlasenko [Fri, 7 Jun 2019 10:32:30 +0000 (12:32 +0200)]
httpd: .js is "application/javascript", not "application/x-javascript"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agopasswd: do not set 0 as date of last password change, closes 11951
Denys Vlasenko [Fri, 7 Jun 2019 10:29:24 +0000 (12:29 +0200)]
passwd: do not set 0 as date of last password change, closes 11951

function                                             old     new   delta
update_passwd                                       1491    1505     +14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: add js to built in MIME types list
Denys Vlasenko [Fri, 7 Jun 2019 07:32:03 +0000 (09:32 +0200)]
httpd: add js to built in MIME types list

Firefox needs this to execute .js

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: add svg to built in MIME types list
Vicente Jimenez Aguilar [Thu, 6 Jun 2019 15:12:55 +0000 (17:12 +0200)]
httpd: add svg to built in MIME types list

Signed-off-by: Vicente Jimenez Aguilar <googuy@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolpd: avoid SEGVing on immediate EOF from peer
Denys Vlasenko [Fri, 7 Jun 2019 07:14:41 +0000 (09:14 +0200)]
lpd: avoid SEGVing on immediate EOF from peer

Patch by Luís Marques <luismarques@lowrisc.org>

function                                             old     new   delta
lpd_main                                             749     757      +8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolibbb: move netlink socket binding to the utility function
Denys Vlasenko [Mon, 3 Jun 2019 12:16:52 +0000 (14:16 +0200)]
libbb: move netlink socket binding to the utility function

function                                             old     new   delta
create_and_bind_to_netlink                             -     134    +134
ifplugd_main                                        1117    1052     -65
uevent_main                                          399     306     -93
mdev_main                                            314     215     -99
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 134/-257)         Total: -123 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agomdev: add support to run as daemon
Jan Klötzke [Tue, 7 May 2019 18:59:43 +0000 (20:59 +0200)]
mdev: add support to run as daemon

Adds the -d option to run mdev in daemon mode handling hotplug events
from the kernel like udev. If the system generates many hotplug events
this mode of operation will consume less resources than registering
mdev as hotplug helper or using the uevent applet.

function                                             old     new   delta
daemon_loop                                            -     152    +152
initial_scan                                           -     127    +127
open_mdev_log                                          -      85     +85
mdev_main                                            255     314     +59
packed_usage                                       33284   33316     +32
process_action                                      1051     992     -59
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 2/1 up/down: 455/-59)           Total: 396 bytes

Signed-off-by: Jan Klötzke <jan@kloetzke.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agomdev: use option parser helper
Jan Klötzke [Fri, 3 May 2019 20:35:51 +0000 (22:35 +0200)]
mdev: use option parser helper

function                                             old     new   delta
process_action                                         -    1051   +1051
mdev_main                                           1324     255   -1069
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 1051/-1069)        Total: -18 bytes

Signed-off-by: Jan Klötzke <jan@kloetzke.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agomdev: move action processing into separate functions
Jan Klötzke [Fri, 3 May 2019 20:35:50 +0000 (22:35 +0200)]
mdev: move action processing into separate functions

This purely moves code from main() to separate functions for better
extensibility.

Signed-off-by: Jan Klötzke <jan@kloetzke.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash,hush: show 'c' in $- if run in "sh -c CMD"
Denys Vlasenko [Mon, 3 Jun 2019 10:21:04 +0000 (12:21 +0200)]
ash,hush: show 'c' in $- if run in "sh -c CMD"

function                                             old     new   delta
options                                              552     599     +47
expand_one_var                                      2375    2385     +10
optletters_optnames                                   60      64      +4
hush_main                                           1108    1111      +3
ash_main                                            1150    1152      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/0 up/down: 66/0)               Total: 66 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: allocate line editing structure only if needed
Denys Vlasenko [Sat, 1 Jun 2019 14:35:09 +0000 (16:35 +0200)]
ash: allocate line editing structure only if needed

function                                             old     new   delta
optschanged                                           91     128     +37
historycmd                                            13      17      +4
setcmd                                                80      78      -2
ash_main                                            1167    1150     -17
options                                              576     552     -24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/3 up/down: 41/-43)             Total: -2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodhcp: downgrade "got raw socket fd" message to log3, make log2 default max
Denys Vlasenko [Fri, 31 May 2019 21:51:07 +0000 (23:51 +0200)]
dhcp: downgrade "got raw socket fd" message to log3, make log2 default max

log3 messages are very much redundant

function                                             old     new   delta
change_listen_mode                                   322     302     -20

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodhcp: get rid of static data signal_pipe
Denys Vlasenko [Fri, 31 May 2019 21:39:22 +0000 (23:39 +0200)]
dhcp: get rid of static data signal_pipe

function                                             old     new   delta
udhcp_sp_setup                                        65     110     +45
udhcp_sp_fd_set                                       60      59      -1
udhcpd_main                                         1442    1437      -5
udhcpc_main                                         2684    2679      -5
signal_pipe                                            8       -      -8
packed_usage                                       33292   33284      -8
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/4 up/down: 45/-27)             Total: 18 bytes
   text    data     bss     dec     hex filename
 952746     481    7296  960523   ea80b busybox_old
 952768     481    7288  960537   ea819 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcp: rename server_config to server_data
Denys Vlasenko [Thu, 30 May 2019 14:23:34 +0000 (16:23 +0200)]
udhcp: rename server_config to server_data

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolosetup: Add partition scanning option
Jack O'Sullivan [Tue, 28 May 2019 14:28:27 +0000 (15:28 +0100)]
losetup: Add partition scanning option

Add -P option from util-linux losetup to scan for partitions.

function                                             old     new   delta
losetup_main                                         449     482     +33
packed_usage                                       33264   33292     +28
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 61/0)               Total: 61 bytes

Signed-off-by: Jack O'Sullivan <jackos1998@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcp: rename client_config to client_data, server_config to server_data
Denys Vlasenko [Sun, 26 May 2019 13:01:13 +0000 (15:01 +0200)]
udhcp: rename client_config to client_data, server_config to server_data

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc6: Fixed aliasing compilation error
Martin Lewis [Sun, 26 May 2019 12:22:44 +0000 (14:22 +0200)]
udhcpc6: Fixed aliasing compilation error

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoshell: move all definitions of strto_arith_t() together
Denys Vlasenko [Sun, 26 May 2019 12:02:10 +0000 (14:02 +0200)]
shell: move all definitions of strto_arith_t() together

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agols: fix SEGV when --color is used and ENABLE_LS_COLOR=n
Denys Vlasenko [Sun, 26 May 2019 11:53:41 +0000 (13:53 +0200)]
ls: fix SEGV when --color is used and ENABLE_LS_COLOR=n

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotestsuite: fix bunzip2.tests expectations
Denys Vlasenko [Sun, 26 May 2019 11:51:41 +0000 (13:51 +0200)]
testsuite: fix bunzip2.tests expectations

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agocomment fix
Denys Vlasenko [Sun, 26 May 2019 11:46:49 +0000 (13:46 +0200)]
comment fix

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolibarchive: treat one "FIXME: avoid seek", take 2
Denys Vlasenko [Sun, 26 May 2019 11:43:06 +0000 (13:43 +0200)]
libarchive: treat one "FIXME: avoid seek", take 2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodhcp: get rid of last global data
Denys Vlasenko [Sun, 26 May 2019 11:05:04 +0000 (13:05 +0200)]
dhcp: get rid of last global data

function                                             old     new   delta
udhcpc_main                                         2680    2684      +4
state                                                  1       -      -1
listen_mode                                            1       -      -1
sockfd                                                 4       -      -4
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 1/0 up/down: 4/-6)               Total: -2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolibarchive: treat one "FIXME: avoid seek"
Denys Vlasenko [Fri, 24 May 2019 15:03:28 +0000 (17:03 +0200)]
libarchive: treat one "FIXME: avoid seek"

function                                             old     new   delta
xmalloc_read_with_initial_buf                          -     205    +205
setup_transformer_on_fd                              154     150      -4
xmalloc_open_zipped_read_close                       143     135      -8
xmalloc_read                                         201      10    -191
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 205/-203)            Total: 2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolosetup: implement -c
Denys Vlasenko [Thu, 23 May 2019 14:11:42 +0000 (16:11 +0200)]
losetup: implement -c

function                                             old     new   delta
losetup_main                                         422     449     +27
packed_usage                                       33243   33264     +21
get_next_block                                      1677    1681      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 52/0)               Total: 52 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodhcp: tweak comments, no code changes
Denys Vlasenko [Thu, 23 May 2019 13:24:03 +0000 (15:24 +0200)]
dhcp: tweak comments, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobunzip2: the correct condition is "n < groupCount", not "n <= groupCount". Closes...
Denys Vlasenko [Thu, 23 May 2019 12:54:13 +0000 (14:54 +0200)]
bunzip2: the correct condition is "n < groupCount", not "n <= groupCount". Closes 11896

function                                             old     new   delta
get_next_block                                      1677    1681      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoip: use rtnl_send_check() on flush commands, closes 6962
Denys Vlasenko [Wed, 22 May 2019 11:54:46 +0000 (13:54 +0200)]
ip: use rtnl_send_check() on flush commands, closes 6962

function                                             old     new   delta
rtnl_send_check                                        -     160    +160
xrtnl_wilddump_request                                64      66      +2
ipneigh_list_or_flush                                714     706      -8
rtnl_send                                             69       -     -69
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/1 up/down: 162/-77)            Total: 85 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years ago*: slap on a few ALIGN1/2s where appropriate
Denys Vlasenko [Tue, 21 May 2019 15:29:24 +0000 (17:29 +0200)]
*: slap on a few ALIGN1/2s where appropriate

The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map"

   text    data     bss     dec     hex filename
 952537     485    7296  960318   ea73e busybox_old
 952527     485    7296  960308   ea734 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpd: fix printing of static leases
Denys Vlasenko [Tue, 21 May 2019 14:06:34 +0000 (16:06 +0200)]
udhcpd: fix printing of static leases

function                                             old     new   delta
read_staticlease                                     299     282     -17

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohush: show 's' in $-
Denys Vlasenko [Sun, 19 May 2019 17:11:21 +0000 (19:11 +0200)]
hush: show 's' in $-

function                                             old     new   delta
expand_one_var                                      2362    2375     +13
hush_main                                           1104    1108      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 17/0)               Total: 17 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohush: allocate line edit buffer only for interactive shell
Denys Vlasenko [Sun, 19 May 2019 16:24:52 +0000 (18:24 +0200)]
hush: allocate line edit buffer only for interactive shell

function                                             old     new   delta
builtin_history                                       16      20      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoshell: implement optional "BASE#nnnn" numeric literals
Denys Vlasenko [Sun, 19 May 2019 15:23:31 +0000 (17:23 +0200)]
shell: implement optional "BASE#nnnn" numeric literals

function                                             old     new   delta
evaluate_string                                      729     851    +122

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohush: remove test for "echo ${-}" errorring out - now it works
Denys Vlasenko [Sun, 19 May 2019 14:35:56 +0000 (16:35 +0200)]
hush: remove test for "echo ${-}" errorring out - now it works

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohush: implement $-, set default PATH if it is not set on startup
Denys Vlasenko [Sun, 19 May 2019 14:29:09 +0000 (16:29 +0200)]
hush: implement $-, set default PATH if it is not set on startup

function                                             old     new   delta
expand_one_var                                      2311    2362     +51
hush_main                                           1075    1104     +29
parse_dollar                                         790     791      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 81/0)               Total: 81 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohush: set default PS1/2 only if we interactive
Denys Vlasenko [Sun, 19 May 2019 13:37:50 +0000 (15:37 +0200)]
hush: set default PS1/2 only if we interactive

"env - hush SCRIPT" invocation (that is, with empty environment)
should not show PS1/2 in "set" output.

function                                             old     new   delta
hush_main                                           1070    1075      +5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohush: handle LINENO the same way as RANDOM: variable is "ephemeral"
Denys Vlasenko [Sun, 19 May 2019 13:26:05 +0000 (15:26 +0200)]
hush: handle LINENO the same way as RANDOM: variable is "ephemeral"

"env - hush" invocation (that is, with empty environment)
should not show LINENO in "set" output.

function                                             old     new   delta
get_local_var_value                                  263     294     +31
hush_main                                           1105    1070     -35
handle_changed_special_names                          79      38     -41
run_pipe                                            1834    1765     -69
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 31/-145)          Total: -114 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agonetworking: cc is not a register
Khem Raj [Thu, 7 Mar 2019 05:06:10 +0000 (21:06 -0800)]
networking: cc is not a register

gcc accepts

  __asm__ ( "" : : : "%cc");

but cc is not a real register and clang does not like it.

networking/tls_pstm_montgomery_reduce.c:385:4: error: unknown register name '%cc' in asm
|                         INNERMUL;
|                         ^

The % syntax nominally goes before a register, in this case cc,
like "memory" isn't a true register it's just a way of specifying that
the condition code registers for the target are clobbered

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohush: remove code to track PS1/2 values dynamically - it's too much work
Denys Vlasenko [Thu, 16 May 2019 13:39:19 +0000 (15:39 +0200)]
hush: remove code to track PS1/2 values dynamically - it's too much work

Assignments / exports / unsets of variables are far more frequent than
prompt printing, and if we show prompt, we are likely to be limited by
user typing speed - do not optimize for that scenario.
Just re-query $PS1 / $PS2 values when need to show the prompt.

function                                             old     new   delta
fgetc_interactive                                    236     259     +23
set_vars_and_save_old                                150     147      -3
pseudo_exec_argv                                     597     594      -3
hush_main                                           1110    1105      -5
enter_var_nest_level                                  38      32      -6
builtin_local                                         56      50      -6
run_pipe                                            1857    1834     -23
leave_var_nest_level                                 127      98     -29
handle_changed_special_names                         111      79     -32
cmdedit_update_prompt                                 57       -     -57
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/8 up/down: 23/-164)          Total: -141 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotypo fix in comment
Denys Vlasenko [Thu, 16 May 2019 12:31:58 +0000 (14:31 +0200)]
typo fix in comment

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohush: small speedup in handle_changed_special_names()
Denys Vlasenko [Thu, 16 May 2019 09:32:26 +0000 (11:32 +0200)]
hush: small speedup in handle_changed_special_names()

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpd: code shrink
Denys Vlasenko [Thu, 16 May 2019 09:27:28 +0000 (11:27 +0200)]
udhcpd: code shrink

function                                             old     new   delta
send_packet_verbose                                    -      35     +35
send_offer                                           443     423     -20
send_ACK                                             152     131     -21
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 35/-41)             Total: -6 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpd: support per-client hostnames in static leases
Denys Vlasenko [Thu, 16 May 2019 09:18:49 +0000 (11:18 +0200)]
udhcpd: support per-client hostnames in static leases

function                                             old     new   delta
read_staticlease                                     222     299     +77
add_server_options                                    92     154     +62
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 139/0)             Total: 139 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoshell: add TODO comment about BASE#nnn literals
Denys Vlasenko [Thu, 16 May 2019 07:56:45 +0000 (09:56 +0200)]
shell: add TODO comment about BASE#nnn literals

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodc: make 4 % 0 emit error messgaes and set result to 0
Denys Vlasenko [Thu, 16 May 2019 07:40:36 +0000 (09:40 +0200)]
dc: make 4 % 0 emit error messgaes and set result to 0

function                                             old     new   delta
mod                                                  105     136     +31

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc6: unbreak
Denys Vlasenko [Wed, 15 May 2019 12:19:46 +0000 (14:19 +0200)]
udhcpc6: unbreak

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohush: fix quoted "${notexist-}" expansion to not disappear
Denys Vlasenko [Wed, 15 May 2019 11:39:19 +0000 (13:39 +0200)]
hush: fix quoted "${notexist-}" expansion to not disappear

function                                             old     new   delta
expand_one_var                                      2296    2311     +15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpd: code shrink - do not fetch requested IP twice
Denys Vlasenko [Wed, 15 May 2019 11:08:48 +0000 (13:08 +0200)]
udhcpd: code shrink - do not fetch requested IP twice

function                                             old     new   delta
send_offer                                           444     443      -1
udhcpd_main                                         1454    1442     -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-13)             Total: -13 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoshells: add tests for backslashes in export VAR=VAL
Denys Vlasenko [Tue, 14 May 2019 17:15:20 +0000 (19:15 +0200)]
shells: add tests for backslashes in export VAR=VAL

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohush: fix "export PS1=xyz" and "local PS1=xyz" messing up prompt
Denys Vlasenko [Tue, 14 May 2019 16:53:24 +0000 (18:53 +0200)]
hush: fix "export PS1=xyz" and "local PS1=xyz" messing up prompt

function                                             old     new   delta
helper_export_local                                  215     253     +38
leave_var_nest_level                                 107     127     +20
run_pipe                                            1840    1857     +17
handle_changed_special_names                         101     105      +4
shell_builtin_read                                  1399    1398      -1
done_word                                            767     766      -1
parse_stream                                        2249    2245      -4
set_local_var                                        437     430      -7
is_well_formed_var_name                               66       -     -66
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 4/4 up/down: 79/-79)              Total: 0 bytes
   text    data     bss     dec     hex filename
 952376     485    7296  960157   ea69d busybox_old
 952400     485    7296  960181   ea6b5 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>