Commit Graph

16676 Commits

Author SHA1 Message Date
Denys Vlasenko
885121e25d libbb: change decode_base32/64 API to return the end of _dst_, not _src_.
function                                             old     new   delta
decode_base64                                        173     178      +5
read_base64                                          222     220      -2
decode_base32                                        186     182      -4
handle_incoming_and_exit                            2263    2239     -24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 5/-30)             Total: -25 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-28 13:27:36 +01:00
Denys Vlasenko
fc6faac84e libbb: trim base32/64 tables
function                                             old     new   delta
bb_uuenc_tbl_base64                                   66      65      -1
bb_uuenc_tbl_base32                                   34      32      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-28 12:48:34 +01:00
Denys Vlasenko
f140b49f5f base32/64: code shrink
function                                             old     new   delta
decode_base64                                        178     173      -5
decode_base32                                        217     186     -31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-36)             Total: -36 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-28 12:33:50 +01:00
Denys Vlasenko
7467e905e5 base32/64: code shrink
function                                             old     new   delta
decode_base64                                        180     178      -2
decode_base32                                        224     217      -7
read_base64                                          236     222     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-23)             Total: -23 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-28 09:50:14 +01:00
Denys Vlasenko
2cd37d65e2 libbb: faster and smaller decode_base32()
function                                             old     new   delta
decode_base32                                        275     224     -51

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-27 21:25:34 +01:00
Denys Vlasenko
170b8628fa libbb: smaller and faster decode_base64()
function                                             old     new   delta
decode_base64                                        195     180     -15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-27 20:45:15 +01:00
Denys Vlasenko
dc68a5ddac sha3sum: fix --help: -a does not depend on FEATURE_MD5_SHA1_SUM_CHECK
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-27 15:55:46 +01:00
Denys Vlasenko
cdab3c4fac base32/64: decode in-place
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-27 15:39:23 +01:00
Denys Vlasenko
c8b3d9a145 base32/64: implement -w COL
function                                             old     new   delta
baseNUM_main                                         568     655     +87
packed_usage                                       33478   33533     +55
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 142/0)             Total: 142 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-27 15:25:31 +01:00
Denys Vlasenko
fc63549352 free: code shrink
function                                             old     new   delta
free_main                                            664     657      -7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-27 12:40:31 +01:00
Denys Vlasenko
20900489a1 base32: new applet
function                                             old     new   delta
baseNUM_main                                           -     568    +568
decode_base32                                          -     275    +275
bb_uuenc_tbl_base32                                    -      34     +34
read_base64                                          218     236     +18
applet_names                                        2732    2739      +7
applet_main                                         1580    1584      +4
packed_usage                                       33480   33478      -2
base64_main                                          208       -    -208
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 3/1 up/down: 906/-210)          Total: 696 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-26 09:04:16 +01:00
Denys Vlasenko
03eb6eba43 mdev: clear LOGMODE_STDIO only directly before daemonizing
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 16:35:56 +01:00
Denys Vlasenko
cb143b9793 uevent: make it survive ENOBUFS
function                                             old     new   delta
uevent_main                                          285     337     +52

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 16:22:16 +01:00
Denys Vlasenko
1c9cd9b71b mdev: clean up
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 14:43:35 +01:00
Jan Klötzke
768153bf8c mdev: add -v to increase log verbosity
If logging to stderr and/or syslog the -v option can be given one or
more times to increase the log verbosity. If mdev is used as hotplug
helper the log level is fixed set to 2 if mdev.log is found an appended
because there is no possiblity to pass arguments to the hotplug helper.

Signed-off-by: Jan Klötzke <jan@kloetzke.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 14:33:58 +01:00
Jan Klötzke
e9003caf6d mdev: add syslog logging mode
If mdev is run as daemon it should be possible to forward the debug
messages to syslog. This feature might be useful if mdev is run with -s
during boot too. OTOH it makes no sense for the daemon to log to
mdev.log. This can be handled by a syslog daemon way better. If the
daemon stays in the foreground due to -f, the messages are still written
to stderr as before.

