aboutsummaryrefslogtreecommitdiff
path: root/libbb/appletlib.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Fix POSIX build; new yearRon Yorston2022-02-091-1/+1
|
* Merge busybox into mergeRon Yorston2022-02-091-1/+1
|\ | | | | | | | | | | | | | | Fix conflicts in reset and ash. Redefine the new safe_read_key() as a reference to read_key(). Disable SHA256_HWACCEL.
| * *: slap on a few ALIGN* where appropriateDenys Vlasenko2022-02-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'busybox' into mergeRon Yorston2021-10-131-9/+14
|\|
| * shell: fix script's comm field if ENABLE_FEATURE_PREFER_APPLETS=yDenys Vlasenko2021-10-111-2/+8
| | | | | | | | | | | | | | | | | | | | function old new delta re_execed_comm - 46 +46 main 72 86 +14 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/0 up/down: 60/0) Total: 60 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Make const ptr assign as function call in clangYU Jincheng2021-10-091-1/+1
| | | | | | | | | | | | | | | | - This can act as memory barrier in clang to avoid read before assign of a const ptr Signed-off-by: LoveSy <shana@zju.edu.cn> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * *: generalize "const trick"YU Jincheng2021-10-071-2/+1
| | | | | | | | | | | | | | | | While at it, change all "__asm__" to "asm" Co-authored-by: canyie <31466456+canyie@users.noreply.github.com> Signed-off-by: YU Jincheng <shana@zju.edu.cn> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: code shrink in main() and scripted_main()Denys Vlasenko2021-09-281-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta main 68 65 -3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3) Total: -3 bytes text data bss dec hex filename 1472 560 16 2048 800 busybox_old 1398 552 16 1966 7ae busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * busybox: fix "busybox --help busybox" not showing correct textDenys Vlasenko2021-08-161-1/+5
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | busybox: bring help handling into line with upstreamRon Yorston2021-08-161-5/+5
| | | | | | | | | | Upstream has fixed a problem with 'busybox --help' so it's possible to remove another gratuitous divergence.
* | busybox: make 'busybox --help busybox' workRon Yorston2021-05-141-0/+4
| | | | | | | | | | Upstream changes broke the 'busybox --help busybox' command. Fix it.
* | Merge branch 'busybox' into mergeRon Yorston2021-05-141-8/+22
|\|
| * echo: special case "echo --help": it should not show help textDenys Vlasenko2021-03-151-8/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | While at it, fix "busybox --help echo" and other special applets to still print the help text. function old new delta run_applet_and_exit 732 761 +29 show_usage_if_dash_dash_help 70 78 +8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 37/0) Total: 37 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | libbb: special case for busybox --help is WIN32-onlyRon Yorston2021-04-091-1/+1
| | | | | | | | | | | | Commit 32833bc06 (ash: treat all applets as NOEXEC) added special treatment for 'busybox --help'. This should only be included for WIN32 builds.
* | libbb: allow single-applet binary to buildRon Yorston2021-03-141-11/+10
| | | | | | | | | | | | The ability to build a single-applet binary was lost following commit 33a914da6b (ps: obtain applet names from other BusyBox processes).
* | busybox: allow '--install' to install symlinksFRP-3902-g61e53aa93Ron Yorston2021-03-021-43/+39
| | | | | | | | | | | | Restore the '--install -s' option which allows BusyBox to install symbolic links. Of course, this will only work if the user has permission to create symlinks.
* | Merge branch 'busybox' into mergeRon Yorston2021-03-011-30/+40
|\|
| * libbb: fix '--help' handling in FEATURE_SH_NOFORK=yDenys Vlasenko2021-02-181-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most BusyBox applets respond to the '--help' option by printing a usage message. This is normally handled by busybox_main() so applet main routines don't have support for '--help'. In standalone shell mode with FEATURE_SH_NOFORK enabled nofork applets are invoked directly, bypassing busybox_main(). This results in inconsistent handling of '--help': - applets which call getopt() report "unrecognized option '--help'" and print help anyway; - realpath says "--help: No such file or directory" and doesn't print help; - usleep says "invalid number '--help'" and doesn't print help. Avoid inconsistency by checking for '--help' in run_nofork_applet(). Bug found by Ron Yorston. function old new delta show_usage_if_dash_dash_help - 70 +70 run_nofork_applet 347 362 +15 run_applet_no_and_exit 432 365 -67 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 85/-67) Total: 18 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | libbb: make banner shorterRon Yorston2021-02-161-2/+2
| |
* | Merge branch 'busybox' into mergeRon Yorston2021-02-051-79/+17
|\|
| * libbb: code shrink and speed up find_applet_by_name()Ron Yorston2021-02-021-79/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | find_applet_by_name() determines the appropriate range of applet indices to check for the given name and performs a linear search in applet_names[]. Revise the code so the index of the upper bound of the range, 'max', isn't calculated. Instead check the value of the first non-matching character to see if we've reached the end of the range. This new code speeds up the time to find a valid applet name by 6% and halves the time to detect that a given name is invalid. The average time to detect an invalid name is now the same as for a valid one. function old new delta find_applet_by_name 155 133 -22 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-22) Total: -22 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Update copyright messageRon Yorston2021-01-131-1/+1
| | | | | | | | Hey, look! It's 2021 already.
* | Merge branch 'busybox' into mergeRon Yorston2020-11-121-2/+7
|\|
| * libbb: do not open-code __errno_location() callDenys Vlasenko2020-10-011-1/+6
| | | | | | | | | | | | Thanks dalias! Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: extend "errno pointer" trick to other than __GLIBC__Denys Vlasenko2020-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Savings on musl: function old new delta resume_main 582 614 +32 lbb_prepare - 20 +20 seq_main 432 449 +17 fgetsetversion 74 88 +14 ... script_main 1207 1180 -27 close_silently 28 - -28 shell_builtin_ulimit 655 626 -29 lineedit_read_key 280 247 -33 ------------------------------------------------------------------------------ (add/remove: 2/1 grow/shrink: 25/123 up/down: 182/-882) Total: -700 bytes text data bss dec hex filename 1005858 551 5676 1012085 f7175 busybox_old 1005136 551 5680 1011367 f6ea7 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | busybox: create custom installation directoryRon Yorston2020-08-151-5/+6
| | | | | | | | | | If a custom installation directory is specified try to create it. Don't worry if we can't, we'll find out when the links fail.
* | busybox: add option to install to Unix-style pathsRon Yorston2020-08-141-11/+34
| | | | | | | | | | The command 'busybox --install -u' installs links to Unix-style paths in the system drive.
* | Merge branch 'busybox' into mergeRon Yorston2020-07-091-5/+33
|\|
| * nologin: make it possible to build it as single appletDenys Vlasenko2020-06-241-5/+33
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: enable globbing by defaultRon Yorston2020-06-141-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change how busybox.exe expands wildcards on the command line. When globbing is enabled at compile time provide an implementation of _setargv(), which is run early during startup of C programs. This: - enables globbing by setting _dowildcard to -1 - checks for the presence of the environment BB_GLOBBING - if it exists and is set to 0 disables globbing - if it doesn't exist sets BB_GLOBBING=0 but continues to apply Windows' globbing in the current process The consequences of this are: - When busybox.exe is initially run from a Command Prompt Windows' globbing is applied; - Windows' globbing is turned off for future child processes, thus allowing the shell re-execute busybox.exe without it interfering with wildcards; - this behaviour can be overridden by setting BB_GLOBBING explicitly. Globbing can still be disabled at compile time if required. In that case BB_GLOBBING has no effect. With these changes globbing can be enabled by default and BusyBox will do the right thing in most circumstances. (See GitHub issues #172 and #189.)
* | ash: treat all applets as NOEXECRon Yorston2020-06-091-0/+3
| | | | | | | | | | | | | | | | | | In standalone shell mode tryexec() treats all applets as NOEXEC. Except for the shell: calling ash_main() recursively seems unwise. This avoids creating a new process for the applet (which is a Good Thing on Microsoft Windows where creating processes is expensive) but leaves the resources used by the invoking shell in the current process.
* | win32: only initialise networking if necessaryRon Yorston2020-06-011-4/+0
| | | | | | | | | | | | A call to initialise networking is made during start up even if the applet doesn't need it. Instead, only initialise networking when a call is made to a function that definitely requires it.
* | libbb: rearrange command line processingRon Yorston2020-04-051-13/+11
| | | | | | | | Process the '--busybox' flag before checking argv[0].
* | Merge branch 'busybox' into mergeRon Yorston2020-01-081-1/+1
|\|
| * clang/llvm 9 fix - do not eliminate a store to a fake "const"Denys Vlasenko2019-10-251-1/+1
| | | | | | | | | | | | | | This is *much* better (9 kbytes better) than dropping "*const" optimization trick. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Update copyright dateRon Yorston2020-01-081-1/+1
| |
* | Merge branch 'busybox' into mergeRon Yorston2019-08-161-5/+5
|\|
| * libbb: reduce the overhead of single parameter bb_error_msg() callsJames Byrne2019-07-021-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower overhead call to bb_perror_msg() when only a string was being printed with no parameters. This saves space for some CPU architectures because it avoids the overhead of a call to a variadic function. However there has never been a simple version of bb_error_msg(), and since 2007 many new calls to bb_perror_msg() have been added that only take a single parameter and so could have been using bb_simple_perror_message(). This changeset introduces 'simple' versions of bb_info_msg(), bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and bb_herror_msg_and_die(), and replaces all calls that only take a single parameter, or use something like ("%s", arg), with calls to the corresponding 'simple' version. Since it is likely that single parameter calls to the variadic functions may be accidentally reintroduced in the future a new debugging config option WARN_SIMPLE_MSG has been introduced. This uses some macro magic which will cause any such calls to generate a warning, but this is turned off by default to avoid use of the unpleasant macros in normal circumstances. This is a large changeset due to the number of calls that have been replaced. The only files that contain changes other than simple substitution of function calls are libbb.h, libbb/herror_msg.c, libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c, networking/udhcp/common.h and util-linux/mdev.c additonal macros have been added for logging so that single parameter and multiple parameter logging variants exist. The amount of space saved varies considerably by architecture, and was found to be as follows (for 'defconfig' using GCC 7.4): Arm: -92 bytes MIPS: -52 bytes PPC: -1836 bytes x86_64: -938 bytes Note that for the MIPS architecture only an exception had to be made disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h) because it made these files larger on MIPS. Signed-off-by: James Byrne <james.byrne@origamienergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2019-03-311-0/+1
|\|
| * libbb: mark scripted_main() as externally visibleRon Yorston2019-03-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Building with individual binaries enabled fails when embedded script applets are included: /tmp/ccIvMFZg.o: In function `main': applet.c:(.text.main+0x20): undefined reference to `scripted_main' Mark scripted_main() as externally visible. Reported-by: Yann E. MORIN <yann.morin.1998@free.fr> Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: improve filesystem detection and displayRon Yorston2019-03-201-0/+3
| | | | | | | | | | | | | | | | | | | | Miscellaneous improvements: - Enable '-a' option to display all filesystems in df(1). - Detect the UDF CDROM filesystem and display it in 'stat -f'. - Let getmntent(3) handle CDROM and floppy devices, ignoring those that have no media. - Set number of inodes and filesystem flags to 0 in statfs(2).
* | win32: add function to convert slashes to backslashesRon Yorston2019-03-151-1/+1
| | | | | | | | | | | | | | | | | | There are now two places where slashes are converted to backslashes throughout a string so it makes sense to create a function to do this. To avoid confusion rename convert_slashes() to bs_to_slash() and call the new function slash_to_bs().
* | Update copyright dateRon Yorston2019-03-141-1/+1
| |
* | win32: fix POSIX buildRon Yorston2019-02-171-0/+8
| | | | | | | | | | | | There were a few places where changes intended for the WIN32 build also affected the POSIX build. Fix these so the result of 'make defconfig; make' for busybox-w32 is identical to upstream BusyBox.
* | libbb: skip fake path componentsRon Yorston2019-02-071-4/+5
| | | | | | | | | | | | | | | | Commit 3476fb9f4 added a fake prefix to the applet pathname to identify the argument containing the name of an interpreted script. Skip over the prefix to prevent it appearing in error messages.
* | win32: add support for the euro currency symbolRon Yorston2019-02-021-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The euro currency symbol was added to some OEM code pages. See: https://www.aivosto.com/articles/charsets-codepages-dos.html Add a configuration option (enabled by default) to support this. When enabled: - The read_key() function requests wide character key events. This allows the euro symbol to be entered regardless of the console OEM code page, though it needs to be available in the ANSI code page. - Conversions between OEM and ANSI code pages in winansi.c are modified to work around a bug in the Microsoft routines. - If the OEM code page is 850 when BusyBox starts it's changed to 858. This is the only currently supported OEM code page. Also, the shell read builtin is modified to use read_key() whenever input is being taken from the console.
* | Merge branch 'busybox' into mergeRon Yorston2019-01-101-4/+4
|\|
| * single-applet build --help had extra \n, removeDenys Vlasenko2019-01-011-5/+5
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ps: display interpreted script name in comm columnRon Yorston2019-01-081-1/+17
| | | | | | | | | | | | | | | | | | | | | | When an interpreted script is being run the comm column in ps should display the name of the script not the name of the interpreter. Use a fake applet pathname to indicate which argument contains the script. This also allows pidof to obtain the pid of a script.
* | ps: add support for the args columnRon Yorston2019-01-081-11/+18
| | | | | | | | | | | | | | | | | | Implement read_cmdline() for WIN32 by storing the command line in the same way as the applet name. The applet name is actually used for the comm column which is truncated to COMM_LEN. Using this as the size of the bb_comm array avoids the need to calculate MAX_APPLET_NAME_LEN.