oweals/busybox.git
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>
5 years agodd: fix handling of short result of full_write(), closes 11711
Denys Vlasenko [Tue, 14 May 2019 15:46:18 +0000 (17:46 +0200)]
dd: fix handling of short result of full_write(), closes 11711

$ dd bs=1G <sda1 of=/dev/sda1
dd: error writing '/dev/sda1': No space left on device
1+0 records in
0+0 records out
999292928 bytes (953.0MB) copied, 0.784617 seconds, 1.2GB/s

function                                             old     new   delta
write_and_stats                                       99     102      +3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agostyle fix, no code changes
Denys Vlasenko [Tue, 14 May 2019 15:26:47 +0000 (17:26 +0200)]
style fix, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agosed: fix /regex/,+N match triggering only once, closes 11871
Denys Vlasenko [Mon, 13 May 2019 14:29:34 +0000 (16:29 +0200)]
sed: fix /regex/,+N match triggering only once, closes 11871

function                                             old     new   delta
process_files                                       2235    2246     +11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpd: code shrink
Denys Vlasenko [Fri, 10 May 2019 13:55:12 +0000 (15:55 +0200)]
udhcpd: code shrink

function                                             old     new   delta
is_nip_reserved_as_static                              -      28     +28
get_static_nip_by_mac                                 43      47      +4
udhcpd_main                                         1459    1454      -5
send_offer                                           449     444      -5
read_leases                                          309     299     -10
is_nip_reserved                                       20       -     -20
packed_usage                                       33283   33243     -40
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/4 up/down: 32/-80)            Total: -48 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoln: correct 'ln -T' usage message
John L. Hammond [Thu, 9 May 2019 14:22:09 +0000 (09:22 -0500)]
ln: correct 'ln -T' usage message

Signed-off-by: John L. Hammond <jhammond@indeed.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodc: code shrink
Denys Vlasenko [Thu, 9 May 2019 13:58:46 +0000 (15:58 +0200)]
dc: code shrink

function                                             old     new   delta
check_under                                           20      21      +1
print_no_pop                                          32      27      -5
pop                                                   24      18      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 1/-11)             Total: -10 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agops: ensure fields are separated by at least one space, closes 11826
Denys Vlasenko [Fri, 3 May 2019 07:49:56 +0000 (09:49 +0200)]
ps: ensure fields are separated by at least one space, closes 11826

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agologin: remove extra IF(), no code changes
Denys Vlasenko [Thu, 2 May 2019 15:13:20 +0000 (17:13 +0200)]
login: remove extra IF(), no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoOptionally re-introduce bb_info_msg()
James Byrne [Fri, 12 Apr 2019 17:01:51 +0000 (17:01 +0000)]
Optionally re-introduce bb_info_msg()

Between Busybox 1.24.2 and 1.25.0 the bb_info_msg() function was
eliminated and calls to it changed to be bb_error_msg(). The downside of
this is that daemons now log all messages to syslog at the LOG_ERR level
which makes it hard to filter errors from informational messages.

This change optionally re-introduces bb_info_msg(), controlled by a new
option FEATURE_SYSLOG_INFO, restores all the calls to bb_info_msg() that
were removed (only in applets that set logmode to LOGMODE_SYSLOG or
LOGMODE_BOTH), and also changes informational messages in ifplugd and
ntpd.

The code size change of this is as follows (using 'defconfig' on x86_64
with gcc 7.3.0-27ubuntu1~18.04)

function                                             old     new   delta
bb_info_msg                                            -     182    +182
bb_vinfo_msg                                           -      27     +27
static.log7                                          194     198      +4
log8                                                 190     191      +1
log5                                                 190     191      +1
crondlog                                              45       -     -45
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 3/0 up/down: 215/-45)           Total: 170 bytes

If you don't care about everything being logged at LOG_ERR level
then when FEATURE_SYSLOG_INFO is disabled Busybox actually gets smaller:

function                                             old     new   delta
static.log7                                          194     200      +6
log8                                                 190     193      +3
log5                                                 190     193      +3
syslog_level                                           1       -      -1
bb_verror_msg                                        583     581      -2
crondlog                                              45       -     -45
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 3/1 up/down: 12/-48)            Total: -36 bytes

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolibbbb: find_mount_point() too eager to stat mounted devices
Denys Vlasenko [Mon, 29 Apr 2019 15:59:08 +0000 (17:59 +0200)]
libbbb: find_mount_point() too eager to stat mounted devices

None of the below "devices" (first word on the line) are real.

sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
devtmpfs /dev devtmpfs rw,nosuid,size=7917900k,nr_inodes=1979475,mode=755 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0
tmpfs /tmp tmpfs rw,relatime 0 0

