Commit Graph

2264 Commits

Author SHA1 Message Date
Denys Vlasenko
27be0e8cfe shell: fix compile failures in some configs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-01-03 08:28:16 +01:00
Shawn Landden
58598eb709 ash: optional sleep builtin
function                                             old     new   delta
sleepcmd                                               -      10     +10
builtintab                                           352     360      +8
.rodata                                           105264  105271      +7
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 25/0)               Total: 25 bytes

Signed-off-by: Shawn Landden <shawnlandden@tutanota.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-08-27 19:56:21 +02:00
Ron Yorston
7d1c7d8337 ash,hush: use HOME for tab completion and prompts
ash and hush correctly use the value of HOME for tilde expansion.
However the line editing code in libbb obtains the user's home
directory by calling getpwuid().  Thus tildes in tab completion
and prompts may be interpreted differently than in tilde expansion.

When the line editing code is invoked from a shell make it use the
shell's interpretation of tilde.  This is similar to how GNU readline
and bash collaborate.

function                                             old     new   delta
get_homedir_or_NULL                                   29      72     +43
optschanged                                          119     126      +7
hush_main                                           1204    1211      +7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 57/0)               Total: 57 bytes

v2: Always check for HOME before trying the password database:  this
    is what GNU readline does.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-06-26 18:05:50 +02:00
Denys Vlasenko
ca466f385a *: slap on a few ALIGN* where appropriate
The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map"

function                                             old     new   delta
.rodata                                           108586  108460    -126
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-126)           Total: -126 bytes
   text	   data	    bss	    dec	    hex	filename
 970412	   4219	   1848	 976479	  ee65f	busybox_old
 970286	   4219	   1848	 976353	  ee5e1	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-02-06 19:53:10 +01:00
Khem Raj
117a8c9b7a apply const trick to ptr_to_globals
This was missing in the previous attempt to fix it via [1]

This helps fix segfaults when compiling with clang ( seen on riscv64 )

[  452.428349] less[270]: unhandled signal 11 code 0x1 at 0x000000000000000c in busybox.nosuid[2ab7491000+ba000]
[  452.430246] CPU: 3 PID: 270 Comm: less Not tainted 5.15.13-yocto-standard #1
[  452.431323] Hardware name: riscv-virtio,qemu (DT)
[  452.431925] epc : 0000002ab74a19ee ra : 0000002ab74a19dc sp : 0000003fec6ec980
[  452.432725]  gp : 0000002ab754dcb0 tp : 0000003f88783800 t0 : 0000003f8878d4a0
[  452.433744]  t1 : 0000002ab749b00c t2 : 0000000000000000 s0 : 0000003fec6ecc38
[  452.434732]  s1 : 000000000000004c a0 : 00000000ffffffff a1 : 0000002ab754dde0
[  452.435861]  a2 : 0000000000000000 a3 : 0000000000000100 a4 : 0000002ab754f3a0
[  452.436787]  a5 : 0000002ab754f3a0 a6 : 0000000000000000 a7 : 0000002ab754f2a0
[  452.437974]  s2 : 0000000000000002 s3 : 0000002ab754b6c8 s4 : 0000002ab749b60e
[  452.438781]  s5 : 0000000000000000 s6 : 0000002ab754b6c8 s7 : 0000003f88943060
[  452.439723]  s8 : 0000003f88944050 s9 : 0000002ad8502e88 s10: 0000002ad8502de8
[  452.440538]  s11: 0000000000000014 t3 : 0000003f887fceb6 t4 : 0000003f8893af0c
[  452.441438]  t5 : 0000000000000000 t6 : 0000003f88923000

