Commit graph

18182 commits

Author SHA1 Message Date
Denys Vlasenko
391fdea73b *: whitespace cleanup
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-08 08:31:13 +01:00
Denys Vlasenko
8289b34626 tls: document PSTM_64BIT + PSTM_X86_64 optimizations better
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-08 08:30:03 +01:00
Denys Vlasenko
91075de0a7 vi: code shrink
function                                             old     new   delta
.rodata                                           107007  107019     +12
run_cmds                                              62      50     -12
indicate_error                                        78      55     -23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 12/-35)            Total: -23 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-07 12:53:27 +01:00
Denys Vlasenko
1380df7a5a vi: fix last commit - do terminate the :CMD on the first whitespace
function                                             old     new   delta
colon                                               3942    3952     +10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-07 03:20:26 +01:00
Denys Vlasenko
9693daaaef *: use is_prefixed_with() where appropriate
function                                             old     new   delta
resume_main                                          560     556      -4
uuidcache_check_device                               107     101      -6
ntp_init                                            1005     997      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-18)             Total: -18 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-07 01:10:55 +01:00
Denys Vlasenko
79d35b5a0e vi: fix ":list" command
function                                             old     new   delta
.rodata                                           107010  107007      -3
show_status_line                                     372     362     -10
colon                                               3989    3942     -47
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-60)             Total: -60 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-07 00:52:49 +01:00
Denys Vlasenko
5de7222395 vi: code shrink
function                                             old     new   delta
colon                                               4005    3989     -16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-06 23:22:49 +01:00
Denys Vlasenko
3620c4ee67 vi: fix "s /find/repl" with whitespace before /
function                                             old     new   delta
colon                                               3977    4005     +28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-06 22:56:16 +01:00
Denys Vlasenko
80ce9e3998 vi: code shrink, optimize: do not call count_lines() unless needed
function                                             old     new   delta
colon                                               4010    3980     -30

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-06 20:50:47 +01:00
Denys Vlasenko
c8cbd3516d *: use xasprintf_inplace() and concat_path_file() where appropriate
function                                             old     new   delta
acpid_main                                          1059    1063      +4
resume_main                                          561     560      -1
unpack_package                                       642     640      -2
adduser_main                                         861     859      -2
getty_main                                          1517    1512      -5
ftpd_main                                           2149    2142      -7
.rodata                                           107018  107010      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/6 up/down: 4/-25)             Total: -21 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-06 13:16:36 +01:00
Denys Vlasenko
9b2a50efe2 *: use xasprintf_inplace() in more places
function                                             old     new   delta
.rodata                                           107009  107018      +9
parse_stream                                        3075    3069      -6
buffer_print                                         612     603      -9
expand_args                                          159     144     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 9/-30)             Total: -21 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-06 11:19:11 +01:00
Denys Vlasenko
89f37ebe8c man: fix following links if run inside manpage dir
function                                             old     new   delta
run_man_pipe                                         369     420     +51

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-05 14:28:20 +01:00
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
3d572a8cc3 watch: implement -x
function                                             old     new   delta
packed_usage                                       35949   36009     +60
watch_main                                           229     269     +40
.rodata                                           107008  107009      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 101/0)             Total: 101 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-05 12:23:32 +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
cdcb4ce314 volume_id: improve handling of too-small (usually zero-byte or erroring) blockdevs
function                                             old     new   delta
volume_id_get_buffer                                 327     372     +45
volume_id_open_node                                   17      24      +7
volume_id_probe_all                                  133     123     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 52/-10)             Total: 42 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-04 15:59:33 +01:00
Alyssa Ross via busybox
7310339e73 volume_id: volume_id_get_buffer with small FSes
I was working with some very small ext4 filesystems, used for
overlaying on immutable VM/container images.  If it's only desired to
overlay a single config file, these filesystems can be very small
indeed, and so ran afoul of this length check.