function                                             old     new   delta
find_mount_point                                     297     302      +5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agostart-stop-daemon: do try to close fds > 2
Denys Vlasenko [Mon, 29 Apr 2019 12:24:07 +0000 (14:24 +0200)]
start-stop-daemon: do try to close fds > 2

sh -c 'exec 3>&1; exec start-stop-daemon -S -b -x /bin/sleep -- 123'

now closes fd 3.

function                                             old     new   delta
bb_daemonize_or_rexec                                183     192      +9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 9/0)                 Total: 9 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoip: fix comment placement
Denys Vlasenko [Sun, 28 Apr 2019 22:34:07 +0000 (00:34 +0200)]
ip: fix comment placement

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoifupdown: close memory leak
Denys Vlasenko [Sun, 28 Apr 2019 15:55:27 +0000 (17:55 +0200)]
ifupdown: close memory leak

function                                             old     new   delta
execute_all                                           80      91     +11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: enable 'dG' command. Closes 11801
Ron Yorston [Sun, 28 Apr 2019 08:10:16 +0000 (09:10 +0100)]
vi: enable 'dG' command. Closes 11801

The 'G' command was omitted from the list of commands that change or
delete whole lines.  Add it in the appropriate places so the 'dG',
'cG' and 'yG' commands work, including in cases where an explicit
line number has been supplied.

function                                             old     new   delta
find_range                                           534     596     +62
.rodata                                           175166  175167      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 63/0)               Total: 63 bytes

Reported-by: David Kelly <david.kelly@liberica.ch>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: fix changes to word at end of line. Closes 11796
Ron Yorston [Sun, 28 Apr 2019 08:09:33 +0000 (09:09 +0100)]
vi: fix changes to word at end of line. Closes 11796

As reported in bug 11796 BusyBox vi incorrectly handles changes
to a word at the end of a line.  If the following line starts
with whitespace changing or deleting the last word of a line
with the 'cw' or 'dw' commands causes the lines to be joined.

This happens because the range for the change returned by
find_range() covers all whitespace after the word, including
newlines.  The problem can be fixed by setting 'ml' to zero
to indicate to yank_delete() that processing should stop at
the end of the current line.

However, this results in a new problem.  'dw' correctly deletes
all whitespace following the word but so does 'cw', which should
preserve the trailing whitespace.  To fix this the code to omit
whitespace from the change is modified to include all whitespace
not just blanks.

function                                             old     new   delta
do_cmd                                              5034    5069     +35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 35/0)               Total: 35 bytes

Reported-by: David Kelly <david.kelly@liberica.ch>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash,hush: ulimit: add -i RLIMIT_SIGPENDING, -q RLIMIT_MSGQUEUE
Denys Vlasenko [Sun, 28 Apr 2019 09:25:11 +0000 (11:25 +0200)]
ash,hush: ulimit: add -i RLIMIT_SIGPENDING, -q RLIMIT_MSGQUEUE

function                                             old     new   delta
limits_tbl                                           104     120     +16
ulimit_opt_string                                     44      50      +6
limit_chars                                           14      16      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 24/0)               Total: 24 bytes
   text    data     bss     dec     hex filename
 981996     485    7296  989777   f1a51 busybox_old
 982065     485    7296  989846   f1a96 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash,hush: bash compat for ulimit: reorder to match
Denys Vlasenko [Sun, 28 Apr 2019 09:20:09 +0000 (11:20 +0200)]
ash,hush: bash compat for ulimit: reorder to match

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash,hush: bash compat for ulimit: -w => -x, -p => -u
Denys Vlasenko [Sat, 27 Apr 2019 19:23:39 +0000 (21:23 +0200)]
ash,hush: bash compat for ulimit: -w => -x, -p => -u

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash,hush: fix ulimit to be more bash-compat, closes 11791
Denys Vlasenko [Sat, 27 Apr 2019 19:01:35 +0000 (21:01 +0200)]
ash,hush: fix ulimit to be more bash-compat, closes 11791

function                                             old     new   delta
shell_builtin_ulimit                                 486     651    +165
limit_chars                                            -      14     +14
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 179/0)             Total: 179 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agostart-stop-daemon: Fix -x is not required for -K
Alexander Vickberg [Sat, 27 Apr 2019 13:42:41 +0000 (15:42 +0200)]
start-stop-daemon: Fix -x is not required for -K

Commit 088fec36fedff2cd50437c95b7fb430abf8d303c made -x required for
all. However it isn't for -K.

function                                             old     new   delta
start_stop_daemon_main                              1084    1105     +21
packed_usage                                       33343   33326     -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 21/-17)              Total: 4 bytes