[1] https://git.busybox.net/busybox/commit/?id=1f925038a

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-23 23:13:44 +01:00
Denys Vlasenko
1e825acf8d libbb: shrink lineedit_read_key()
function                                             old     new   delta
lineedit_read_key                                    237     231      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-18 00:36:42 +01:00
Denys Vlasenko
12566e7f9b ash,hush: fix handling of SIGINT while waiting for interactive input
function                                             old     new   delta
lineedit_read_key                                    160     237     +77
__pgetc                                              522     589     +67
fgetc_interactive                                    244     309     +65
safe_read_key                                          -      39     +39
read_key                                             588     607     +19
record_pending_signo                                  23      32      +9
signal_handler                                        75      81      +6
.rodata                                           104312  104309      -3
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 6/1 up/down: 282/-3)            Total: 279 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-17 11:46:23 +01:00
Denys Vlasenko
c2788f88f4 libbb: introduce and use chdir_or_warn()
function                                             old     new   delta
chdir_or_warn                                          -      37     +37
send_cgi_and_exit                                    720     711      -9
xchdir                                                27      15     -12
setup_environment                                    233     217     -16
fork_job                                             449     433     -16
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/4 up/down: 37/-53)            Total: -16 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-13 12:56:10 +01:00
Denys Vlasenko
931c55f9e2 libbb: invert the meaning of SETUP_ENV_NO_CHDIR -> SETUP_ENV_CHDIR
Double negatives are hard to grok.

function                                             old     new   delta
login_main                                           986     988      +2
su_main                                              474     470      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 2/-4)               Total: -2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-13 12:50:48 +01:00
Denys Vlasenko
d162a7b978 sulogin: increase util-linux compatibility
Change to root's HOME. Set some envvars. Steal ctty if necessary and possible.

function                                             old     new   delta
sulogin_main                                         240     340    +100
setup_environment                                    225     233      +8
su_main                                              479     474      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 108/-5)            Total: 103 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-12 23:19:11 +01:00
Denys Vlasenko
6062c0d19b libbb: change xstrndup, xmemdup to take size_t as size parameter
Also, remove entirely usually-disabled paranoia check (was also using
wrong config option to enable itself).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-05 23:03:54 +01:00
Denys Vlasenko
db5546ca10 libbb: code shrink: introduce and use [_]exit_SUCCESS()
function                                             old     new   delta
exit_SUCCESS                                           -       7      +7
_exit_SUCCESS                                          -       7      +7
run_pipe                                            1562    1567      +5
pseudo_exec_argv                                     399     400      +1
finish                                                86      87      +1
start_stop_daemon_main                              1109    1107      -2
shutdown_on_signal                                    38      36      -2
runsv_main                                          1662    1660      -2
redirect                                            1070    1068      -2
read_line                                             79      77      -2
pause_and_low_level_reboot                            54      52      -2
list_i2c_busses_and_exit                             483     481      -2
less_exit                                             12      10      -2
identify                                            4123    4121      -2
grep_file                                           1161    1159      -2
getty_main                                          1519    1517      -2
fsck_minix_main                                     2681    2679      -2
free_session                                         132     130      -2
fdisk_main                                          4739    4737      -2
clean_up_and_exit                                     53      51      -2
bsd_select                                          1566    1564      -2
bb_daemonize_or_rexec                                198     196      -2
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/17 up/down: 21/-34)           Total: -13 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-05 22:16:06 +01:00
Denys Vlasenko
31f45c1b36 libbb: factor out fflush_stdout_and_exit(EXIT_SUCCESS)
function                                             old     new   delta
fflush_stdout_and_exit_SUCCESS                         -       7      +7
xxd_main                                             890     888      -2
vlock_main                                           353     351      -2
uuencode_main                                        318     316      -2
uniq_main                                            427     425      -2
uname_main                                           250     248      -2
sort_main                                            853     851      -2
shuf_main                                            500     498      -2
route_main                                           238     236      -2
readlink_main                                        113     111      -2
nice_main                                            156     154      -2
last_main                                            957     955      -2
ipcs_main                                            960     958      -2
env_main                                             209     207      -2
chrt_main                                            464     462      -2
cal_main                                             921     919      -2
baseNUM_main                                         650     648      -2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/16 up/down: 7/-32)            Total: -25 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-04 23:31:58 +01:00
Bernhard Reutner-Fischer
bfefa6ab6c libarchive: remove duplicate forward declaration
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2021-11-28 10:53:22 +01:00
Denys Vlasenko
4bc9da1071 tls: P256: 64-bit optimizations
function                                             old     new   delta
sp_256_proj_point_dbl_8                              421     428      +7
sp_256_point_from_bin2x32                             78      84      +6
sp_256_cmp_8                                          38      42      +4
sp_256_to_bin_8                                       28      31      +3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 20/0)               Total: 20 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-11-27 11:28:11 +01:00
Denys Vlasenko
7c3e96d4b3 shell: use more compact SHELL_ASH / HUSH config defines. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-12 01:24:32 +02:00
Denys Vlasenko
5acf5e1f87 shell: fix script's comm field if ENABLE_FEATURE_PREFER_APPLETS=y
function                                             old     new   delta
re_execed_comm                                         -      46     +46
main                                                  72      86     +14
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 60/0)               Total: 60 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-11 18:44:00 +02:00
YU Jincheng
5156b24553 Make const ptr assign as function call in clang
- This can act as memory barrier in clang to avoid
  read before assign of a const ptr

