Denys Vlasenko
fddd93edbd
libbb: introduce and use xasprintf_inplace()
...
function old new delta
xasprintf_and_free - 49 +49
watch_main 269 282 +13
singlemount 1313 1315 +2
append_mount_options 157 149 -8
ip_port_str 122 112 -10
lsblk_main 869 858 -11
add_cmd 1178 1167 -11
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/4 up/down: 64/-40) Total: 24 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-05 13:36:27 +01:00
Denys Vlasenko
e33bd4aaa2
libbb: use narrow isqrt() when 64-bit one is not needed (only "factor" uses it)
...
function old new delta
isqrt_ull - 84 +84
create_J 1809 1808 -1
isqrt 106 38 -68
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 84/-69) Total: 15 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-04 19:47:11 +01:00
Denys Vlasenko
36eed984b8
fdisk: several fixes for 4K sector size
...
function old new delta
bb_getsize_in_512sect - 187 +187
list_disk_name_and_sizes - 80 +80
get_geometry 511 535 +24
.rodata 107066 107088 +22
msg_building_new_label 143 142 -1
fdisk_main 4781 4775 -6
list_table 1423 1366 -57
list_disk_geometry 143 68 -75
bb_BLKGETSIZE_sectors 191 - -191
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 2/4 up/down: 313/-330) Total: -17 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-04 09:46:54 +01:00
Denys Vlasenko
3e80101963
uuidgen: move UUID formatting to libbb
...
function old new delta
format_uuid_DCE_37_chars - 94 +94
uuidgen_main 71 53 -18
.rodata 107089 107066 -23
mkswap_main 278 253 -25
volume_id_set_uuid 258 178 -80
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/4 up/down: 94/-146) Total: -52 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-03 09:10:25 +01:00
Osama Abdelkader via busybox
405afbd551
util-linux: add minimal uuidgen implementation
...
Add a simple uuidgen utility that generates RFC 4122 compliant
UUIDs (version 4, random). Uses the existing generate_uuid()
function from libbb and volume_id_set_uuid() for formatting.
Implementation suggested by Ulli.
Features:
- Generates standard format UUIDs: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- RFC 4122 version 4 compliant
- Minimal implementation (~1.1 kb)
- NOFORK applet for efficiency
- Uses existing volume_id infrastructure for UUID formatting
function old new delta
uuidgen_main - 71 +71
applet_names 2862 2870 +8
.rodata 107010 107016 +6
applet_main 1648 1652 +4
applet_suid 103 104 +1
applet_install_loc 206 207 +1
applet_flags 103 104 +1
packed_usage 35952 35941 -11
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 6/1 up/down: 92/-11) Total: 81 bytes
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-01 11:41:08 +01:00
Wouter Franken
4e82d99460
libbb/loop: fix existence check for LOOP_CONFIGURE ioctl
...
The LOOP_CONFIGURE ioctl is supported in 5.8 kernels and up. To have
backwards compatibility there is a config option CONFIG_TRY_LOOP_CONFIGURE
that will check if the ioctl exists and if not fall back to old way of
configuring loop devices.
Normally errno will be set to EINVAL when this ioctl does not exist.
However, when kernel config CONFIG_COMPAT is enabled, then compat_ioctl
is called. In that case -ENOIOCTLCMD is returned by loop device driver
and generic ioctl wrapper will set errno to ENOTTY. Because busybox
does not expect this it will fail to mount loop devices in this case.
This patch fixes the check for the existence of the ioctl LOOP_CONFIGURE
by checking if errno is one of both: EINVAL or ENOTTY.
function old new delta
set_loop 809 821 +12
Signed-off-by: Wouter Franken <wouter.franken_ext@softathome.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-26 05:43:17 +01:00
Denys Vlasenko
8cafd7a908
lineedit: fix PS1='\W' for root directory
...
'\W' in PS1 returned an empty string for the root directory. bash
displays '/' in similar circumstances.
Avoid returning an empty string for the directory.
function old new delta
parse_and_put_prompt 873 883 +10
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-11-08 07:42:34 +01:00
Denys Vlasenko
b99a529177
busybox: optional --version support
...
function old new delta
busybox_main 695 734 +39
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-10-13 21:56:47 +02:00
Denys Vlasenko
3621595939
nsenter,unshare: don't use xvfork_parent_waits_and_exits(), it SEGVs on ppc64le
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-10-08 14:49:26 +02:00
Denys Vlasenko
e660eab458
*: code shrink using sigprocmask2() where appropriate
...
function old new delta
sig_unblock 41 43 +2
sig_block 41 40 -1
sigprocmask_allsigs 33 31 -2
wait_for_child_or_signal 202 193 -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 2/-12) Total: -10 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-11 01:17:02 +02:00
Denys Vlasenko
df154028dc
ash: eval: Add vfork support
...
Upstream commit:
Date: Sat, 19 May 2018 02:39:56 +0800
eval: Add vfork support
This patch adds basic vfork support for the case of a simple command.
Upstream commit:
Date: Tue, 12 Jan 2021 17:11:19 +1100
jobs: Always reset SIGINT/SIGQUIT handlers
On Fri, Jan 08, 2021 at 08:55:41PM +0000, Harald van Dijk wrote:
> On 18/05/2018 19:39, Herbert Xu wrote:
> > This patch adds basic vfork support for the case of a simple command.
> > ... @@ -879,17 +892,30 @@ forkchild(struct job *jp, union node *n, int
> > mode)
> > }
> > }
> > if (!oldlvl && iflag) {
> > - setsignal(SIGINT);
> > - setsignal(SIGQUIT);
> > + if (mode != FORK_BG) {
> > + setsignal(SIGINT);
> > + setsignal(SIGQUIT);
> > + }
> > setsignal(SIGTERM);
> > }
> > +
> > + if (lvforked)
> > + return;
> > +
> > for (jp = curjob; jp; jp = jp->prev_job)
> > freejob(jp);
> > }
>
> This leaves SIGQUIT ignored in background jobs in interactive shells.
>
> ENV= dash -ic 'dash -c "kill -QUIT \$\$; echo huh" & wait'
>
> As of dash 0.5.11, this prints "huh". Before, the subprocess process killed
> itself before it could print anything. Other shells do not leave SIGQUIT
> ignored.
>
> (In a few other shells, this also prints "huh", but in those other shells,
> that is because the inner shell chooses to ignore SIGQUIT, not because the
> outer shell leaves it ignored.)
Thanks for catching this. I have no idea how that got in there
and it makes no sense whatsoever. This patch removes the if
conditional.
Fixes: e94a964e7dd0 ("eval: Add vfork support")
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-09 17:36:18 +02:00
Denys Vlasenko
0b05a4e71e
top,pmap: speed up /smaps parsing
...
function old new delta
procps_read_smaps 515 529 +14
procps_get_maps 685 665 -20
.rodata 105847 105820 -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 14/-47) Total: -33 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-06 14:42:06 +02:00
Denys Vlasenko
47d27cdaff
libbb: fix too-narrow variable in procps_read_smaps() causing incorrect sizes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-06 14:04:49 +02:00
Denys Vlasenko
40c2d01da2
libbb: make read_cmdline() replace chars 1..31 with '?', not space
...
Space was too inconspicuous on output
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-06 14:02:05 +02:00
Denys Vlasenko
8bde71eb15
top: simplify command line reading
...
function old new delta
cmdline_to_line_buf_and_print - 48 +48
read_cmdline 326 327 +1
display_topmem_process_list 523 505 -18
display_process_list 1186 1161 -25
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/2 up/down: 49/-43) Total: 6 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-06 00:42:05 +02:00
Denys Vlasenko
d16bde623c
top,pmap: do not use common code for reading /proc/PID/smaps
...
The logic is in fact quite far from common.
While at it, stop accounting "---p" mappings as mapped (e.g. VSZ in top).
Nothing is mapped there (why would kernel waste RAM to map pages
which can't be accessed?).
function old new delta
read_smaps - 562 +562
read_cmdline 315 326 +11
print_smaprec 97 101 +4
procps_scan 1219 1211 -8
.rodata 115541 115533 -8
skip_whitespace_if_prefixed_with 25 - -25
procps_read_smaps 864 577 -287
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 2/3 up/down: 577/-328) Total: 249 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05 14:21:51 +02:00
Denys Vlasenko
c229982b33
top: fix display of very large VSZ
...
function old new delta
display_process_list 1366 1403 +37
handle_input 628 636 +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 45/0) Total: 45 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05 02:57:05 +02:00
Denys Vlasenko
5f3a986c9e
libbb: simplify concat_path_file()
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-04 22:27:40 +02:00
Denys Vlasenko
a33ce612b5
libbb: much faster concat_path_file()
...
function old new delta
concat_path_file 68 127 +59
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-04 19:21:45 +02:00
Denys Vlasenko
7d782e8813
shell: fix the check of empty HISTFILE
...
The check for "" history file is done on a wrong state pointer.
Fixes: shell: empty HISTFILE disables history saving, just as unset one did
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-03 00:11:11 +02:00
Denys Vlasenko
91d8b4eb5c
ftpd: code shrink, move replace_char() to libbb
...
function old new delta
modprobe_main 803 804 +1
escape_text 127 122 -5
replace 18 - -18
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 1/-23) Total: -22 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-02 07:18:56 +02:00
Denys Vlasenko
0fea54a983
libbb/dump: much faster formatting of %_u on x86
...
function old new delta
display 1485 1481 -4
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-01 03:01:38 +02:00
Denys Vlasenko
e95086b2fa
libbb/yescrypt: code shrink
...
function old new delta
static.PBKDF2_SHA256 219 165 -54
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-01 02:21:38 +02:00
Denys Vlasenko
4f3a56dc12
ls: fix -Q to match GNU
...
function old new delta
print_name 137 229 +92
display_files 375 402 +27
c_escape_conv_str00 - 24 +24
display 1476 1485 +9
conv_str 33 - -33
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 3/0 up/down: 152/-33) Total: 119 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-01 01:02:43 +02:00
Denys Vlasenko
551bfdb97f
ls: implement -q, fix -w0, reduce startup time
...
function old new delta
ls_main 598 660 +62
ls_longopts - 47 +47
G_isatty - 36 +36
print_name 102 134 +32
display_files 358 374 +16
.rodata 105829 105833 +4
vgetopt32 1330 1317 -13
static.ls_longopts 47 - -47
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 4/1 up/down: 197/-60) Total: 137 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-31 18:35:11 +02:00
Andy Knowles
dcbb69e0a5
sha384sum: new applet
...
function old new delta
sha512384_end - 198 +198
packed_usage 35021 35134 +113
init384 - 80 +80
sha384_begin - 19 +19
sha384_end - 10 +10
applet_names 2823 2833 +10
md5_sha1_sum_main 501 507 +6
sha3_end 54 59 +5
applet_main 1628 1632 +4
show_usage_if_dash_dash_help 79 72 -7
hash_file 358 344 -14
sha512_end 197 10 -187
------------------------------------------------------------------------------
(add/remove: 4/0 grow/shrink: 5/3 up/down: 445/-208) Total: 237 bytes
Signed-off-by: Andy Knowles <aknowles@galleonec.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-30 18:39:46 +02:00
Denys Vlasenko
e022ff88d1
libbb: SHA-NI - document that unpckhpd also works, no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-22 16:43:22 +02:00
Denys Vlasenko
ed22c5bd4a
libbb: SHA-NI code shrink
...
function old new delta
sha256_process_block64_shaNI 673 657 -16
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-22 00:12:54 +02:00
Denys Vlasenko
d23ad55904
libbb: change define names in SHA-NI code to match kernel source more closely
...
No code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-21 08:45:02 +02:00
Denys Vlasenko
77a49a61b2
libbb/yescrypt: de-unroll salsa20()
...
function old new delta
salsa20 760 296 -464
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-20 08:42:51 +02:00
Denys Vlasenko
c6b9e76373
libbb: crypt_make_pw_salt(): fix yescrypt's random salt last char
...
function old new delta
crypt_make_pw_salt 128 146 +18
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-19 18:42:32 +02:00
Denys Vlasenko
6979467a62
cryptpw: fix detection of crypt algo from salt (was broken if default isn't DES)
...
The symptom is: "cryptpw ... implicit" testsuite tests were failing
if CONFIG_FEATURE_DEFAULT_PASSWD_ALGO is not "des".
function old new delta
cryptpw_main 223 283 +60
pw_encrypt 974 975 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 61/0) Total: 61 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-19 18:20:01 +02:00
Denys Vlasenko
51b45ce28a
libbb/yescrypt: code shrink
...
function old new delta
blockmix_xor_save 1169 708 -461
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-19 17:20:35 +02:00
Denys Vlasenko
b823735b7e
libbb/yescrypt: actually, largest allowed salt is 86 chars, support that
...
function old new delta
yescrypt_r 767 756 -11
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-17 17:01:40 +02:00
Denys Vlasenko
abe0b45cd7
libbb/yescrypt: code shrink
...
function old new delta
blockmix_xor 1177 702 -475
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-15 05:47:18 +02:00
Denys Vlasenko
e62bfbcaed
libbb/yescrypt: code shrink
...
function old new delta
salsa20 684 650 -34
blockmix_salsa8 198 144 -54
blockmix 762 565 -197
blockmix_xor 1322 1028 -294
blockmix_xor_save 1499 1103 -396
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-975) Total: -975 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-11 08:58:07 +02:00
Denys Vlasenko
95f169f3bb
libbb/yescrypt: code shrink
...
function old new delta
static.yescrypt_kdf32_body 847 823 -24
yescrypt_r 805 767 -38
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-62) Total: -62 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-09 10:38:11 +02:00
Denys Vlasenko
11d4c08d75
libbb/bitops.c: add inlining comment
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-09 08:21:47 +02:00
Denys Vlasenko
c305c81c94
libbb: introduce and use block-XOR functions
...
On x86_64, they can be done in 16-byte blocks
64-bit:
function old new delta
xorbuf_3 - 84 +84
xorbuf64_3_aligned64 - 58 +58
smix1 687 712 +25
xwrite_encrypted 520 534 +14
xorbuf16_aligned_long - 13 +13
tls_xread_record 733 742 +9
xorbuf 21 13 -8
xorbuf_aligned_AES_BLOCK_SIZE 15 - -15
blockmix 814 762 -52
blockmix_salsa8 317 198 -119
blockmix_xor_save 1620 1499 -121
blockmix_xor 1543 1322 -221
------------------------------------------------------------------------------
(add/remove: 4/1 grow/shrink: 3/5 up/down: 203/-536) Total: -333 bytes
32-bit:
function old new delta
xorbuf_3 - 76 +76
xorbuf64_3_aligned64 - 36 +36
xorbuf16_aligned_long - 23 +23
xwrite_encrypted 499 507 +8
tls_xread_record 646 650 +4
xorbuf 22 11 -11
xorbuf_aligned_AES_BLOCK_SIZE 23 - -23
blockmix 1083 938 -145
blockmix_salsa8 415 210 -205
blockmix_salsa8_xor 601 163 -438
blockmix_xor 2103 1533 -570
blockmix_xor_save 2614 1859 -755
------------------------------------------------------------------------------
(add/remove: 4/1 grow/shrink: 2/6 up/down: 147/-2147) Total: -2000 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-09 07:00:59 +02:00
Denys Vlasenko
7b313c3465
libbb: code shrink in sha_crypt()
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-08 10:04:47 +02:00
Denys Vlasenko
0930708794
libbb/yescrypt: disable NROM code
...
function old new delta
smix1 - 595 +595
smix2 - 414 +414
static.yescrypt_kdf32_body 899 847 -52
static.smix2 420 - -420
static.smix1 604 - -604
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 0/1 up/down: 1009/-1076) Total: -67 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-08 06:52:27 +02:00
Denys Vlasenko
d0f0874d57
libbb/yescrypt: disable code which accepts unusual yescrypt parameters
...
Almost any reasonable yescrypt hashes in /etc/shadow should only ever use
"jXY" parameters which set N and r. Fancy multi-byte-encoded
wide integers are not needed for that.
function old new delta
static.yescrypt_kdf32_body - 899 +899
static.PBKDF2_SHA256 213 219 +6
decode64_uint32 141 - -141
yescrypt_r 990 805 -185
yescrypt_kdf32_body 1423 - -1423
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 1/1 up/down: 905/-1749) Total: -844 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-08 05:34:41 +02:00
Denys Vlasenko
78bd8a44b7
libbb/yescrypt: explain and shrink decode64_uint32()
...
function old new delta
decode64_uint32 177 141 -36
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-08 03:47:48 +02:00
Denys Vlasenko
d18ac080e4
libbb/yescrypt: code shrink
...
Setting EINVAL in errno is not necessary, just error return works.
function old new delta
yescrypt_kdf32_body 1434 1423 -11
yescrypt_r 1029 990 -39
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-50) Total: -50 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-08 00:16:56 +02:00
Denys Vlasenko
8466c3e78f
libbb/yescrypt: madvise(MADV_HUGEPAGE) our usually very large allocation
...
Nearly ~2 faster run when buffer is gigabytes in size
function old new delta
yescrypt_kdf32_body 1386 1406 +20
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-07 23:07:58 +02:00
Denys Vlasenko
f8e9bd30d7
libbb/yescrypt: disable unrolling in two places
...
Also, make many define macros safer
function old new delta
blockmix 2300 814 -1486
blockmix_xor 4606 1543 -3063
blockmix_xor_save 4737 1620 -3117
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-7666) Total: -7666 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-07 22:34:31 +02:00
Denys Vlasenko
e5d3a87633
libbb/yescrypt: 64-bit build fixes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-07 21:52:39 +02:00
Denys Vlasenko
7798f651a4
add libbb/yescrypt/PARAMETERS
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-07 21:36:31 +02:00
Denys Vlasenko
67b98c7b1b
libbb/yescrypt: no need to find salt-terminating "$" twice
...
function old new delta
yescrypt_r 1048 1029 -19
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-07 18:28:56 +02:00
Denys Vlasenko
e3484095f9
libbb/yescrypt: code shrink
...
function old new delta
yescrypt_r 1063 1048 -15
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-07 18:03:10 +02:00