Signed-off-by: Alexander Vickberg <wickbergster@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoexamples/var_service: use "exec sleep 5" instead of "{ sleep 5; exit; }"
Denys Vlasenko [Sun, 21 Apr 2019 12:30:19 +0000 (14:30 +0200)]
examples/var_service: use "exec sleep 5" instead of "{ sleep 5; exit; }"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: do disable header reading timeout even if proxying
Denys Vlasenko [Fri, 19 Apr 2019 12:24:57 +0000 (14:24 +0200)]
httpd: do disable header reading timeout even if proxying

function                                             old     new   delta
handle_incoming_and_exit                            2362    2369      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: use full size of iobuf[] when piping CGI data
Denys Vlasenko [Fri, 19 Apr 2019 12:19:41 +0000 (14:19 +0200)]
httpd: use full size of iobuf[] when piping CGI data

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: do not set alarm() timeout if we read cached header
Denys Vlasenko [Fri, 19 Apr 2019 12:03:37 +0000 (14:03 +0200)]
httpd: do not set alarm() timeout if we read cached header

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: deindent code block, no code changes
Denys Vlasenko [Fri, 19 Apr 2019 12:02:51 +0000 (14:02 +0200)]
httpd: deindent code block, no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: require "HTTP/xyz" at the end of request line
Denys Vlasenko [Fri, 19 Apr 2019 11:59:58 +0000 (13:59 +0200)]
httpd: require "HTTP/xyz" at the end of request line

function                                             old     new   delta
handle_incoming_and_exit                            2379    2362     -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-17)             Total: -17 bytes
   text    data     bss     dec     hex filename
 981787     485    7296  989568   f1980 busybox_old
 981779     485    7296  989560   f1978 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: catch error in arithmetic expansion in PS1
Ron Yorston [Thu, 18 Apr 2019 08:49:13 +0000 (09:49 +0100)]
ash: catch error in arithmetic expansion in PS1

Setting PS1 to:

   PS1='$((123+))'

causes the shell to enter an infinite error loop:

   sh: arithmetic syntax error

Catch any exception raised by expandarg() in expandstr() and allow
processing to continue.

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

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: prevent error in backquotes in PS1 from exiting shell
Ron Yorston [Thu, 18 Apr 2019 08:48:13 +0000 (09:48 +0100)]
ash: prevent error in backquotes in PS1 from exiting shell

Setting PS1 to:

   PS1='`xxx(`'

causes the shell to terminate with the error:

   sh: syntax error: unexpected end of file (expecting ")")

This happens because old-style backquotes require the input to be reread
and thus call setinputstring() a second time.  Prevent the problem by
unwinding all recently opened files in expandstr().

function                                             old     new   delta
unwindfiles                                            -      22     +22
expandstr                                            247     262     +15
forkchild                                            631     625      -6
evalcommand                                         1694    1685      -9
ash_main                                            1346    1336     -10
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/3 up/down: 37/-25)             Total: 12 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agodc.tests: fix two test case to also depend on DC_BIG
Chen Qi [Wed, 17 Apr 2019 01:39:25 +0000 (09:39 +0800)]
dc.tests: fix two test case to also depend on DC_BIG

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: pass authorization header to CGI if not Basic
Alexander Vickberg [Thu, 18 Apr 2019 08:05:53 +0000 (10:05 +0200)]
httpd: pass authorization header to CGI if not Basic

Pass the Authorization header to CGI if not of type Basic. This will
make it possible for CGI to verify authorization headers of type
Bearer <token>.

function                                             old     new   delta
handle_incoming_and_exit                            2370    2379      +9

Signed-off-by: Alexander Vickberg <wickbergster@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: When sending gzipped content use content-length header
Alexander Vickberg [Wed, 17 Apr 2019 09:34:21 +0000 (11:34 +0200)]
httpd: When sending gzipped content use content-length header

Today for gzipped content httpd is using a header with name
Transfer-Length. However I can't find a header with that name in the
standards. Instead use Content-Length.

function                                             old     new   delta
.rodata                                           157940  157936      -4
send_headers                                         980     939     -41
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-45)             Total: -45 bytes

Signed-off-by: Alexander Vickberg <wickbergster@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: add bash-compatible EPOCH variables
Ron Yorston [Mon, 15 Apr 2019 09:52:05 +0000 (10:52 +0100)]
ash: add bash-compatible EPOCH variables

Bash 5.0 added the dynamic variable EPOCHSECONDS and EPOCHREALTIME
which return the number of seconds since the Unix Epoch as an
integer or float.  These are useful for logging or tracing.