Signed-off-by: LoveSy <shana@zju.edu.cn>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-09 22:30:45 +02:00
Ron Yorston
94eb1c4dc6 libbb: better coreutils compatibility for realpath
Add some tests which coreutils realpath pass but BusyBox realpath
fails (bar one).  Adjust xmalloc_realpath_coreutils() so the tests
pass:

- Expand symbolic links before testing whether the last path component
  exists.

- When the link target is a relative path canonicalize it by passing
  it through xmalloc_realpath_coreutils() as already happens for
  absolute paths.

- Ignore trailing slashes when finding the last path component and
  correctly handle the case where the only slash is at the start of
  the path.  This requires ignoring superfluous leading slashes.

- Undo all changes to the path so error messages from the caller show
  the original filename.

function                                             old     new   delta
xmalloc_realpath_coreutils                           214     313     +99

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-09 01:47:12 +02:00
Denys Vlasenko
049775b2ef libbb.h: fix logic selecting incorrect BB_STRTOOFF for !LFS configs
BB_STRTOOFF() was equal to bb_strtou(). On x86_64, it's incorrect.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-08 15:54:40 +02:00
YU Jincheng
1f925038ab *: generalize "const trick"
While at it, change all "__asm__" to "asm"

Co-authored-by: canyie <31466456+canyie@users.noreply.github.com>
Signed-off-by: YU Jincheng <shana@zju.edu.cn>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-07 15:22:35 +02:00
Denys Vlasenko
6279aec03d libbb: clarify what bb_mode_string() generates
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-17 17:10:38 +02:00
Denys Vlasenko
59ac467dc6 libbb: eliminate a static data array in bb_mode_string()
function                                             old     new   delta
print_stat                                           861     869      +8
header_verbose_list_ar                                73      77      +4
display_single                                       975     979      +4
header_verbose_list                                  237     239      +2
bb_mode_string                                       124     115      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 18/-9)               Total: 9 bytes
   text	   data	    bss	    dec	    hex	filename
1043136	    559	   5052	1048747	 1000ab	busybox_old
1043153	    559	   5020	1048732	 10009c	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-17 01:18:31 +02:00
Denys Vlasenko
4958c18134 libbb: code shrink bb_parse_mode
function                                             old     new   delta
bb_parse_mode                                        393     398      +5
static.who_mask                                       16       8      -8
static.perm_mask                                      24      12     -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 5/-20)             Total: -15 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-17 00:47:23 +02:00
Ron Yorston
9fe1548bbf date,touch: allow timezone offsets in dates
Allow ISO 8601 style dates to include a timezone offset.  Like
the '@' format these dates aren't relative to the user's current
timezone and shouldn't be subject to DST adjustment.

- The implementation uses the strptime() '%z' format specifier.
  This an extension which may not be available so the use of
  timezones is a configuration option.

- The 'touch' applet has been updated to respect whether DST
  adjustment is required, matching 'date'.

function                                             old     new   delta
parse_datestr                                        624     730    +106
static.fmt_str                                       106     136     +30
touch_main                                           388     392      +4
date_main                                            818     819      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 141/0)             Total: 141 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-17 00:11:30 +02:00
Sergey Ponomarev
82c5eb8e46 httpd,telnetd: make default port configurable
BusyBox on Termux can't use ports less than 1024 it's patched to change default port for httpd to 8080 and telnetd to 8023.

