18445 Commits
Author SHA1 Message Date
Denys Vlasenko 6412da255d libbb: fix ioloop's limitation of fd < 1024
function                                             old     new   delta
grow_fdsets                                            -      90     +90
ioloop_run                                           438     485     +47
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 137/0)             Total: 137 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-17 18:23:08 +01:00
Denys Vlasenko 25a61f0feb shell: in math evaluation, use malloc, not alloca
function                                             old     new   delta
evaluate_string                                     1315    1322      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-17 14:44:30 +01:00
Denys Vlasenko d724d7d292 mkfs.vfat: fix creation of 2.5 kbyte FAT12 image
function                                             old     new   delta
mkfs_vfat_main                                      2463    2454      -9
.rodata                                           105036  105007     -29
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-38)             Total: -38 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-16 13:56:51 +01:00
Denys Vlasenko 8d79a6335c mkfs.vfat: fix write buffer allocation for tiny images
function                                             old     new   delta
mkfs_vfat_main                                      2460    2463      +3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-15 23:06:39 +01:00
Denys Vlasenko 3441a0e4bc mkfs.vfat: add ignored option -a ("disable alignment")
function                                             old     new   delta
.rodata                                           105038  105036      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-15 22:44:24 +01:00
Denys Vlasenko f8f567fb54 mkfs.vfat: implement creation of FAT12/16 filesystems
function                                             old     new   delta
mkfs_vfat_main                                      1858    2460    +602
.rodata                                           105028  105038     +10
packed_usage                                       36569   36575      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 618/0)             Total: 618 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-15 19:18:08 +01:00
Denys Vlasenko 7b38885adf mkfs.vfat: code shrink
function                                             old     new   delta
mkfs_vfat_main                                      1874    1858     -16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-14 20:04:56 +01:00
Denys Vlasenko 174ee36441 mkfs.vfat: code chrink, prepare for FAT16/12 support
function                                             old     new   delta
mkfs_vfat_main                                      1880    1874      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-14 16:14:12 +01:00
Denys Vlasenko cb53a88831 testsuite: modify 130GB mkfs.vfat test to actually have the very max cluster#
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-14 00:23:59 +01:00
Denys Vlasenko fb32719cb2 testsuite: add 130GB mkfs.vfat test
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-13 17:30:02 +01:00
Denys Vlasenko d3303c327e mkfs.vfat: add -s SECTORS_PER_CLUSTER
function                                             old     new   delta
mkfs_vfat_main                                      1800    1880     +80
.rodata                                           105000  105028     +28
packed_usage                                       36552   36549      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 108/-3)            Total: 105 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-13 16:55:59 +01:00
Denys Vlasenko 9f435d8347 mkfs.vfat: if -C, avoid unnecessary zero-filling of newly-created image file
This can save hundreds of megabytes for a QEMU-operated virtual FAT32 disk.

function                                             old     new   delta
mkfs_vfat_main                                      1766    1800     +34
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 34/0)               Total: 34 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-13 15:09:33 +01:00
Denys Vlasenko 484da7a2b3 mkfs.vfat: add support for -S SECTOR_SIZE
mkfs.vfat -v -F32 -S4096 -C IMAGE_16TB $((1024*1024*1024*16 - 0x10000))
tested to work.

function                                             old     new   delta
mkfs_vfat_main                                      1613    1686     +73
packed_usage                                       36498   36552     +54
.rodata                                           104988  105000     +12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 139/0)             Total: 139 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-13 14:49:44 +01:00
Denys Vlasenko d99c769ce3 mkfs.vfat: make -n "NO NAME " create the volume label as requested.
"NO NAME    " has special meaning _only_ in boot sector, not in rootdir's label.

function                                             old     new   delta
mkfs_vfat_main                                      1621    1613      -8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-13 13:53:13 +01:00
Denys Vlasenko c743bd3a9d libbb: if get_volume_size_in_bytes() detects too-small block device, warn about it
The "mkfs.vfar BLOCKDEV 1000000" case where BLOCKDEV is smaller.

function                                             old     new   delta
.rodata                                           104938  104988     +50
get_volume_size_in_bytes                             262     293     +31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 81/0)               Total: 81 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-13 13:44:25 +01:00
Denys Vlasenko 8eea53bb7a libbb: introduce and use xfstat_mode() and xfstat_size()
function                                             old     new   delta
xfstat_size                                            -      28     +28
add_remove_shell_main                                312     302     -10
mkfs_ext2_main                                      2299    2285     -14
mesg_main                                            157     136     -21
ar_main                                              565     527     -38
ubi_tools_main                                      1164    1125     -39
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/5 up/down: 28/-122)           Total: -94 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-12 16:40:57 +01:00
Denys Vlasenko 10c9c7faec mkfs.vfat: code shrink
function                                             old     new   delta
xfstat_mode                                            -      26     +26
mkfs_vfat_main                                      2106    1621    -485
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 26/-485)          Total: -459 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-12 16:05:41 +01:00
Denys Vlasenko e18ddc4ad3 mkfs.vfat: print how many sectors we ignore on large volumes
It's quite useful to know whether you lose 123 sectors, or 123 gigabytes.