function                                             old     new   delta
change_epoch                                           -      78     +78
.rodata                                           175167  175235     +68
varinit_data                                         264     312     +48
change_seconds                                         -      24     +24
change_realtime                                        -      24     +24
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 2/0 up/down: 242/0)             Total: 242 bytes
   text    data     bss     dec     hex filename
 938508    4203    1888  944599   e69d7 busybox_old
 938702    4203    1888  944793   e6a99 busybox_unstripped

v2: Cast tv_sec and tv_usec to unsigned quantities.
    Add brackets to macros.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: an unset dynamic variable should not be dynamic
Ron Yorston [Mon, 15 Apr 2019 09:49:35 +0000 (10:49 +0100)]
ash: an unset dynamic variable should not be dynamic

Commit b28d4c346 (ash: [VAR] Move unsetvar functionality into setvareq)
dropped the code that caused dynamic variables to lose their special
properties when unset.  Add it back again.

function                                             old     new   delta
setvareq                                             346     360     +14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 14/0)               Total: 14 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohush: add bash-compatible EPOCH variables
Ron Yorston [Mon, 15 Apr 2019 09:48:29 +0000 (10:48 +0100)]
hush: add bash-compatible EPOCH variables

Bash 5.0 added the dynamic variable EPOCHSECONDS and EPOCHREALTIME
which return the number of seconds since the Unix Epoch as an
integer or float.  These are useful for logging or tracing.

function                                             old     new   delta
get_local_var_value                                  207     302     +95
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 95/0)               Total: 95 bytes
   text    data     bss     dec     hex filename
 938702    4203    1888  944793   e6a99 busybox_old
 938797    4203    1888  944888   e6af8 busybox_unstripped

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: extract query string only after proxying check
Denys Vlasenko [Tue, 16 Apr 2019 11:35:56 +0000 (13:35 +0200)]
httpd: extract query string only after proxying check

function                                             old     new   delta
handle_incoming_and_exit                            2398    2370     -28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: make rmt_ip variable local
Denys Vlasenko [Tue, 16 Apr 2019 11:18:12 +0000 (13:18 +0200)]
httpd: make rmt_ip variable local

function                                             old     new   delta
handle_incoming_and_exit                            2385    2398     +13
if_ip_denied_send_HTTP_FORBIDDEN_and_exit             51      54      +3
get_line                                             110     106      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 16/-4)              Total: 12 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: check denied IPs even before reading 1st query line
Denys Vlasenko [Tue, 16 Apr 2019 10:59:20 +0000 (12:59 +0200)]
httpd: check denied IPs even before reading 1st query line

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: do not decode URL and headers if proxying - send all verbatim
Denys Vlasenko [Tue, 16 Apr 2019 10:45:26 +0000 (12:45 +0200)]
httpd: do not decode URL and headers if proxying - send all verbatim

function                                             old     new   delta
handle_incoming_and_exit                            2566    2385    -181

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: remove duplicate "decode URL escape sequences" code
Denys Vlasenko [Tue, 16 Apr 2019 09:58:28 +0000 (11:58 +0200)]
httpd: remove duplicate "decode URL escape sequences" code

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: put all headers into environment as HTTP_UPPERCASED_HEADER=val
Denys Vlasenko [Tue, 16 Apr 2019 09:37:02 +0000 (11:37 +0200)]
httpd: put all headers into environment as HTTP_UPPERCASED_HEADER=val

Set up environment variables before running the CGI script.
The variables will be named HTTP_<filtered_name> where the <filtered_name>
is the header name capitalized and all characters not matching
[a-z] | [A-Z] | [0-9] replaced with '_'.

function                                             old     new   delta
http_response                                         80      88      +8
http_response_type                                    20      22      +2
send_headers                                         718     715      -3
parse_conf                                          1481    1478      -3
get_line                                             128     110     -18
cgi_io_loop_and_exit                                 599     569     -30
send_cgi_and_exit                                    882     738    -144
handle_incoming_and_exit                            2793    2592    -201
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/6 up/down: 10/-399)          Total: -389 bytes
   text    data     bss     dec     hex filename
 982178     485    7296  989959   f1b07 busybox_old
 981675     485    7296  989456   f1910 busybox_unstripped

Signed-off-by: Alexander Vickberg <wickbergster@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: fix handling of EOF in get_line()
Denys Vlasenko [Tue, 16 Apr 2019 09:07:37 +0000 (11:07 +0200)]
httpd: fix handling of EOF in get_line()

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: add missing {}
Denys Vlasenko [Tue, 16 Apr 2019 08:14:50 +0000 (10:14 +0200)]
httpd: add missing {}

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: do not percent-decode URI if proxying
Denys Vlasenko [Tue, 16 Apr 2019 08:00:06 +0000 (10:00 +0200)]
httpd: do not percent-decode URI if proxying

The proxying is documented as follows:

