summaryrefslogtreecommitdiff
path: root/libbb
Commit message (Collapse)AuthorAgeFilesLines
* lineedit: fix crash when icanon set with -echoAkos Somfai2023-04-121-2/+2
| | | | | | | | | When icanon is set with -echo (e.g. ssh from an emacs shell) then S.state will remain null but later it will be deferenced causing ash to crash. Fix: additional check on state. Signed-off-by: Akos Somfai <akos.somfai@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* appletlib: fix "warning: unused variable applet_no"Tomas Paukrt2023-04-101-1/+1
| | | | | Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix sleep built-in not running INT trap immediately on ^CDenys Vlasenko2023-04-101-9/+7
| | | | | | | function old new delta sleep_for_duration 169 149 -20 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: consolidate NOMMU fix of restoring high bit in argv[0][0]Denys Vlasenko2023-04-061-4/+6
| | | | | | | | | | | function old new delta fork_or_rexec 46 56 +10 bootchartd_main 1087 1079 -8 cpio_main 674 661 -13 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 10/-21) Total: -11 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* lineedit: fix matching of directories when searching PATHRon Yorston2023-03-291-2/+2
| | | | | | | | | | | | | | | Commit 8baa643a3 (lineedit: match local directories when searching PATH) included subdirectories of the current directory in the search when tab-completing commands. Unfortunately a short time later commit 1d180cd74 (lineedit: use strncmp instead of is_prefixed_with (we know the length)) broke this feature by returning an incorrect length for the array of paths. Fix the length and reinstate matching of subdirectories. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha: do not read shaNI variable twice, and factor out its settingDenys Vlasenko2023-03-291-12/+16
| | | | | | | | | | | | My gcc inlines both calls, so instead of "-20 bytes" I get only this: function old new delta sha256_begin 84 83 -1 sha1_begin 114 111 -3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-4) Total: -4 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha: fix sha-NI instruction detectionDenys Vlasenko2023-03-291-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: fix SIGWINCH and SIGCHLD (in hush) interrupting line input, closes 15256Denys Vlasenko2023-01-261-7/+10
| | | | | | | | | | function old new delta record_pending_signo 32 63 +31 lineedit_read_key 231 224 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 31/-7) Total: 24 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: fix compile failures in some configsDenys Vlasenko2023-01-031-11/+13
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/loop: fix compile failure (name collision)Denys Vlasenko2023-01-021-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: shrink del_loop()Denys Vlasenko2022-12-131-1/+1
| | | | | | | function old new delta del_loop 52 49 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* loop: restore the correct return vaule of set_loop()Denys Vlasenko2022-12-131-4/+8
| | | | | | It is only used by mount's error path, though... Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* loop: optionally use ioctl(LOOP_CONFIGURE) to set up loopdevsDenys Vlasenko2022-12-132-9/+65
| | | | | | | | | | | | | | | | LOOP_CONFIGURE is added to Linux 5.8 function old new delta NO_LOOP_CONFIGURE (old code): set_loop 784 782 -2 LOOP_CONFIGURE: set_loop 784 653 -131 TRY_LOOP_CONFIGURE: set_loop 784 811 +27 Based on a patch by Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* loop: refactor: extract subfunction set_loopdev_params()Xiaoming Ni2022-12-131-39/+51
| | | | | | | | | | Extract subfunction set_loop_info() from set_loop() function old new delta set_loop 760 784 +24 Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* loop: simplify code of LOOP_SET_FD failureXiaoming Ni2022-12-121-7/+3
| | | | | | | | function old new delta set_loop 790 760 -30 Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* loop: refactor: extract subfunction get_next_free_loop()Xiaoming Ni2022-12-121-30/+26
| | | | | | | | | | | | | Extract subfunction get_next_free_loop() from set_loop() Also fix miss free(try) when stat(try) and mknod fail function old new delta set_loop 807 790 -17 Fixes: 3448914e8cc5 ("mount,losetup: use /dev/loop-control is it exists") Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* loop: fix a race when a free loop device is snatchedXiaoming Ni2022-11-151-1/+10
| | | | | | | | | | | When /dev/loop-control exists and *device is empty, the mount may fail if a concurrent mount is running. function old new delta set_loop 809 807 -2 Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: mark stack in assembly files read-onlyLudwig Nussel2022-08-306-0/+18
| | | | | Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* fix [ --help ] and [[ --help ]]Denys Vlasenko2022-08-301-0/+3
| | | | | | | function old new delta show_usage_if_dash_dash_help 72 79 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: optional sleep builtinShawn Landden2022-08-271-0/+6
| | | | | | | | | | | | function old new delta sleepcmd - 10 +10 builtintab 352 360 +8 .rodata 105264 105271 +7 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/0 up/down: 25/0) Total: 25 bytes Signed-off-by: Shawn Landden <shawnlandden@tutanota.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: make '--help' handling more consistentRon Yorston2022-08-221-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Running an applet with '--help' as its only argument is treated as a special case. If additional arguments follow '--help' the behaviour is inconsistent: - applets which call single_argv() print help and do nothing else; - applets which call getopt() report "unrecognized option '--help'" and print help anyway; - expr says "expr: syntax error" and doesn't print help; - printenv silently ignores '--help', prints any other variables and doesn't print help; - realpath says "--help: No such file or directory", prints the path of any other files and doesn't print help. If the first argument is '--help' ignore any other arguments and print help. This is more consistent and most likely what the user wanted. See also commit 6bdfbc4cb (libbb: fix '--help' handling in FEATURE_SH_NOFORK=y). function old new delta show_usage_if_dash_dash_help 75 69 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-6) Total: -6 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* lineedit: get PWD from ashRon Yorston2022-07-031-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The line editing code and ash disagree when the current directory is changed to a symbolic link: ~ $ mkdir real ~ $ ln -s real link ~ $ cd link ~/real $ pwd /home/rmyf36/link Note the prompt says we're in ~/real. Bash does: [rmy@random ~]$ cd link [rmy@random link]$ pwd /home/rmyf36/link Ash uses the name supplied by the user while the line editing code calls getcwd(3). The discrepancy can be avoided by fetching the value of PWD from ash. Hush calls getcwd(3) when the directory is changed so there's no disagreement with the line editing code. There is no standard how shells should handle cd'ing into symlinks. function old new delta parse_and_put_prompt 838 869 +31 Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash,hush: use HOME for tab completion and promptsRon Yorston2022-06-261-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | ash and hush correctly use the value of HOME for tilde expansion. However the line editing code in libbb obtains the user's home directory by calling getpwuid(). Thus tildes in tab completion and prompts may be interpreted differently than in tilde expansion. When the line editing code is invoked from a shell make it use the shell's interpretation of tilde. This is similar to how GNU readline and bash collaborate. function old new delta get_homedir_or_NULL 29 72 +43 optschanged 119 126 +7 hush_main 1204 1211 +7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 57/0) Total: 57 bytes v2: Always check for HOME before trying the password database: this is what GNU readline does. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: restore special handling of nomsg errorsRon Yorston2022-06-262-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The functions bb_perror_nomsg() and bb_perror_nomsg_and_die() are used to print error messages where no specific information is available. For example: $ busybox mktemp -p / mktemp: (null): Permission denied mktemp(3) doesn't tell us the name of the file it tried to create. However, printing '(null)' is a regression introduced by commit 6937487be (libbb: reduce the overhead of single parameter bb_error_msg() calls). Restore the previous behaviour by reverting the changes to the two functions mentioned: $ busybox mktemp -p / mktemp: Permission denied function old new delta bb_perror_nomsg_and_die 7 14 +7 bb_perror_nomsg 7 14 +7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 14/0) Total: 14 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* style fixDenys Vlasenko2022-05-011-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: update config help text with new performance numbersDenys Vlasenko2022-02-181-3/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha256: explicitly use sha256rnds2's %xmm0 (MSG) argumentDenys Vlasenko2022-02-122-70/+70
| | | | | | Else, the code seemingly does not use MSG. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* whitespace fixesDenys Vlasenko2022-02-112-11/+11
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: revert last commit: pshufb is a SSSE3 insn, can't use itDenys Vlasenko2022-02-116-115/+163
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: shrink unrolled x86-64 codeDenys Vlasenko2022-02-112-123/+117
| | | | | | | function old new delta sha1_process_block64 3481 3384 -97 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha: improve commentsDenys Vlasenko2022-02-104-21/+20
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* whitespace fixDenys Vlasenko2022-02-094-10/+10
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha256: code shrink in x86 assemblyDenys Vlasenko2022-02-092-12/+10
| | | | | | | | function old new delta sha256_process_block64_shaNI 32-bit 676 673 -3 sha256_process_block64_shaNI 64-bit 680 677 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha256: code shrink in 64-bit x86Denys Vlasenko2022-02-091-11/+14
| | | | | | | function old new delta sha256_process_block64_shaNI 701 680 -21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha256: code shrink in 32-bit x86Denys Vlasenko2022-02-091-13/+16
| | | | | | | function old new delta sha256_process_block64_shaNI 697 676 -21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha256: code shrink in 32-bit x86Denys Vlasenko2022-02-092-123/+114
| | | | | | | function old new delta sha256_process_block64_shaNI 713 697 -16 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: shrink x86 hardware accelerated hashing (32-bit)Denys Vlasenko2022-02-082-7/+5
| | | | | | | function old new delta sha1_process_block64_shaNI 511 507 -4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: shrink x86 hardware accelerated hashing (32-bit)Denys Vlasenko2022-02-081-6/+5
| | | | | | | function old new delta sha1_process_block64_shaNI 517 511 -6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: shrink x86 hardware accelerated hashingDenys Vlasenko2022-02-082-32/+29
| | | | | | | | function old new delta sha1_process_block64_shaNI 32-bit 524 517 -7 sha1_process_block64_shaNI 64-bit 510 508 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: shrink unrolled x86-64 codeDenys Vlasenko2022-02-082-46/+21
| | | | | | | | | | function old new delta sha1_process_block64 3482 3481 -1 .rodata 108460 108412 -48 ------------------------------------------------------------------------------ (add/remove: 1/4 grow/shrink: 0/2 up/down: 0/-49) Total: -49 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: shrink and speed up unrolled x86-64 codeDenys Vlasenko2022-02-076-46/+131
| | | | | | | function old new delta sha1_process_block64 3514 3482 -32 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: slap on a few ALIGN_PTR where appropriateDenys Vlasenko2022-02-061-1/+1
| | | | 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>
* libbb/sha256: code shrink in 32-bit x86Denys Vlasenko2022-02-061-45/+48
| | | | | | | function old new delta sha256_process_block64_shaNI 722 713 -9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha256: code shrink in 64-bit x86Denys Vlasenko2022-02-061-48/+48
| | | | | | | function old new delta sha256_process_block64_shaNI 706 701 -5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha256: code shrink in 64-bit x86Denys Vlasenko2022-02-031-17/+17
| | | | | | | function old new delta sha256_process_block64_shaNI 730 706 -24 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha256: code shrink in 32-bit x86Denys Vlasenko2022-02-031-18/+17
| | | | | | | function old new delta sha256_process_block64_shaNI 747 722 -25 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha256: optional x86 hardware accelerated hashingDenys Vlasenko2022-02-039-26/+612
| | | | | | | | | | | | | | | | | | | | 64 bit: function old new delta sha256_process_block64_shaNI - 730 +730 .rodata 108314 108586 +272 sha256_begin 31 83 +52 ------------------------------------------------------------------------------ (add/remove: 5/1 grow/shrink: 2/0 up/down: 1055/-1) Total: 1054 bytes 32 bit: function old new delta sha256_process_block64_shaNI - 747 +747 .rodata 104318 104590 +272 sha256_begin 29 84 +55 ------------------------------------------------------------------------------ (add/remove: 5/1 grow/shrink: 2/0 up/down: 1075/-1) Total: 1074 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: in unrolled x86-64 code, pass initial W[] in registers, not on stackDenys Vlasenko2022-01-252-205/+214
| | | | | | | | | | | | This can be faster on some CPUs. On Skylake, evidently load latency from L1 (or store-to-load forwarding in LSU) is fast enough to completely hide memory reference latencies here. function old new delta sha1_process_block64 3495 3514 +19 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* cut: build fix for FEATURE_CUT_REGEXDenys Vlasenko2022-01-241-0/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>