Signed-off-by: Jan Klötzke <jan@kloetzke.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 14:33:58 +01:00
Jan Klötzke
d560030548 mdev: re-initialize if uevent messages were lost
If the netlink read() failed with ENOBUFS we know that we have missed at
least one message due to a socket receive buffer overrun. The only way
how to recover is to drop the old socket, open a fresh one and make a
cold-plug scan of the current system state.

Signed-off-by: Jan Klötzke <jan@kloetzke.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 14:33:58 +01:00
Jan Klötzke
e3f4759019 mdev: move daemon setup to dedicated function
Signed-off-by: Jan Klötzke <jan@kloetzke.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 14:33:58 +01:00
Denys Vlasenko
a569fd37fe uevent: increase netlink buffer sizes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 13:34:07 +01:00
Jan Klötzke
3cd55d49a2 mdev: increase netlink buffer sizes
The socket receive buffer turned out to be too small for real world
systems. Use the same size as udevd to be on the safe side. As this is
just a limit and the memory is not allocated by the kernel until really
needed there is actually no memory wasted.

Signed-off-by: Jan Klötzke <jan@kloetzke.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 13:32:06 +01:00
Jan Klötzke
12aa68d10f libbb: set netlink socket revbuf size before binding
As soon as the socket is bound it will receive messages. Make sure the
recieve buffer size is increased before the first message is received.

Signed-off-by: Jan Klötzke <jan@kloetzke.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-22 13:12:51 +01:00
Audun-Marius Gangstø
9bf4499dd7 lineedit: fix unicode characters in prompt
function                                             old     new   delta
parse_and_put_prompt                                 779     823     +44

Signed-off-by: Audun-Marius Gangstø <audun@gangsto.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-21 17:34:42 +01:00
Denys Vlasenko
4323ac861e libiproute: reuse string constants
text	   data	    bss	    dec	    hex	filename
1020826	    559	   5052	1026437	  fa985	busybox_old
1020815	    559	   5052	1026426	  fa97a	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-21 17:23:13 +01:00
Denys Vlasenko
2c92d1ec58 volume_id: improve struct layout (smaller offesets, smaller insns on x86)
function                                             old     new   delta
volume_id_probe_xfs                                  101      98      -3
volume_id_probe_vfat                                 827     824      -3
volume_id_probe_udf                                  541     538      -3
volume_id_probe_ubifs                                 67      64      -3
volume_id_probe_squashfs                              86      83      -3
volume_id_probe_romfs                                 97      94      -3
volume_id_probe_reiserfs                             246     243      -3
volume_id_probe_ocfs2                                110     107      -3
volume_id_probe_ntfs                                 288     285      -3
volume_id_probe_nilfs                                100      97      -3
volume_id_probe_minix                                 85      82      -3
volume_id_probe_luks                                  92      89      -3
volume_id_probe_linux_swap                           251     248      -3
volume_id_probe_linux_raid                           131     128      -3
volume_id_probe_lfs                                   62      59      -3
volume_id_probe_jfs                                  110     107      -3
volume_id_probe_iso9660                              318     315      -3
volume_id_probe_f2fs                                 107     104      -3
volume_id_probe_exfat                                285     282      -3
volume_id_probe_erofs                                 89      86      -3
volume_id_probe_cramfs                                67      64      -3
volume_id_probe_btrfs                                134     131      -3
volume_id_probe_bcache                               107     104      -3
volume_id_probe_sysv                                 194     188      -6
volume_id_probe_hfs_hfsplus                          518     512      -6
add_to_uuid_cache                                    271     265      -6
volume_id_probe_ext                                  131     122      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/27 up/down: 0/-96)            Total: -96 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-19 13:58:25 +01:00
Cristian Ionescu-Idbohrn
ddfdf68ca1 fix warning: label 'out1' defined but not used
Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-19 13:14:59 +01:00
Norbert Lange
c20e42e320 util-linux: support erofs filesystem
Add erofs to the known volume_ids.

function                                             old     new   delta
volume_id_probe_erofs                                  -      89     +89
fs1                                                   24      28      +4
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 1/0 up/down: 93/0)               Total: 93 bytes