P:/url:[http://]hostname[:port]/new/path

Howeverm urlcopy is not a true copy anymore when it is fdprint'ed
to proxy_fd, this is because percent_decode_in_place() is called
after the copy is created.

This breaks reverse proxying all URIs containing percent
encoded spaces, e.g. - because a decoded URI will be printed out
to proxy_fd instead of the original.

The fix keeps the logic in place to canonicalize the uri first,
before reverse proxying (one could argue that the uri
should be proxied completely unaltered, except for the prefix
rewrite).

function                                             old     new   delta
handle_incoming_and_exit                            2752    2792     +40

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: fix proxy headers passing - full_write() instead of write()
Denys Vlasenko [Sun, 14 Apr 2019 18:46:57 +0000 (20:46 +0200)]
httpd: fix proxy headers passing - full_write() instead of write()

function                                             old     new   delta
handle_incoming_and_exit                            2763    2752     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agohttpd: if remote IP is denied, send FORBIDDEN reply earlier
Denys Vlasenko [Sun, 14 Apr 2019 17:57:13 +0000 (19:57 +0200)]
httpd: if remote IP is denied, send FORBIDDEN reply earlier

While at it, fix sighup_handler to not clobber errno.

function                                             old     new   delta
send_HTTP_FORBIDDEN_and_exit_if_denied_ip              -      47     +47
sighup_handler                                        15      30     +15
handle_incoming_and_exit                            2791    2763     -28
checkPermIP                                           48       -     -48
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/1 up/down: 62/-76)            Total: -14 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc6: code shrink
Denys Vlasenko [Sun, 14 Apr 2019 15:01:10 +0000 (17:01 +0200)]
udhcpc6: code shrink

function                                             old     new   delta
d6_read_interface                                    593     582     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc6: add a few comments, no code changes.
Denys Vlasenko [Sat, 13 Apr 2019 17:43:15 +0000 (19:43 +0200)]
udhcpc6: add a few comments, no code changes.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcpc6: make it enabled in defconfig
Denys Vlasenko [Sat, 13 Apr 2019 15:32:40 +0000 (17:32 +0200)]
udhcpc6: make it enabled in defconfig

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoexamples/udhcp/simple.script: fix resolv.conf update if it is a dangling symlink
Rolf Eike Beer [Thu, 28 Mar 2019 14:29:29 +0000 (15:29 +0100)]
examples/udhcp/simple.script: fix resolv.conf update if it is a dangling symlink

If /etc/resolv.conf is a symlink to a tmpfs and the actual file does not
already exist, "readlink -f" will not detect it as symlink. Explicitely check
for that condition before and touch the file, making the other code work as
intended.

Signed-off-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoudhcp: add 100 and 101 dhcp options for ipv4
Antoine Girard-Vallée [Fri, 8 Mar 2019 14:24:42 +0000 (09:24 -0500)]
udhcp: add 100 and 101 dhcp options for ipv4

Support for the IEEE timezone string and timezone database strings (100
and 101 options respectively) is added for ipv4, conforming to RFC-4833.

The two options are passed to hook scripts in the variables tzstr and
tzdbstr.

function                                             old     new   delta
dhcp_option_strings                                  280     294     +14
dhcp_optflags                                         76      80      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 18/0)               Total: 18 bytes

Signed-off-by: Antoine Girard-Vallée <antoine.girard-vallee@savoirfairelinux.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobrctl: add TODO: "showmacs BR"
Denys Vlasenko [Sat, 13 Apr 2019 13:48:31 +0000 (15:48 +0200)]
brctl: add TODO: "showmacs BR"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobrctl: simplify str_to_jiffies()
Denys Vlasenko [Sat, 13 Apr 2019 12:17:55 +0000 (14:17 +0200)]
brctl: simplify str_to_jiffies()

function                                             old     new   delta
write_uint                                             -      96     +96
brctl_main                                           721     678     -43
write_ulong                                           96       -     -96
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/1 up/down: 96/-139)           Total: -43 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobrctl: convert remaining commands to work via /sys
Denys Vlasenko [Sat, 13 Apr 2019 11:58:06 +0000 (13:58 +0200)]
brctl: convert remaining commands to work via /sys

function                                             old     new   delta
write_ulong                                            -      96     +96
show_bridge                                          310     338     +28
static.ops                                             3       -      -3
arm_ioctl                                             20       -     -20
packed_usage                                       33344   33315     -29
brctl_main                                           885     721    -164
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 1/2 up/down: 124/-216)          Total: -92 bytes
   text    data     bss     dec     hex filename
 982112     485    7296  989893   f1ac5 busybox_old
 982157     485    7296  989938   f1af2 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agobrctl: make "show" command retrieve data from /sys