function                                             old     new   delta
mkfs_vfat_main                                      2096    2106     +10
.rodata                                           104951  104938     -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 10/-13)             Total: -3 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-12 16:04:41 +01:00
Denys Vlasenko 67a351f7c0 mkfs.vfat: code shrink, tweak comments
function                                             old     new   delta
mkfs_vfat_main                                      2102    2096      -6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-12 12:33:16 +01:00
Denys Vlasenko 7de358fa8e mkfs.vfat: explain big filesystem sizes with 32 sectors/cluster, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-12 11:11:29 +01:00
Denys Vlasenko 3e4beef20c mkfs.vfat: support -b N -R N - allows creation of tiny 3KB FAT32 image
function                                             old     new   delta
mkfs_vfat_main                                      1586    2102    +516
.rodata                                           104913  104951     +38
packed_usage                                       36467   36498     +31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 585/0)             Total: 585 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-12 10:48:49 +01:00
Denys Vlasenko 4f986c0f9d mkfs.vfat: make it possible to create tiny 5KB images
function                                             old     new   delta
mkfs_vfat_main                                      1539    1586     +47
mkswap_main                                          253     256      +3
mkfs_minix_main                                     2575    2578      +3
mkfs_ext2_main                                      2297    2299      +2
.rodata                                           104946  104913     -33
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 55/-33)             Total: 22 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-10 18:19:26 +01:00
Denys Vlasenko d03387ebf3 mkfs.vfat: correctly handle huge images with total sectors above 2^32
function                                             old     new   delta
.rodata                                           104897  104946     +49
mkfs_vfat_main                                      1526    1539     +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 62/0)               Total: 62 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-10 16:21:24 +01:00
Denys Vlasenko 292ec317a3 mkfs.ext2: fix "can't open '(null)': Bad address"
function                                             old     new   delta
.rodata                                           104893  104897      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-10 14:32:38 +01:00
Denys Vlasenko f227dc2eb7 mkfs.vfat: implement -C
function                                             old     new   delta
packed_usage                                       36438   36467     +29
mkfs_vfat_main                                      1518    1526      +8
.rodata                                           104894  104893      -1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 37/-1)              Total: 36 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-10 14:29:07 +01:00
Denys Vlasenko a096845640 testsuite: add mkfs.vfat and blkid tests
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-10 11:46:15 +01:00
Denys Vlasenko 6a839afdee volume_id/fat: follow kernel example in deciding what is FAT32
This will allow detection of small FAT32 volumes which
are mountable by kernel - before this change we misdetected them,
and likely failed to fetch volume label.

While at it, avoid running off FAT if FAT is smaller than necessary
to cover entire data area, and rootdir has clusters beyond this
"shorter FAT". (This matches kernel behavior too)

function                                             old     new   delta
volume_id_probe_vfat                                 856     886     +30

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-10 03:25:03 +01:00
Denys Vlasenko bd8c4f7ce9 volume_id/fat: decrease maximum valid FAT table size to 0x02000000 sectors
It's still enormous (16GByte FAT tables). Real-world maximum
is 16 times smaller since cluster numbers are 28-bit.

function                                             old     new   delta
volume_id_probe_vfat                                 867     856     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-10 00:43:35 +01:00
Denys Vlasenko 8015168a75 Share "NO NAME " string
function                                             old     new   delta
bb_NO_NAME_11                                          -      12     +12
static.NO_NAME_11                                     12       -     -12
.rodata                                           104906  104894     -12
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/1 up/down: 12/-24)            Total: -12 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-09 23:43:17 +01:00
Denys Vlasenko d04e804bee volume_id/fat: in root dir scan, stop at first cluster# larger than FAT size
Otherwise, we can read non-FAT area and try to interpret it as FAT.

function                                             old     new   delta
volume_id_probe_vfat                                 851     867     +16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-09 12:50:07 +01:00
Denys Vlasenko 0c1060dee1 volume_id/fat: add validity checks for FAT12/16 (rootdir can't have 0 sectors)
function                                             old     new   delta
volume_id_probe_vfat                                 815     852     +37
mkfs_vfat_main                                      1523    1518      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 37/-5)              Total: 32 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-09 12:37:21 +01:00
Denys Vlasenko 484e887ce6 volume_id/fat: avoid rereading of 1st sector - use it when we have it initially
function                                             old     new   delta
volume_id_probe_vfat                                 856     815     -41

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-08 21:13:58 +01:00
Denys Vlasenko 0338bee40e volume_id/fat: allow FAT partitions with one FAT, tighten some validity checks
function                                             old     new   delta
volume_id_probe_vfat                                 829     856     +27

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-08 20:54:48 +01:00
Denys Vlasenko 7584233f64 volume_id/fat: remove test for non-zero head count in FAT superblock probe.
From util-linux:

    This change enables the auto-detection of the internal storage on a VTech
    Kidizoom camera, which has a zero head count value in the superblock.

    Microsoft documentation, "FAT: General Overview of On-Disk Format", states
    that the sectors and heads fields are only relevant for media that have
    a geometry.

    The Linux kernel also does not require a non-zero head count, and can
    manually mount the filesystem.