https://github.com/termux/termux-packages/blob/master/packages/busybox/0011-networking-telnetd-default-port.patch
https://github.com/termux/termux-packages/blob/master/packages/busybox/0010-networking-httpd-default-port.patch

To avoid such patches we can make port configurable.

function                                             old     new   delta
packed_usage                                       33920   33914      -6

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-09 21:42:48 +02:00
Denys Vlasenko
62d5a1e56f tar,smemcap: commonalyze checksumming code for tar header
function                                             old     new   delta
chksum_and_xwrite_tar_header                           -      99     +99
writeheader                                          280     199     -81
chksum_and_xwrite                                    102       -    -102
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/1 up/down: 99/-183)           Total: -84 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-20 17:58:49 +02:00
Denys Vlasenko
1746218bee move iterate_on_dir() from e2fsprogs to libbb
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-24 11:42:55 +02:00
Denys Vlasenko
56bbbfae7d cp: implement -n
function                                             old     new   delta
.rodata                                           103681  103722     +41
packed_usage                                       33698   33717     +19
copy_file                                           1678    1696     +18
cp_main                                              500     492      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 78/-8)              Total: 70 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-22 15:28:34 +02:00
Denys Vlasenko
0ec52d438a cp: implement -t DIR
function                                             old     new   delta
packed_usage                                       33713   33734     +21
.rodata                                           103670  103672      +2
cp_main                                              506     500      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 23/-6)              Total: 17 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-21 19:38:39 +02:00
Denys Vlasenko
83dff7f431 lsattr: support more ext2 flags
function                                             old     new   delta
e2attr_flags_lname                                   214     285     +71
e2attr_flags_value                                    52      80     +28
e2attr_flags_sname                                    14      21      +7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 106/0)             Total: 106 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-20 12:34:05 +02:00
Denys Vlasenko
526b834790 lsattr,chattr: support -p
function                                             old     new   delta
fgetsetprojid                                          -     107    +107
list_attributes                                      169     222     +53
change_attributes                                    277     326     +49
chattr_main                                          272     307     +35
close_silently                                         -      22     +22
.rodata                                           103378  103393     +15
packed_usage                                       33658   33666      +8
fgetsetversion                                        88      74     -14
fgetsetflags                                         162     148     -14
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 5/2 up/down: 289/-28)           Total: 261 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-20 11:02:49 +02:00
Denys Vlasenko
dc30f3dce2 free: implement -h
function                                             old     new   delta
.rodata                                           103331  103363     +32
packed_usage                                       33652   33654      +2
free_main                                            657     588     -69
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 34/-69)            Total: -35 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-18 12:08:02 +02:00
Denys Vlasenko
2c436679fb xxd: implement -i "C style output"
function                                             old     new   delta
xxd_main                                             710     888    +178
.rodata                                           103252  103331     +79
print_C_style                                          -      78     +78
packed_usage                                       33639   33652     +13
next                                                 276     278      +2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/0 up/down: 350/0)             Total: 350 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-18 00:59:17 +02:00
Denys Vlasenko
4d16161797 xxd: implement -o DISPLAYOFFSET
function                                             old     new   delta
xxd_main                                             680     710     +30
xstrtoll                                               -      30     +30
bb_dump_dump                                        1511    1531     +20
rewrite                                              941     951     +10
packed_usage                                       33629   33639     +10
.rodata                                           103250  103252      +2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/0 up/down: 102/0)             Total: 102 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-17 23:53:30 +02:00
Ron Yorston
a1b0d3856d ash: add process substitution in bash-compatibility mode
Process substitution is a Korn shell feature that's also available
in bash and some other shells.  This patch implements process
substitution in ash when ASH_BASH_COMPAT is enabled.