Denys Vlasenko [Fri, 12 Apr 2019 16:52:31 +0000 (18:52 +0200)]
brctl: make "show" command retrieve data from /sys

ioctl interface is obsolete and has no 32/64 compat shim,
making "brctl show" fail for 32-bit userspace and 64-bit kernel.

function                                             old     new   delta
show_bridge                                            -     310    +310
read_file                                              -      64     +64
if_indextoname                                       117       -    -117
brctl_main                                          1183     885    -298
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/1 up/down: 374/-415)          Total: -41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agostat: reduce storage for human-readable filesystem names
Ron Yorston [Mon, 18 Mar 2019 11:14:52 +0000 (11:14 +0000)]
stat: reduce storage for human-readable filesystem names

function                                             old     new   delta
static.humanname                                       -     236    +236
static.fstype                                          -     140    +140
print_statfs                                         339     341      +2
static.humantypes                                    288       -    -288
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/0 up/down: 378/-288)           Total: 90 bytes
   text    data     bss     dec     hex filename
 982183     485    7296  989964   f1b0c busybox_old
 982152     485    7296  989933   f1aed busybox_unstripped

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoipaddress: remove unused variable no_link
Bernhard Reutner-Fischer [Sun, 7 Apr 2019 16:09:37 +0000 (18:09 +0200)]
ipaddress: remove unused variable no_link

ipaddress.c: In function ‘ipaddr_list_or_flush’:
ipaddress.c:427:6: warning: variable ‘no_link’ set but not used [-Wunused-but-set-variable]

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
5 years agoservice examples: if iface do not exist, retry upping it
Denys Vlasenko [Fri, 5 Apr 2019 16:38:12 +0000 (18:38 +0200)]
service examples: if iface do not exist, retry upping it

I've had a case of a machine where eth0 was appearing a bit later
after the boot, and appearing _downed_. ifplugd then fails to detect
"link up". Thus, depending on how service startup
("ip link set dev eth0 up") races with driver initialization,
ethernet randomly fails to initialize on boot.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agochrt: fix for SCHED_RESET_ON_FORK bit
Denys Vlasenko [Fri, 5 Apr 2019 14:59:07 +0000 (16:59 +0200)]
chrt: fix for SCHED_RESET_ON_FORK bit

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agochrt: do not segfault if policy number is unknown
Denys Vlasenko [Fri, 5 Apr 2019 10:03:48 +0000 (12:03 +0200)]
chrt: do not segfault if policy number is unknown

While at it, improve help text

function                                             old     new   delta
packed_usage                                       33319   33344     +25
policy_name                                            -      22     +22
show_min_max                                          59      64      +5
chrt_main                                            432     429      -3
policies                                              72       -     -72
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 2/1 up/down: 52/-75)            Total: -23 bytes
   text    data     bss     dec     hex filename
 982150     485    7296  989931   f1aeb busybox_old
 982183     485    7296  989964   f1b0c busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotelnetd: whitespace fix
Denys Vlasenko [Thu, 4 Apr 2019 14:54:14 +0000 (16:54 +0200)]
telnetd: whitespace fix

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotelnetd: better AYT handling
Denys Vlasenko [Thu, 4 Apr 2019 14:00:23 +0000 (16:00 +0200)]
telnetd: better AYT handling

function                                             old     new   delta
telnetd_main                                        1792    1837     +45

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotelnetd: Added support for AYT IAC command.
Martin Lewis [Thu, 4 Apr 2019 11:29:32 +0000 (13:29 +0200)]
telnetd: Added support for AYT IAC command.

Fixed a TODO in AYT IAC handling by replying back with a NOP.

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agotop: provide cmdline argument '-H' to enable thread scanning by default
Thomas De Schampheleire [Tue, 26 Mar 2019 12:10:21 +0000 (13:10 +0100)]
top: provide cmdline argument '-H' to enable thread scanning by default

In particular useful when you want to evaluate the threads in batch mode:
    top -Hbn1

function                                             old     new   delta
top_main                                             928     941     +13
packed_usage                                       33317   33319      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 15/0)               Total: 15 bytes

Signed-off-by: Philippe Belet <philippe.belet@nokia.com>
Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: revert change in how "end of file list" is deteced - fixes 'q' in bare "vi"
Denys Vlasenko [Wed, 3 Apr 2019 14:35:23 +0000 (16:35 +0200)]
vi: revert change in how "end of file list" is deteced - fixes 'q' in bare "vi"

function                                             old     new   delta
vi_main                                              273     272      -1
colon                                               2853    2852      -1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-2)               Total: -2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: code shrink
Denys Vlasenko [Wed, 3 Apr 2019 14:30:50 +0000 (16:30 +0200)]
vi: code shrink

