aboutsummaryrefslogtreecommitdiff
path: root/miscutils (follow)
Commit message (Collapse)AuthorAgeFilesLines
* platform.h: UNINITIALIZED_VAR() macro for suppressing gcc warningsDenys Vlasenko9 days1-5/+6
| | | | | | | | | | | | With gcc-15.0.1: function old new delta tftpd_main 603 617 +14 expand_one_var 1923 1929 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 20/0) Total: 20 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* devfsd: heed warningsDenys Vlasenko10 days1-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hdparm: fix ATA identification string outputRomain Guyard10 days1-1/+1
| | | | | | | | | | | | | | | | | | | | | print_ascii() is intended to skip leading spaces before printing ATA IDENTIFY strings, but the condition is inverted and skips non-space characters instead. As a result, left-justified strings such as serial numbers and firmware revisions can be printed as empty, while strings containing embedded spaces, such as model names, are truncated up to the first space. Fix the condition so only leading spaces are skipped, and add a regression test covering left-justified strings, embedded spaces, and leading-space padding. function old new delta ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0) Total: 0 bytes Signed-off-by: Romain Guyard <foss@romainguyard.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: fix ":d" commandDenys Vlasenko2026-03-151-13/+13
| | | | | | | function old new delta less_main 2105 2062 -43 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: unbreak EAGAIN propagationDenys Vlasenko2026-02-271-6/+12
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: make read error reporting actually visibleDenys Vlasenko2026-02-271-10/+19
| | | | | | | | | | | | function old new delta m_status_print 252 275 +23 status_print 111 122 +11 read_lines 783 775 -8 .rodata 107141 107131 -10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 34/-18) Total: 16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: improve O_NONBLOCK manipulations on stdinDenys Vlasenko2026-02-271-32/+44
| | | | | | | | | | | | | "less FILE" case needs it to be set just once. In other cases, manipulate it less often. function old new delta read_lines 702 783 +81 reinitialize 198 199 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 82/0) Total: 82 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: do not retry reads of stdin if got EAGAINDenys Vlasenko2026-02-271-35/+35
| | | | | | | | | | | | | | | Also: fewer syscalls to set/clear O_NONBLOCK, skip trying to read keyboard if poll() told us it's not ready. function old new delta reinitialize 184 198 +14 getch_nowait 251 258 +7 sched_yield 25 - -25 read_lines 815 702 -113 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 2/1 up/down: 21/-138) Total: -117 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: placate warnings where strchr/strstr returns constant pointerDenys Vlasenko2026-02-151-1/+1
| | | | | | | | | Newer glibc is now smarter and can propagate const-ness from those! function old new delta readtoken1 3111 3108 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: whitespace cleanupDenys Vlasenko2026-02-081-1/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: use xasprintf_inplace() in more placesDenys Vlasenko2026-02-061-7/+7
| | | | | | | | | | | | 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>
* man: fix following links if run inside manpage dirDenys Vlasenko2026-02-051-16/+28
| | | | | | | function old new delta run_man_pipe 369 420 +51 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* fdisk: several fixes for 4K sector sizeDenys Vlasenko2026-02-041-4/+6
| | | | | | | | | | | | | | | | | 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>
* devfsd: constify, code shrinkDenys Vlasenko2026-02-021-4/+4
| | | | | | | | | | | | 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>
* *: use safe_waitpid() or wait_any_nohang() where approppriateDenys Vlasenko2025-07-301-3/+7
| | | | | | | | | | | function old new delta crond_main 1227 1237 +10 init_main 804 794 -10 wait_one 263 252 -11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 10/-21) Total: -11 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* crond: reap orphaned grandchildren to prevent zombie buildupValentin Lab2025-07-301-0/+4
| | | | | | | | | | | | | | | | | | | | If a cron job launches a background task, e.g. `sh -c "sleep 5 &"`, the shell exits immediately and the `sleep` process is re-parented to PID 1. When BusyBox `crond` itself happens to be PID 1 (common in a minimal container), those orphans become direct children of `crond`. Because `crond` only calls waitpid() for the PIDs it explicitly tracks, these processes remain forever in Z state and the container slowly fills with zombies. Add a small `while (waitpid(-1, NULL, WNOHANG) > 0)` sweep at the end of check_completions() so any stray children are reaped. When `crond` is not PID 1 the loop returns -ECHILD immediately, so behaviour and overhead on a normal system are unchanged. Size impact: +12 bytes on x86-64 (gcc 13.3.0 -Os, static) Signed-off-by: Valentin Lab <valentin.lab@kalysto.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: crypt_make_pw_salt(): fix yescrypt's random salt last charDenys Vlasenko2025-07-191-1/+1
| | | | | | | function old new delta crypt_make_pw_salt 128 146 +18 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: fix race between signal handlers setting bb_got_signal and poll()Denys Vlasenko2025-07-021-1/+1
| | | | | | | | | | | | function old new delta __ppoll_time64 - 211 +211 check_got_signal_and_poll - 164 +164 read_key 607 601 -6 shell_builtin_read 1328 1318 -10 ------------------------------------------------------------------------------ (add/remove: 4/0 grow/shrink: 0/2 up/down: 375/-16) Total: 359 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/archival: make setup_unzip_on_fd() return bytes read if not compressedDenys Vlasenko2025-04-202-2/+2
| | | | | | | | | | | | | | | setup_unzip_on_fd() does not return the transformer structure, so the user does not know how much to seek back (or alternatively what the signature was) when compressor signature is not detected. Currently not needed (the only user is tar which dies anyway). However, rpm2cpio may need this if we extend it to extract the internal .cpio even if cpio's compressions algo is not known. function old new delta setup_unzip_on_fd 53 59 +6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* crond: log5 fix typo, replace log level '4' with '5'Jones Syue2024-03-021-1/+1
| | | | | | | | | | | log5() with crondlog(5, msg, va) seems making logging more consistent. function old new delta ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0) Total: 0 bytes Signed-off-by: Jones Syue <jonessyue@qnap.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* time: implement %% and \escapes in -f FMTDenys Vlasenko2024-01-011-21/+18
| | | | | | | function old new delta time_main 1217 1316 +99 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* time: fix max resident set size unitNatanael Copa2023-12-311-9/+19
| | | | | | | | | | | | | | | The ru_maxrss is already in Kbytes and not pages. function old new delta ptok 21 - -21 time_main 1261 1217 -44 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-65) Total: -65 bytes fixes: https://bugs.busybox.net/show_bug.cgi?id=15751 Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* introduce and use exitcode_tDenys Vlasenko2023-07-174-4/+5
| | | | | | | | | | | | | | | | | | | | | function old new delta strings_main 422 420 -2 setfattr_main 175 173 -2 brctl_main 1548 1546 -2 makedevs_main 979 975 -4 rev_main 337 332 -5 getfattr_main 307 302 -5 cut_main 1201 1196 -5 cksum_main 398 393 -5 umount_main 573 565 -8 ln_main 516 508 -8 expand_main 660 652 -8 df_main 1068 1060 -8 renice_main 346 332 -14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/13 up/down: 0/-76) Total: -76 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* getfattr: fix "getfattr NOTEXIST" - now prints error msgDenys Vlasenko2023-07-171-4/+9
| | | | | | | | | | function old new delta getfattr_main 309 307 -2 .rodata 105395 105391 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6) Total: -6 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* getfattr: new appletYU Jincheng2023-07-161-0/+131
| | | | | | | | | | | | | | | | | | | function old new delta getfattr_main - 309 +309 print_attr - 115 +115 packed_usage 34576 34631 +55 .rodata 105349 105395 +46 lgetxattr - 41 +41 getxattr - 41 +41 llistxattr - 35 +35 listxattr - 35 +35 applet_names 2806 2815 +9 applet_main 1620 1624 +4 ------------------------------------------------------------------------------ (add/remove: 7/0 grow/shrink: 4/0 up/down: 690/0) Total: 690 bytes Signed-off-by: YU Jincheng <shana@zju.edu.cn> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* i2ctransfer: fix build warningDenys Vlasenko2023-07-101-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Update applet size estimatesDenys Vlasenko2023-07-1031-42/+42
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: code shrink: introduce and use [_]exit_FAILURE()Denys Vlasenko2023-06-152-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta exit_FAILURE - 7 +7 _exit_FAILURE - 7 +7 run 198 199 +1 restore_state_and_exit 114 115 +1 xbsd_write_bootstrap 399 397 -2 vfork_compressor 209 207 -2 sig_handler 12 10 -2 serial_ctl 154 152 -2 parse_args 1169 1167 -2 onintr 21 19 -2 make_new_session 493 491 -2 login_main 988 986 -2 gotsig 35 33 -2 do_iplink 1315 1313 -2 addgroup_main 397 395 -2 inetd_main 1911 1908 -3 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 2/12 up/down: 16/-25) Total: -9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* seedrng: fix for glibc <= 2.24 not providing random headerThomas Devoogdt2023-04-111-4/+10
| | | | | | | | | | - dropped the wrong define (not sure why it was there) - <sys/random.h> not available if glibc <= 2.24 - GRND_NONBLOCK not defined if <sys/random.h> not included - ret < 0 && errno == ENOSYS has to be true to get creditable set Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* seedrng: fix for glibc <= 2.24 not providing getrandom()Denys Vlasenko2023-04-101-0/+14
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Remove "select PLATFORM_LINUX"Denys Vlasenko2022-11-295-9/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Fix non-Linux buildsSamuel Thibault2022-11-295-0/+9
| | | | | | | | | | | Various tools are Linuxish and should thus only attempted to build on Linux only. Some features are also Linux-only. Also, libresolv is used on all GNU platforms, notably GNU/Hurd and GNU/kfreeBSD. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: style fixDenys Vlasenko2022-08-303-16/+16
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* devmem: add 128-bit widthAaro Koskinen2022-08-261-24/+44
| | | | | | | | | | | | | | Add 128-bit width if the compiler provides the needed type. function old new delta devmem_main 405 464 +59 .rodata 109025 109043 +18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 77/0) Total: 77 bytes Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com> Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tree: unicode tweak (use normal space char, 0x20)Denys Vlasenko2022-08-261-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tree: make it unicode-awareDenys Vlasenko2022-08-261-3/+16
| | | | | | | | | | | function old new delta tree_print 396 420 +24 .rodata 105251 105266 +15 tree_main 86 91 +5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 44/0) Total: 44 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: hopefully fix bug 14956 (use-after-free)Denys Vlasenko2022-08-181-0/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tree: new appletRoger Knecht2022-06-301-0/+118
| | | | | | | | | | | | | | | | | | | | | | | | Adds the tree program to list directories and files in a tree structure. function old new delta tree_print - 343 +343 scandir64 - 330 +330 scandir - 330 +330 tree_main - 86 +86 .rodata 105150 105228 +78 packed_usage 34511 34557 +46 alphasort64 - 31 +31 alphasort - 31 +31 strcoll - 5 +5 applet_names 2801 2806 +5 applet_main 1616 1620 +4 applet_suid 101 102 +1 applet_install_loc 202 203 +1 ------------------------------------------------------------------------------ (add/remove: 11/0 grow/shrink: 6/0 up/down: 1291/0) Total: 1291 bytes Signed-off-by: Roger Knecht <rknecht@pm.me> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* seedrng: do not hash in a constant string, it's not adding entropyDenys Vlasenko2022-05-031-8/+8
| | | | | | | | | | function old new delta seedrng_main 906 880 -26 .rodata 104899 104873 -26 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-52) Total: -52 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* seedrng: restore error check on fsyncDenys Vlasenko2022-05-021-9/+12
| | | | | | | | | Or else security people will never stop nagging us. function old new delta seedrng_main 884 906 +22 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* seedrng: it's not a part of util-linux, move to miscutilsDenys Vlasenko2022-05-021-0/+239
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* crond: implement support for setting PATH in crontab filesPaul Fox2022-05-021-7/+16
| | | | | | | | | | | | | | It's very inconvenient for a cron user not to be able to set a "personal" PATH for their cron jobs, as is possible with other crons function old new delta load_crontab 868 942 +74 .rodata 104878 104884 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 80/0) Total: 80 bytes Signed-off-by: Paul Fox <pgf@foxharp.boston.ma.us> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: slap on a few ALIGN_PTR where appropriateDenys Vlasenko2022-02-061-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: slap on a few ALIGN* where appropriateDenys Vlasenko2022-02-062-2/+2
| | | | | | | | | | | | | | The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map" function old new delta .rodata 108586 108460 -126 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-126) Total: -126 bytes text data bss dec hex filename 970412 4219 1848 976479 ee65f busybox_old 970286 4219 1848 976353 ee5e1 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* fix "defined but not used" warningsDenys Vlasenko2022-01-171-0/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash,hush: fix handling of SIGINT while waiting for interactive inputDenys Vlasenko2022-01-172-3/+3
| | | | | | | | | | | | | | | | function old new delta lineedit_read_key 160 237 +77 __pgetc 522 589 +67 fgetc_interactive 244 309 +65 safe_read_key - 39 +39 read_key 588 607 +19 record_pending_signo 23 32 +9 signal_handler 75 81 +6 .rodata 104312 104309 -3 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 6/1 up/down: 282/-3) Total: 279 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: introduce and use chdir_or_warn()Denys Vlasenko2022-01-131-2/+1
| | | | | | | | | | | | | function old new delta chdir_or_warn - 37 +37 send_cgi_and_exit 720 711 -9 xchdir 27 15 -12 setup_environment 233 217 -16 fork_job 449 433 -16 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/4 up/down: 37/-53) Total: -16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: invert the meaning of SETUP_ENV_NO_CHDIR -> SETUP_ENV_CHDIRDenys Vlasenko2022-01-131-2/+2
| | | | | | | | | | | | Double negatives are hard to grok. function old new delta login_main 986 988 +2 su_main 474 470 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 2/-4) Total: -2 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: code shrink: introduce and use [_]exit_SUCCESS()Denys Vlasenko2022-01-055-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta exit_SUCCESS - 7 +7 _exit_SUCCESS - 7 +7 run_pipe 1562 1567 +5 pseudo_exec_argv 399 400 +1 finish 86 87 +1 start_stop_daemon_main 1109 1107 -2 shutdown_on_signal 38 36 -2 runsv_main 1662 1660 -2 redirect 1070 1068 -2 read_line 79 77 -2 pause_and_low_level_reboot 54 52 -2 list_i2c_busses_and_exit 483 481 -2 less_exit 12 10 -2 identify 4123 4121 -2 grep_file 1161 1159 -2 getty_main 1519 1517 -2 fsck_minix_main 2681 2679 -2 free_session 132 130 -2 fdisk_main 4739 4737 -2 clean_up_and_exit 53 51 -2 bsd_select 1566 1564 -2 bb_daemonize_or_rexec 198 196 -2 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 3/17 up/down: 21/-34) Total: -13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* less: code shrinkDenys Vlasenko2022-01-051-9/+13
| | | | | | | | | | | | | function old new delta restore_tty - 29 +29 less_main 2107 2105 -2 getch_nowait 253 251 -2 buffer_print 614 612 -2 less_exit 51 12 -39 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/4 up/down: 29/-45) Total: -16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>