Signed-off-by: Norbert Lange <nolange79@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-18 19:19:23 +01:00
Joachim Nilsson
bd46f64dcb archival: avoid std namespace for local includes
Avoid using same include file naming pattern as available in GLIBC.
Renamed to match grp_.h et al.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-16 13:24:24 +01:00
Denys Vlasenko
4ac35a30db ash: make interactive ^C break out of PS2 mode
Based on patch by Joachim Nilsson <troglobit@gmail.com>

function                                             old     new   delta
pgetc                                                570     547     -23

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-16 13:09:37 +01:00
Denys Vlasenko
dc9c10a7b2 hush: make interactive ^C break out of PS2 mode
function                                             old     new   delta
syntax_error_unterm_str                                -      26     +26
parse_stream                                        2238    2251     +13
fgetc_interactive                                    243     249      +6
parse_dollar                                         824     817      -7
syntax_error_unterm_ch                                29      21      -8
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/2 up/down: 45/-15)             Total: 30 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-16 13:00:44 +01:00
Joachim Nilsson
efe99b59c6 syslogd: delay PID file creation until syslogd is ready
This patch moves the creation of the PID file until after syslogd has
set up signal handlers and is ready.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-16 12:12:04 +01:00
Joachim Nilsson
a4747230ab login: update UTMP before forking
/bin/login updates the preliminary UTMP record created by /bin/getty for
$LOGNAME.  However, if the PID of login is not the same as getty, then
it will create a new entry.  This causes GLIBC getlogin(3) to return the
string 'LOGIN' (set by getty) instead of $LOGNAME.  This affects tools
like /usr/bin/logname but also various 3rd party PAM applications.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-16 12:09:53 +01:00
Denys Vlasenko
5323af7f51 awk: fix dodgy multi-char separators splitting logic
function                                             old     new   delta
awk_split                                            521     484     -37

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-16 10:40:32 +01:00
Christian Eggers
89f063b900 chrt: support for musl C library
musl "implements" several sched_xxx() functions by returning ENOSYS. As
an alternative, either pthread_(g|s)etschedparam() or direct syscalls
can be used.

References: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/commit/schedutils/chrt.c?id=fcc3078754291d2f5121797eb91b364f8e24b2f1
References: http://git.musl-libc.org/cgit/musl/commit/src/sched/sched_setscheduler.c?id=1e21e78bf7a5c24c217446d8760be7b7188711c2
Signed-off-by: Christian Eggers <ceggers@arri.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-15 20:26:46 +01:00
Denys Vlasenko
64981b4c8e hush: document bugs in [[ =~ ]] comparison
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-01 18:47:24 +01:00
Denys Vlasenko
a7c065354f shell: update comments on the status of [[ ]] compat
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-31 04:32:34 +01:00
Denys Vlasenko
b259e97d47 hush: add tests for unquoted < > in [[ ]]
They pass.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-31 03:51:37 +01:00
Denys Vlasenko
d2241f5902 shell: better support of [[ ]] bashism
Still rather rudimentary for ash

function                                             old     new   delta
binop                                                433     589    +156
check_operator                                        65     101     +36
done_word                                            736     769     +33
test_main                                            405     418     +13
parse_stream                                        2227    2238     +11
ops_texts                                            124     133      +9
ops_table                                             80      86      +6
run_pipe                                            1557    1562      +5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/0 up/down: 269/0)             Total: 269 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-31 03:34:07 +01:00
Denys Vlasenko
112453acf2 od: unbreak it
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-25 23:44:22 +01:00
Denys Vlasenko
32e1f69ae0 compat: move hexdump -R functionality to xxd -r
function                                             old     new   delta
xxd_main                                             466     680    +214
packed_usage                                       33474   33483      +9
hexdump_opts                                          17      16      -1
hexdump_main                                         565     401    -164
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 223/-165)           Total: 58 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-25 16:06:45 +01:00
Denys Vlasenko
e16f7eb596 hush: output bash-compat killing signal names
This significantly syncronises ash-signals and hush-signals tests.