function                                             old     new   delta
new_screen                                            84      75      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: avoid build failure in non-default case
Ron Yorston [Wed, 3 Apr 2019 07:56:30 +0000 (08:56 +0100)]
vi: avoid build failure in non-default case

If vi is built with FEATURE_VI_USE_SIGNALS disabled and
FEATURE_VI_WIN_RESIZE enabled new_screen() is used without a
declaration.  Move the function to avoid this.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agofsync,sync: merge into one source module
Denys Vlasenko [Tue, 2 Apr 2019 12:54:56 +0000 (14:54 +0200)]
fsync,sync: merge into one source module

With FEATURE_SYNC_FANCY not set:

function                                             old     new   delta
fsync_main                                           130     123      -7

With FEATURE_SYNC_FANCY set, should be much larger code size savings.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agofsync,sync: make them similar
Denys Vlasenko [Tue, 2 Apr 2019 12:39:56 +0000 (14:39 +0200)]
fsync,sync: make them similar

sync: add O_NOCTTY
fsync: drop O_NOATIME, add O_NONBLOCK, set exitcode to 1 if fsync() fails,
    update --help message to be similar to sync.
both: reformat code to minimize "diff -u sync.c fsync.c":
    in particular, they use same open() flags now

function                                             old     new   delta
fsync_main                                           126     130      +4
packed_usage                                       33316   33317      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 5/0)                 Total: 5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoash: distinguish 'wait -n' from other bashisms
Ron Yorston [Sun, 31 Mar 2019 08:27:09 +0000 (09:27 +0100)]
ash: distinguish 'wait -n' from other bashisms

Add a specific define to indicate which bash compatibility code
implements 'wait -n'.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: rename save_argc -> cmdline_filecnt
Denys Vlasenko [Tue, 2 Apr 2019 10:45:30 +0000 (12:45 +0200)]
vi: rename save_argc -> cmdline_filecnt

function                                             old     new   delta
vi_main                                              272     273      +1
colon                                               2852    2853      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: restore capability to remember insertion cmds for "."
Denys Vlasenko [Tue, 2 Apr 2019 09:50:25 +0000 (11:50 +0200)]
vi: restore capability to remember insertion cmds for "."

function                                             old     new   delta
modifying_cmds                                        17      22      +5
get_one_char                                         103      98      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 5/-5)                Total: 0 bytes
   text    data     bss     dec     hex filename
 982121     485    7296  989902   f1ace busybox_old
 982094     485    7296  989875   f1ab3 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: code shrink
Denys Vlasenko [Mon, 1 Apr 2019 15:17:02 +0000 (17:17 +0200)]
vi: code shrink

function                                             old     new   delta
get_input_line                                       172     175      +3
char_insert                                          444     447      +3
rawmode                                               36      24     -12
edit_file                                            644     626     -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 6/-30)             Total: -24 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: convert more /**/ comments to //
Denys Vlasenko [Mon, 1 Apr 2019 14:38:06 +0000 (16:38 +0200)]
vi: convert more /**/ comments to //

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: code shrink
Denys Vlasenko [Mon, 1 Apr 2019 14:15:51 +0000 (16:15 +0200)]
vi: code shrink

function                                             old     new   delta
get_one_char                                         108     103      -5
edit_file                                            651     644      -7
do_cmd                                              4696    4688      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-20)             Total: -20 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: use vsnprintf to format status line
Denys Vlasenko [Mon, 1 Apr 2019 13:41:05 +0000 (15:41 +0200)]
vi: use vsnprintf to format status line

This is the last use of "vsprintf" in busybox:

function                                             old     new   delta
status_line_bold                                      72      77      +5
status_line                                           40      45      +5
vsprintf                                              23       -     -23
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 2/0 up/down: 10/-23)            Total: -13 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: rearrange functions, no logic changes
Denys Vlasenko [Mon, 1 Apr 2019 12:18:02 +0000 (14:18 +0200)]
vi: rearrange functions, no logic changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: rearrange functions, no logic changes
Denys Vlasenko [Mon, 1 Apr 2019 12:08:00 +0000 (14:08 +0200)]
vi: rearrange functions, no logic changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: rearrange functions, no logic changes
Denys Vlasenko [Mon, 1 Apr 2019 12:02:37 +0000 (14:02 +0200)]
vi: rearrange functions, no logic changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: rearrange functions, no logic changes
Denys Vlasenko [Mon, 1 Apr 2019 11:59:38 +0000 (13:59 +0200)]
vi: rearrange functions, no logic changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: rearrange functions, no logic changes
Denys Vlasenko [Mon, 1 Apr 2019 11:55:27 +0000 (13:55 +0200)]
vi: rearrange functions, no logic changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: fix ^Z not always working as intended
Denys Vlasenko [Mon, 1 Apr 2019 10:29:27 +0000 (12:29 +0200)]
vi: fix ^Z not always working as intended