function                                             old     new   delta
argstr                                              1386    1522    +136
strtodest                                              -      52     +52
readtoken1                                          3346    3392     +46
.rodata                                           183206  183250     +44
unwindredir                                            -      28     +28
cmdloop                                              365     372      +7
static.spclchars                                      10      12      +2
cmdputs                                              380     367     -13
exitreset                                             86      69     -17
evalcommand                                         1754    1737     -17
varvalue                                             675     634     -41
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 5/4 up/down: 315/-88)           Total: 227 bytes
   text	   data	    bss	    dec	    hex	filename
 953967	   4219	   1904	 960090	  ea65a	busybox_old
 954192	   4219	   1904	 960315	  ea73b	busybox_unstripped

v2: Replace array of file descriptors with a linked list.
    Include tests that were unaccountably omitted from v1.
v3: Update linked list code to the intended version.
v4: Change order of conditional code in cmdputs().
v5: Use existing popredir() mechanism to manage file descriptors.
v6: Rebase to latest version of BusyBox ash.  Reduce code churn.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-05 23:37:19 +02:00
Denys Vlasenko
5dadd497ff runsv: robustify signal handling - SIGTERM to child between vfork and exec could mess things up
While at it, rename bb_signals_recursive_norestart() to bb_signals_norestart():
"recursive" was implying we are setting SA_NODEFER allowing signal handler
to be entered recursively, but we do not do that.

function                                             old     new   delta
bb_signals_norestart                                   -      70     +70
startservice                                         380     394     +14
bb_signals_recursive_norestart                        70       -     -70
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/0 up/down: 84/-70)             Total: 14 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-05 16:20:05 +02:00
Sören Tempel
3d9c649158 ls: don't output any colors with TERM=dumb
The TERM variable is usually set to "dumb" to indicate that the terminal
does not support any ANSI escape sequences. Presently, ls does not honor
this variable and outputs colors anyhow which results in unreadable
output, unless the user explicitly disables colors using `ls
--color=never`. The rational behind this change is that ls should "just
work" by default, even on dumb terminals.

For this reason, this patch adds a check which additionally consults the
TERM variable before printing any colors. This is analogous to the
existing check for ensuring that standard output is a tty. As such,
colors can still be forced with `--color=force`, even if TERM is set to
dumb.