function                                             old     new   delta
volume_id_probe_vfat                                 841     829     -12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-08 19:20:57 +01:00
Denys Vlasenko b7c89c493a volume_id/fat: prevent possible division by zero and crash
function                                             old     new   delta
volume_id_probe_vfat                                 830     841     +11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-08 18:25:22 +01:00
Dominique Martinet d68f55fc29 tunctl: fix segfault on ioctl failure
libbb now takes "" instead of NULL as format string for nomsg functions,
but this caller had not been updated making busybox segfault on tunctl
commands when ioctl fails.
This can be reproduced by running `tunctl -t tun0` in gdb and blocking
with the tun open after being created, and running `tunctl -d tun0` in
another shell: the later will fail with EBUSY after fixing:
> tunctl: Device or resource busy

function                                             old     new   delta
tunctl_main                                          393     409     +16

Fixes: 4bd70463c7 ("libbb: pass "" rather than NULL as format string in _nomsg functions")
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-08 17:24:12 +01:00
Denys Vlasenko 17080dd399 shell/math: speed up handling of short arithmetic expansions
function                                             old     new   delta
evaluate_string                                     1291    1315     +24

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-08 16:31:12 +01:00
Denys Vlasenko d03670c64e mount: remove support for "swap" and "sw" mount options, they were added by mistake
Review of git log shows that they were mistakenly added during a rewrite
(confused with *FS type string* "swap" used in fstab to specify swap partitions).
util-linux's mount does not support this.
There is no reason to keep this incompatible extension.

function                                             old     new   delta
mount_main                                          1250    1249      -1
mount_options                                        188     180      -8
mount_option_str                                     385     377      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-17)             Total: -17 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-08 13:17:40 +01:00
Denys Vlasenko 604470bec4 mount: disallow -o OPTS, -T ALT_FSTAB, -a,r,w,n,f,i for non-root mount invocations
function                                             old     new   delta
mount_main                                          1259    1250      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-9)               Total: -9 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-08 03:05:09 +01:00
Denys Vlasenko c64ffa2e2b nsloopup: tighten up length checks to avoid out-of-bounds reads
function                                             old     new   delta
parse_reply                                          979    1030     +51

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-07 20:30:35 +01:00
Denys Vlasenko 5450a8ed71 rpm: bail out if headers have abnormally large entry counts
function                                             old     new   delta
.rodata                                           104880  104906     +26
rpm_gettags                                          419     443     +24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 50/0)               Total: 50 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-07 20:02:28 +01:00
Denys Vlasenko f3ca54f688 tftp: add commented-out code with non-ISREG check
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-07 16:14:03 +01:00
Denys Vlasenko 56e9d36bb6 udhcpc[6]: check minimum packet size after reducing it to ip.tot_len
For DHCPv6, also require that all fields up until option array exist in the packet.
I did not find a definitive info that DHCPv6 requires at least one option
to be present, and the code appears to handle empty option array correctly.

function                                             old     new   delta
d6_recv_raw_packet                                   228     230      +2
d4_recv_raw_packet                                   500     501      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 3/0)                 Total: 3 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-07 14:05:35 +01:00
Denys Vlasenko b67f7b7d14 tftpd: make DIR argiment work for non-root too, strip leading /
function                                             old     new   delta
tftpd_main                                           573     589     +16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-06 20:33:51 +01:00
Denys Vlasenko 7022247743 tftp(d): code shrink by not having two copies of option value
function                                             old     new   delta
tftp_protocol                                       1985    1938     -47

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-06 19:01:51 +01:00
Denys Vlasenko 1d363c609f tftpd: code shrink
function                                             old     new   delta
tftp_get_option                                      102      93      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-06 18:09:10 +01:00
Denys Vlasenko 11edcd9eb0 tftpd: comment tweak
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-06 16:56:02 +01:00
Denys Vlasenko 1a80c25d30 tftpd: increase minimum supported block size to approx. 64
function                                             old     new   delta
tftp_protocol                                       2001    1985     -16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-06 16:43:33 +01:00
Denys Vlasenko 8650079721 tftpd: improve sanitization of remote strings in error messages
function                                             old     new   delta
tftp_blksize_check                                    57      64      +7
tftp_protocol                                       2009    2001      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-8)               Total: -1 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-06 16:18:47 +01:00
Michael Pfeifroth 2d6925708e awk: fix mktime() for dates beyond 2038
do_mktime() returned the result of mktime() as int. Since int is
32 bits wide even on LP64 systems, any time at or after
2038-01-19 03:14:08 UTC was truncated, even with a 64-bit time_t:

  $ TZ=UTC busybox awk 'BEGIN { printf "%.0f\n", mktime("2038 01 19 03 14 08") }'
  -2147483648

Return time_t instead and add a testcase.

function                                             old     new   delta
exec_builtin                                        1130    1136      +6
do_mktime                                            119     121      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 8/0)                 Total: 8 bytes

Signed-off-by: Michael Pfeifroth <micpf@westermo.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-11-06 15:33:22 +01:00