function                                             old     new   delta
tstp_handler                                          64      71      +7
text_yank                                             54      56      +2
vi_main                                              280     272      -8
do_cmd                                              4705    4696      -9
colon                                               2861    2852      -9
cont_handler                                          66       -     -66
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/3 up/down: 9/-92)             Total: -83 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: install SIGINT handler _after_ restart setjmp is initialized
Denys Vlasenko [Mon, 1 Apr 2019 09:58:11 +0000 (11:58 +0200)]
vi: install SIGINT handler _after_ restart setjmp is initialized

While at it, sanitized comment style, deleted wrong ones, renamed signal
handlers to <sig>_handler(), slightly optimized "cursor home+clear screen".

function                                             old     new   delta
cont_handler                                           -      66     +66
tstp_handler                                           -      64     +64
winch_handler                                          -      60     +60
int_handler                                            -      32     +32
edit_file                                            648     651      +3
redraw                                                52      43      -9
catch_sig                                             32       -     -32
winch_sig                                             60       -     -60
suspend_sig                                           64       -     -64
cont_sig                                              66       -     -66
------------------------------------------------------------------------------
(add/remove: 4/4 grow/shrink: 1/1 up/down: 225/-231)           Total: -6 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoblockdev: code shrink
Denys Vlasenko [Sat, 30 Mar 2019 19:07:21 +0000 (20:07 +0100)]
blockdev: code shrink

function                                             old     new   delta
bdcmd_names                                            -      82     +82
bdcmd_ioctl                                            -      44     +44
bdcmd_flags                                            -      11     +11
blockdev_main                                        273     258     -15
bdcommands                                           176       -    -176
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 0/1 up/down: 137/-191)          Total: -54 bytes
   text    data     bss     dec     hex filename
 982326     485    7296  990107   f1b9b busybox_old
 982272     485    7296  990053   f1b65 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoip: Fix ip -o link
Stefan Sørensen [Sat, 30 Mar 2019 17:24:46 +0000 (18:24 +0100)]
ip: Fix ip -o link

Commit db169f253854db572c0c2b7e3d74ebbe6afdb97f breaks the "ip -o link"
command, no output is displayed.. Fix by only excluding the link info if
in oneline mode and if the address family is not AF_PACKET.

function                                             old     new   delta
ipaddr_list_or_flush                                1232    1202     -30

Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: allow manual screen update if SIGWINCH isn't supported
Ron Yorston [Wed, 20 Mar 2019 11:00:28 +0000 (11:00 +0000)]
vi: allow manual screen update if SIGWINCH isn't supported

On platforms that don't support SIGWINCH vi can be configured
with FEATURE_VI_USE_SIGNALS disabled and FEATURE_VI_WIN_RESIZE
enabled.  This allows the user to force an update with ^L when
the screen is resized.

However, because the SIGWINCH handler hasn't run the virtual
screen buffer won't have been updated and the display becomes
corrupted.  Fix this by calling new_screen() if necessary.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agoman: add "/usr/share/man" as another default MANPATH, fix col override
Denys Vlasenko [Sat, 30 Mar 2019 16:27:09 +0000 (17:27 +0100)]
man: add "/usr/share/man" as another default MANPATH, fix col override

function                                             old     new   delta
static.mpl                                             -      12     +12
packed_usage                                       33307   33316      +9
man_main                                             857     851      -6
add_MANPATH                                          148     138     -10
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/2 up/down: 21/-16)              Total: 5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agolibbb: mark scripted_main() as externally visible
Ron Yorston [Sat, 30 Mar 2019 07:47:12 +0000 (07:47 +0000)]
libbb: mark scripted_main() as externally visible

Building with individual binaries enabled fails when embedded
script applets are included:

   /tmp/ccIvMFZg.o: In function `main':
   applet.c:(.text.main+0x20): undefined reference to `scripted_main'

Mark scripted_main() as externally visible.

Reported-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
5 years agovi: code shrink, proper printf formatting for strlen()
Denys Vlasenko [Fri, 29 Mar 2019 13:40:01 +0000 (14:40 +0100)]
vi: code shrink, proper printf formatting for strlen()

function                                             old     new   delta
yank_delete                                           98      99      +1
what_reg                                              34      33      -1
text_yank                                             56      54      -2
end_cmd_q                                             17      14      -3
do_cmd                                              4718    4705     -13
colon                                               2875    2861     -14
edit_file                                            668     648     -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/6 up/down: 1/-53)             Total: -52 bytes

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