function                                             old     new   delta
is_TERM_dumb                                           -      40     +40
ls_main                                              579     598     +19
.rodata                                           103246  103251      +5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 64/0)               Total: 64 bytes

Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-04 22:39:10 +02:00
Denys Vlasenko
d005c9f4c7 libbb.h: inline byteswaps
function                                             old     new   delta
recv_and_process_peer_pkt                           2173    2245     +72
machtime_dg                                           97     114     +17
machtime_stream                                       29      45     +16
fmt_time_bernstein_25                                132     139      +7
aesgcm_GHASH                                         183     184      +1
dumpleases_main                                      519     516      -3
__bswap_32                                             3       -      -3
udhcp_run_script                                     743     739      -4
tls_xread_record                                     634     630      -4
select_lease_time                                     56      52      -4
rdate_main                                           260     256      -4
get_prefix                                           327     323      -4
udhcp_listen_socket                                  185     180      -5
sha1_process_block64                                 361     356      -5
sendping6                                             81      76      -5
sendping4                                            107     102      -5
read32                                                27      22      -5
ll_proto_a2n                                         112     107      -5
bb_lookup_port                                       102      97      -5
udhcpc_main                                         2615    2609      -6
tftpd_main                                           579     573      -6
str2sockaddr                                         558     552      -6
GMULT                                                136     130      -6
sha1_end                                              73      66      -7
ntpd_main                                           1361    1354      -7
ntohl                                                  7       -      -7
inet_addr_match                                       93      86      -7
htonl                                                  7       -      -7
do_iplink                                           1259    1252      -7
do_add_or_delete                                    1138    1131      -7
create_and_bind_or_die                               117     110      -7
bind_for_passive_mode                                124     117      -7
xconnect_ftpdata                                      98      90      -8
rpm_getint                                           118     110      -8
read_leases                                          304     296      -8
read_config                                          216     208      -8
udhcp_send_kernel_packet                             336     327      -9
udhcp_recv_kernel_packet                             143     134      -9
sha256_process_block64                               451     442      -9
d6_send_kernel_packet_from_client_data_ifindex       275     266      -9
write_leases                                         215     205     -10
wget_main                                           2518    2508     -10
udhcpd_main                                         1528    1518     -10
tftp_protocol                                       2019    2009     -10
ftpd_main                                           2159    2149     -10
des_crypt                                           1318    1308     -10
send_ACK                                             138     127     -11
ipaddr_modify                                       1618    1607     -11
udhcp_str2optset                                     650     638     -12
init_d6_packet                                       115     103     -12
xwrite_encrypted                                     512     499     -13
tls_handshake                                       2060    2047     -13
pscan_main                                           607     594     -13
perform_d6_release                                   240     227     -13
ip_port_str                                          135     122     -13
handle_incoming_and_exit                            2230    2217     -13
INET_setroute                                        751     737     -14
traceroute_init                                     1153    1137     -16
nc_main                                             1055    1039     -16
udhcp_init_header                                     92      75     -17
volume_id_probe_hfs_hfsplus                          512     494     -18
send_offer                                           455     435     -20
do_lzo_decompress                                    507     487     -20
add_client_options                                   229     209     -20
ipcalc_main                                          554     533     -21
dhcprelay_main                                       966     943     -23
change_listen_mode                                   345     321     -24
send_packet                                          188     162     -26
static.xmalloc_optname_optval                        709     681     -28
rpm_gettags                                          447     419     -28
machtime                                              28       -     -28
catcher                                              299     270     -29
sfp_to_d                                              78      48     -30
reread_config_file                                   917     886     -31
lfp_to_d                                              84      51     -33
udhcp_recv_raw_packet                                594     559     -35
nbdclient_main                                      1182    1145     -37
d_to_lfp                                             137     100     -37
lzo_compress                                         567     529     -38
d6_recv_raw_packet                                   299     254     -45
d_to_sfp                                             133      85     -48
d6_send_raw_packet_from_client_data_ifindex          427     379     -48
common_ping_main                                    1935    1887     -48
udhcp_send_raw_packet                                467     416     -51
zcip_main                                           1219    1160     -59
udhcpc6_main                                        2636    2568     -68
do_lzo_compress                                      327     258     -69
send_arp_request                                     201     129     -72
common_traceroute_main                              1699    1621     -78
arpping                                              523     437     -86
arping_main                                         1597    1481    -116
print_tunnel                                         678     550    -128
dnsd_main                                           1304    1164    -140
parse_args                                          1370    1169    -201
------------------------------------------------------------------------------
(add/remove: 0/6 grow/shrink: 5/85 up/down: 113/-2246)      Total: -2133 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-24 11:54:50 +02:00
Denys Vlasenko
c0943ac451 platform.h: fix for Bionic >= 21 not having wait3()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-14 22:14:36 +02:00
Denys Vlasenko
fe2d8065e3 fix gcc-11.0 warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-14 17:52:18 +02:00
Denys Vlasenko
6bdfbc4cb5 libbb: fix '--help' handling in FEATURE_SH_NOFORK=y
Most BusyBox applets respond to the '--help' option by printing
a usage message.  This is normally handled by busybox_main() so
applet main routines don't have support for '--help'.

In standalone shell mode with FEATURE_SH_NOFORK enabled nofork
applets are invoked directly, bypassing busybox_main().  This
results in inconsistent handling of '--help':

- applets which call getopt() report "unrecognized option '--help'"
  and print help anyway;

- realpath says "--help: No such file or directory" and doesn't
  print help;

- usleep says "invalid number '--help'" and doesn't print help.

Avoid inconsistency by checking for '--help' in run_nofork_applet().

Bug found by Ron Yorston.

function                                             old     new   delta
show_usage_if_dash_dash_help                           -      70     +70
run_nofork_applet                                    347     362     +15
run_applet_no_and_exit                               432     365     -67
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 85/-67)             Total: 18 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-18 23:30:24 +01:00
Denys Vlasenko
33745b1fc8 ash: placate -Werror=format-security
"In function 'sprint_status48':
 error: format not a string literal and no format arguments"