Since 4fc5ec56f ("device matching against UUIDs: do not try
floppies") (from 2009), floppy drives are skipped before this function
is even called.  Reading from an unused loop device returns 0, so it
should be fine to reduce  the minimum length.

Signed-off-by: Alyssa Ross via busybox <busybox@busybox.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-04 13:30:24 +01:00
Denys Vlasenko
72fbc81224 fdisk: code shrink
function                                             old     new   delta
new_partition                                       1054    1066     +12
list_table                                          1366    1370      +4
update_units                                          32      35      +3
list_disk_geometry                                    68      71      +3
get_geometry                                         535     538      +3
fdisk_fatal                                           38      41      +3
warn_cylinders                                        42      44      +2
xbsd_print_disklabel                                 836     834      -2
create_doslabel                                      110     108      -2
change_units                                          49      45      -4
xbsd_new_part                                        477     456     -21
add_partition                                       1278    1246     -32
.rodata                                           107059  107008     -51
fdisk_main                                          4775    4618    -157
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/7 up/down: 30/-269)          Total: -239 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-04 12:03:33 +01:00
Denys Vlasenko
8aba5f6347 fdisk: comment out "not a multiple of 512 bytes" warning
function                                             old     new   delta
bb_getsize_in_512sect                                187     163     -24
.rodata                                           107088  107059     -29
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-53)             Total: -53 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-04 10:30:45 +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
93b684fe9f findfs: tweak --help
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-03 11:40:41 +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
Denys Vlasenko
4855fbe6a8 fdisk: uncomment -s support
function                                             old     new   delta
bb_BLKGETSIZE_sectors                                  -     191    +191
fdisk_main                                          4674    4774    +100
packed_usage                                       35941   35997     +56
.rodata                                           107069  107089     +20
get_geometry                                         665     511    -154
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/1 up/down: 367/-154)          Total: 213 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-02 15:26:03 +01:00
Denys Vlasenko
705c9b3487 devfsd: constify, code shrink
function                                             old     new   delta
static.copy_inode                                    613     608      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-5)               Total: -5 bytes
   text	   data	    bss	    dec	    hex	filename
1087619	    827	   5088	1093534	 10af9e	busybox_old
1087654	    787	   5088	1093529	 10af99	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-02 08:49:11 +01:00
Denys Vlasenko
4e815cd7b3 fdisk_sgi: formatting fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-02 05:19:26 +01:00
Denys Vlasenko
3b19867d97 fdisk: fix spurious warning about zero unused sectors
while at it, deindent nested for()

function                                             old     new   delta
verify_sun                                           429     447     +18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-01 14:36:06 +01:00
Denys Vlasenko
47775e8e6a fdisk: simplify start/len calcualtions for Sun labels
function                                             old     new   delta
new_partition                                       1060    1054      -6
fetch_sun                                            219     207     -12
verify_sun_cmp                                        54      39     -15
verify_sun                                           508     429     -79
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-112)           Total: -112 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-01 14:23:00 +01:00
Denys Vlasenko
7ac2bd6917 fdisk: eliminate static variables, fix GPT disk size (32x32->32 overflow)
function                                             old     new   delta
verify_sun                                           481     508     +27
.rodata                                           107016  107022      +6
verify_sun_cmp                                        51      54      +3
sun_other_endian                                       1       -      -1
scsi_disk                                              1       -      -1
floppy                                                 1       -      -1
xbsd_print_disklabel                                 838     836      -2
xbsd_new_part                                        479     477      -2
xbsd_write_bootstrap                                 397     394      -3
set_sun_partition                                    103     100      -3
delete_partition                                     435     432      -3
xbsd_part_index                                        4       -      -4
xbsd_part                                              4       -      -4
verify_sun_starts                                      4       -      -4
part_entry_len                                         4       -      -4
part_array                                             4       -      -4
n_parts                                                4       -      -4
gpt_hdr                                                4       -      -4
check_sun_label                                      214     208      -6
list_table                                          1433    1423     -10
fetch_sun                                            233     219     -14
bsd_select                                          1564    1546     -18
get_geometry                                         691     665     -26
get_boot                                            1539    1513     -26
fdisk_main                                          4737    4674     -63
------------------------------------------------------------------------------
(add/remove: 0/10 grow/shrink: 3/12 up/down: 36/-207)        Total: -171 bytes
   text	   data	    bss	    dec	    hex	filename