function                                             old     new   delta
process_wait_result                                  449     450      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-24 04:26:43 +02:00
Denys Vlasenko
b65d6cb00f hush: do not print killing signal name in cmd_whihc_dies_on_signal
function                                             old     new   delta
process_wait_result                                  438     449     +11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-24 03:33:32 +02:00
Denys Vlasenko
079487b487 hexdump: fix dup block comparison
function                                             old     new   delta
bb_dump_dump                                        1523    1520      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-20 19:29:32 +02:00
Denys Vlasenko
dac5b83142 xxd: fix printing of trailing spaces
function                                             old     new   delta
bb_dump_dump                                        1497    1523     +26
xxd_main                                             459     466      +7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 33/0)               Total: 33 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-20 18:57:02 +02:00
Denys Vlasenko
085f19cdff uudecode: fix possible signed char bug
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-07 17:02:46 +02:00
Denys Vlasenko
2496616b0a avoid using strok - eliminates use of hidden global variable
function                                             old     new   delta
udhcp_str2optset                                     616     650     +34
setpriv_main                                         950     975     +25
switch_root_main                                     688     706     +18
parse                                                958     970     +12
getopt_main                                          622     628      +6
parse_resolvconf                                     302     306      +4
mpstat_main                                         1139    1142      +3
static.p                                               4       -      -4
cdcmd                                                717     702     -15
strtok                                               148       -    -148
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 7/1 up/down: 102/-167)          Total: -65 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-06 02:36:47 +02:00
Xabier Oneca
535a509846 httpd: code shrink
Use decode_base64() from uuencode.c when uudecode/base64 applets are included.
That function is bigger than httpd's decodeBase64(), so we use the old one when
those applets are disabled. Bloat-o-meter when one of those is enabled:

function                                             old     new   delta
handle_incoming_and_exit                            2371    2265    -106

Signed-off-by: Xabier Oneca <xoneca@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-06 02:36:06 +02:00
Rui Salvaterra
eecd6f7a6c ip rule: add support for fwmark/fwmask for policy routing
This adds support for fwmark/fwmask in ip rule which is needed, for example, in
OpenWrt's mwan3. Masks are supported since Linux 2.6.19.

Fixes: https://bugs.busybox.net/show_bug.cgi?id=11621

Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-03 22:08:39 +02:00
Denys Vlasenko
16e82c61d4 tar: fix fallout of last_char_is(NULL) no longer being allowed
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-02 18:30:53 +02:00
Denys Vlasenko
a90a54aead udhcp: remove struct packing attribute, eliminates gcc-9.x
"error: taking address of packed member of 'struct ip_udp_dhcp_packet'
may result in an unaligned pointer value" here:

	udhcp_dump_packet(&packet.data);

and in other places.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-01 23:49:16 +02:00
Denys Vlasenko
689d0650ab libbb: shrink recursive_action() by reducing memory pressure
function                                             old     new   delta
recursive_action1                                      -     316    +316
file_action_grep                                     161     164      +3
add_to_prg_cache_if_socket                           202     205      +3
depmod_main                                          509     511      +2
writeFileToTarball                                   488     489      +1
parse_module                                         281     282      +1
fileAction                                           207     208      +1
act                                                  189     190      +1
add_to_dirlist                                        65      64      -1
writeTarFile                                         196     194      -2
uuidcache_init                                        47      45      -2
uuidcache_check_device                               109     107      -2
true_action                                            8       6      -2
run_parts_main                                       310     308      -2
netstat_main                                         534     532      -2
lsusb_main                                            29      27      -2
lspci_main                                            45      43      -2
initial_scan                                         138     136      -2
grep_main                                            845     843      -2
find_main                                            482     480      -2
config_file_action                                   437     435      -2
chmod_main                                           142     140      -2
dirAction                                             14      10      -4
diff_main                                           1544    1540      -4
chown_main                                           154     148      -6
skip_dir                                             136     129      -7
dir_act                                              191     184      -7
recursive_action                                     453      69    -384
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 7/20 up/down: 328/-439)        Total: -111 bytes

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