function                                             old     new   delta
sprint_status48                                      160     158      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-18 13:45:49 +01:00
Ron Yorston
cad3fc743a libbb: introduce and use fputs_stdout
function                                             old     new   delta
fputs_stdout                                           -      12     +12
zxc_vm_process                                      7237    7230      -7
yes_main                                              85      78      -7
write_block                                          380     373      -7
wrapf                                                305     298      -7
strings_main                                         437     430      -7
show_bridge                                          353     346      -7
rev_main                                             384     377      -7
put_prompt_custom                                     58      51      -7
put_cur_glyph_and_inc_cursor                         168     161      -7
print_numbered_lines                                 152     145      -7
print_named_ascii                                    130     123      -7
print_name                                           135     128      -7
print_login_issue                                    386     379      -7
print_ascii                                          208     201      -7
powertop_main                                       1249    1242      -7
od_main                                             1789    1782      -7
logread_main                                         518     511      -7
head_main                                            804     797      -7
display_process_list                                1319    1312      -7
cut_main                                            1002     995      -7
bb_dump_dump                                        1550    1543      -7
bb_ask_noecho                                        393     386      -7
baseNUM_main                                         702     695      -7
expand_main                                          755     745     -10
dumpleases_main                                      497     487     -10
write1                                                12       -     -12
putcsi                                                37      23     -14
print_login_prompt                                    55      41     -14
paste_main                                           525     511     -14
cat_main                                             440     426     -14
print_it                                             245     230     -15
print_addrinfo                                      1188    1171     -17
print_rule                                           770     750     -20
print_linkinfo                                       842     822     -20
httpd_main                                           791     771     -20
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/34 up/down: 12/-341)         Total: -329 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-03 20:52:40 +01:00
Alex Samorukov
4a4b453a87 Fix for the FEATURE_UTMP on the FreeBSD
FreeBSD is not using <utmp.h> and does not define _PATH_UTMPX.
Tested with busybox applets depending on FEATURE_UTMP (e.g. who, users, etc)

Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-01-04 21:59:40 +01:00
Alex Samorukov
d4624d3468 Fix bb_setpgrp weapper on the FreeBSD
FreeBSD uses setpgrp(pid_t, pid_t)
This patch makes crond.c and probably others compilable

Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-01-04 13:28:28 +01:00
Denys Vlasenko
3c13da3dab libbb: introduce and use xgettimeofday(), do not truncate 64-bit time_t in shells
function                                             old     new   delta
xgettimeofday                                          -      11     +11
get_local_var_value                                  280     281      +1
svlogd_main                                         1323    1322      -1
change_epoch                                          67      66      -1
timestamp_and_log                                    461     458      -3
hwclock_main                                         301     298      -3
fmt_time_bernstein_25                                135     132      -3
step_time                                            331     326      -5
script_main                                         1207    1202      -5
machtime                                              34      28      -6
curtime                                               61      54      -7
ts_main                                              423     415      -8
nmeter_main                                          761     751     -10
gettime1900d                                          67      46     -21
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/12 up/down: 12/-73)           Total: -61 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-30 23:48:01 +01:00
Denys Vlasenko
00eb23b47a bc: do not allocate line editing state until needed
function                                             old     new   delta
xc_read_line                                         324     353     +29
free_line_input_t                                     34      39      +5
xc_vm_init                                           656     640     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 34/-16)             Total: 18 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-21 21:36:58 +01:00
Denys Vlasenko
251e08ffa6 move ADJTIME_PATH define to header files
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-17 20:53:43 +01:00
Denys Vlasenko
eb0c2e218c libbb: introduce and use xsettimeofday()
function                                             old     new   delta
xsettimeofday                                          -      25     +25
rdate_main                                           274     260     -14
step_time                                            348     331     -17
set_kernel_timezone_and_clock                        119     102     -17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 25/-48)            Total: -23 bytes
   text	   data	    bss	    dec	    hex	filename
1020753	    559	   5052	1026364	  fa93c	busybox_old
1020708	    559	   5052	1026319	  fa90f	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-16 21:36:36 +01:00