1078472	    555	   5088	1084115	 108ad3	busybox_old
1078332	    555	   5056	1083943	 108a27	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-01 13:44:54 +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
Denys Vlasenko
2bfe3753d9 lkblk: list multiple MOUNTPOINTS
function                                             old     new   delta
lsblk_main                                           550     869    +319
.rodata                                           106977  107010     +33
process__sys_block_NAME                              461     356    -105
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 352/-105)          Total: 247 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-30 21:16:30 +01:00
Denys Vlasenko
8463ce06ca lsblk: add error messages and exit code when non-blockdevs are given
function                                             old     new   delta
process__sys_block_NAME                                -     461    +461
lsblk_main                                           511     550     +39
.rodata                                           106960  106977     +17
process_SYS_BLOCK_entry                              460       -    -460
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 2/0 up/down: 517/-460)           Total: 57 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-30 20:16:59 +01:00
Osama Abdelkader
8a347fd31a lsblk: new applet
Add a simple lsblk utility that lists information about block devices.
Reads from /sys/block to enumerate devices and displays their size,
type, and mount point.

Features:
- Lists all block devices or specific devices
- Shows device size in human-readable format (B, K, M, G, T, P)
- Shows device type (disk, loop, partition)
- Shows mount point if device is mounted
- Sorts devices alphabetically
- Minimal implementation (~2.5 kb)

Mostly rewritten by vda.linux

function                                             old     new   delta
lsblk_main                                             -     511    +511
process_SYS_BLOCK_entry                                -     460    +460
.rodata                                           106856  106960    +104
read_ull                                               -      81     +81
packed_usage                                       35924   35952     +28
compare_devices                                        -      25     +25
applet_names                                        2856    2862      +6
applet_main                                         1644    1648      +4
------------------------------------------------------------------------------
(add/remove: 5/0 grow/shrink: 4/0 up/down: 1219/0)           Total: 1219 bytes

Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-30 12:23:42 +01:00
Denys Vlasenko
3fb6b31c71 tar: strip unsafe hardlink components - GNU tar does the same
Defends against files like these (python reproducer):

import tarfile
ti = tarfile.TarInfo("leak_hosts")
ti.type = tarfile.LNKTYPE
ti.linkname = "/etc/hosts"  # or "../etc/hosts" or ".."
ti.size = 0
with tarfile.open("/tmp/hardlink.tar", "w") as t:
	t.addfile(ti)

function                                             old     new   delta
skip_unsafe_prefix                                     -     127    +127
get_header_tar                                      1752    1754      +2
.rodata                                           106861  106856      -5
unzip_main                                          2715    2706      -9
strip_unsafe_prefix                                  102      18     -84
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/3 up/down: 129/-98)            Total: 31 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-29 12:01:56 +01:00
Denys Vlasenko
768ab5384c httpd: do not use a global variable in index.cgi
text	   data	    bss	    dec	    hex	filename
   3255	      0	      0	   3255	    cb7	httpd_indexcgi.o
   3253	      0	      4	   3257	    cb9	httpd_indexcgi.o.old

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-29 02:39:31 +01:00
Denys Vlasenko
df1ef312a0 httpd: handle bare "Location: URL" redirects from CGIs
Many sites on the Web give those as valid CGI examples -
no "Status:", just "Location:".

function                                             old     new   delta
cgi_io_loop_and_exit                                 620     684     +64
log_cgi_status                                         -      49     +49
.rodata                                           106846  106861     +15
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 128/0)             Total: 128 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-28 17:45:37 +01:00
Denys Vlasenko
03d6d1014a ash: fix \ooo octal printout in DEBUG code
function                                             old     new   delta
ash_main                                            1624    1645     +21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-28 15:12:43 +01:00
Denys Vlasenko
56143ea63f ash: code shrink: eliminate pstrcmp1()
function                                             old     new   delta
find_command                                         961     963      +2
evalcommand                                         1631    1633      +2
hashcmd                                              299     300      +1
describe_command                                     320     321      +1
clearcmdentry                                         93      94      +1
cdcmd                                                695     696      +1
pstrcmp1                                              16       -     -16
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 6/0 up/down: 8/-16)              Total: -8 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-28 09:23:54 +01:00
Denys Vlasenko
758c948a63 ash: remove non-standard chdir builtin
function                                             old     new   delta
.rodata                                           106853  106846      -7
builtintab                                           352     344      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-15)             Total: -15 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-28 01:34:13 +01:00
Denys Vlasenko
77d242d7ac ash: get rid of a static in cmdlookup()/delete_cmd_entry()
function                                             old     new   delta
cmdlookup_pp                                           -     120    +120
find_command                                         953     961      +8
unsetcmd                                              74      76      +2
hashcmd                                              297     299      +2
lastcmdentry                                           4       -      -4
delete_cmd_entry                                      47      43      -4
cmdlookup                                            132       -    -132
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 3/1 up/down: 132/-140)           Total: -8 bytes
   text	   data	    bss	    dec	    hex	filename
  47470	      8	    149	  47627	   ba0b	shell/ash.o.orig
  47466	      8	    145	  47619	   ba03	shell/ash.o

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-28 01:01:15 +01:00
Denys Vlasenko
2051c69358 ash: group command hashing/searching code together, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-28 00:34:22 +01:00
Denys Vlasenko
e05b922c89 ash: move casematch() directly to its only caller, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-27 23:44:06 +01:00
Denys Vlasenko
c9af9073b8 ash: reorder functions to reduce forward declarations, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-27 17:08:12 +01:00
Denys Vlasenko
b715e82e1f ash: JOBSTOPPED can only be set if job control is compiled in - conditionalize code which depends on it
With !ASH_JOB_CONTROL:

function                                             old     new   delta
cmdloop                                              363     351     -12
exitcmd                                               47      31     -16
.rodata                                           106422  106398     -24
stoppedjobs                                           58       -     -58
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/3 up/down: 0/-110)           Total: -110 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-27 13:15:14 +01:00
Denys Vlasenko
dee0168219 ash: reorder functions to reduce forward declarations, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-27 13:15:13 +01:00
Denys Vlasenko
97a7813971 ash: move applet handling out of tryexec() - making it similar to dash
function                                             old     new   delta
tryexec                                                -      60     +60
shellexec                                            476     349    -127
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 60/-127)           Total: -67 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-27 11:17:38 +01:00
Denys Vlasenko
e4f4bf95ac doc: update docs/nofork_noexec.txt
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-27 08:13:42 +01:00
Denys Vlasenko
22b96c0ddf ash: unset traps before entering NOEXEC programs after [v]fork
If we don't do that, if INT trap was set, ^C will set a flag
"run trap later" and _return_, which is not expected by the NOFORK!

function                                             old     new   delta
clear_traps                                            -     107    +107
evalcommand                                         1617    1631     +14
shellexec                                            471     476      +5
setsignal                                            333     327      -6
forkchild                                            620     480    -140
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/2 up/down: 126/-146)          Total: -20 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-27 08:03:15 +01:00
Denys Vlasenko
28e4d2b854 httpd: optimize example CGIs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-26 07:21:11 +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
4da1badf13 networking/httpd_indexcgi.c: non-mallocing version
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-26 04:48:28 +01:00