aboutsummaryrefslogtreecommitdiff
path: root/include/libbb.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* test: code shrink supplementary groupsRon Yorston2024-10-091-0/+4
| | | | | | | | Since we don't use is_in_supplementary_groups() there's no need for the cached_groupinfo structure to include the members required for its support or for them to be initialised. Saves 32 bytes.
* Merge branch 'busybox' into mergeRon Yorston2024-10-081-1/+1
|\
| * libbb: modify find_executable() to not temporarily write to PATHDenys Vlasenko2024-10-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This allows to simplify "which" applet code function old new delta find_executable 93 111 +18 which_main 191 177 -14 builtin_source 316 294 -22 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 18/-36) Total: -18 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | libbb: code shrink supplementary group testRon Yorston2024-10-081-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Recent upstream changes to file permission tests added a function to check and cache values in the supplementary group list. The implementation of getgroups() in the Windows port adds no useful information beyond what can be obtained by checking the current effective gid, which all callers of the new function already do. The function can be replaced with a simple 'FALSE'. Saves 232-288 bytes.
* | Merge branch 'busybox' into mergeRon Yorston2024-10-081-0/+14
|\|
| * ash: cache more of uid/gid syscallsDenys Vlasenko2024-10-071-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Testcase: setuidgid 1:1 strace ash -c 'test -x TODO; test -x TODO; echo $?' should show that second "test -x" does not query ids again. function old new delta ash_main 1236 1256 +20 get_cached_euid - 19 +19 get_cached_egid - 19 +19 test_main 56 72 +16 test_exec 119 135 +16 is_in_supplementary_groups 52 57 +5 nexpr 718 702 -16 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 4/1 up/down: 95/-16) Total: 79 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: make "test -x" use cached groupinfoDenys Vlasenko2024-10-071-0/+1
| | | | | | | | | | | | | | | | | | | | | | function old new delta test_main2 - 407 +407 testcmd 10 23 +13 test_main 418 56 -362 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 420/-362) Total: 58 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: simplify parameter passing in is_in_supplementary_groups()Denys Vlasenko2024-10-071-2/+8
| | | | | | | | | | | | | | | | | | | | | | function old new delta is_in_supplementary_groups 54 52 -2 nexpr 721 718 -3 test_exec 125 119 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-11) Total: -11 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: move is_in_supplementary_groups() from test to libbbDenys Vlasenko2024-10-071-0/+5
| | | | | | | | | | | | | | | | | | | | function old new delta is_in_supplementary_groups - 54 +54 nexpr 766 721 -45 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 54/-45) Total: 9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2024-09-281-5/+5
|\|
| * lineedit: make save_history() FAST_FUNCDenys Vlasenko2024-09-271-5/+5
| | | | | | | | | | | | | | | | | | | | | | function old new delta save_history 267 266 -1 hush_exit 98 97 -1 exitshell 140 138 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-4) Total: -4 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: use 64-bit time on 32-bit platformsRon Yorston2024-08-141-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To avoid problems with dates in 2038 and beyond use 64-bit time values on 32-bit platforms. - Mostly this just requires a few preprocessor macros to choose the appropriate functions, structs and typedefs. - We have our own implementations of nanosleep(), clock_gettime() and clock_settime(). Omit the Windows include file that declares them. - Apply the hack for struct timeval in the 'ts' applet on 32-bit. Adds 1624 bytes on 32-bit, none on 64-bit. (GitHub issue #446)
* | Merge branch 'busybox' into mergeRon Yorston2024-06-231-0/+9
|\|
| * libbb: fix 64-bit bb_popcnt_longDenys Vlasenko2024-05-311-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: add bit counting function, use where appropriateDenys Vlasenko2024-05-311-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although "naive" counting function is not too slow and is smaller, using it on e.g. each of 1024 words of CPU mask feels wrong. function old new delta bb_popcnt_32 - 52 +52 get_prefix 323 321 -2 nproc_main 206 199 -7 d4_run_script 739 731 -8 ipcalc_main 533 507 -26 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 0/4 up/down: 52/-43) Total: 9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * nproc: prepare for arbitrarily large CPU masksDenys Vlasenko2024-05-311-0/+2
| | | | | | | | | | | | | | | | | | | | | | function old new delta get_malloc_cpu_affinity - 76 +76 nproc_main 216 206 -10 process_pid_str 250 206 -44 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 0/2 up/down: 76/-54) Total: 22 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: add env var to control error dialogsRon Yorston2024-06-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the environment variable BB_CRITICAL_ERROR_DIALOGS is set to 1 critical error dialogs are enabled. If unset or set to any other value they aren't. In either case the error messages introduced by commit 790e37727 (win32: revert 'don't set error mode') are issued. The shell exports BB_CRITICAL_ERROR_DIALOGS to the environment immediately on any change so the setting takes effect at once. Adds 104-160 bytes. (GitHub issue #423)
* | win32: ensure PIDs are read early in procps_scan()Ron Yorston2024-05-161-2/+1
| | | | | | | | | | | | | | | | | | | | | | Recent changes to allow orphaned processes to report a parent PID of 1 rely on the assumption that Process32First/Process32Next return parents before children. This isn't guaranteed by the API. Obtain all known PIDs on the first call to procps_scan() so that dead parents can be detected reliably. Costs 48 bytes.
* | ps: report unknown parent PID as 1Ron Yorston2024-05-141-0/+3
| | | | | | | | | | | | | | | | | | | | If the parent PID doesn't appear in the process table, report it as 1. This more closely matches how orphaned children are handled on UNIX. Adds 96-128 bytes. (GitHub issue #416)
* | libbb: make default history size configurableRon Yorston2024-04-281-0/+5
| | | | | | | | | | | | | | | | Allow the default history size (used if HISTFILESIZE isn't set) to be configured at build time. This may be less than or equal to the standard history size. (GitHub issue #411)
* | win32: rearrange applet override handlingRon Yorston2024-02-021-4/+4
| | | | | | | | | | | | | | | | | | | | - Rename some functions to be more meaningful. - Adjust conditional compilation to clarify which code is required for 'standalone shell' and 'exec prefers applets' settings. This shouldn't result in any change to the behaviour or size of default builds.
* | Fix POSIX build in standalone shell modeRon Yorston2024-01-231-2/+3
| | | | | | | | | | | | | | The conditional compilation to control standalone shell mode was incorrect when building for POSIX. This hadn't been noticed before as it had only been tested in the default configuration where standalone shell mode is disabled.
* | Remove FAST_FUNC from variadic functionsRon Yorston2024-01-171-12/+12
| | | | | | | | | | | | | | | | | | | | | | The GCC documentation points out that the stdcall attribute doesn't apply to functions which take a variable number of arguments. GCC is silent about this during compilation but clang complains noisily. Remove FAST_FUNC from all variadic functions. This has no effect whatsoever on the binary resulting from a default 32-bit build. Signed-off-by: Ron Yorston <rmy@pobox.com>
* | libbb: introduce last_char_is_dir_sep()Ron Yorston2024-01-041-0/+1
| | | | | | | | | | | | | | Add a convenience function to determine if the last character of a string is a directory separator. Adds 16-32 bytes.
* | win32: make the clang build less crashyRon Yorston2024-01-031-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | busybox-w32 binaries built using clang crashed so frequently that they were pretty much unusable. The main issue seems to be with assignments to the structures containing global variables which are used in most applets. Upstream commit 5156b2455 (Make const ptr assign as function call in clang) addresses this, but is insufficient for the build on Windows. Extend the idea to the ASSIGN_CONST_PTR() macro too. Costs 32-80 bytes in the gcc build.
* | win32: tidy up conditional compilation of applet overrideRon Yorston2023-12-121-5/+5
| | | | | | | | | | This doesn't affect the generated binary, at least in the default configuration.
* | win32: code shrink applet overridesRon Yorston2023-12-101-4/+4
| | | | | | | | | | | | | | | | Pass the PATH to be used to look up executables down from the shell to the applet override code. This replaces the use of a static variable and a function to fetch its value. Saves 16-32 bytes.
* | Merge branch 'busybox' into mergeFRP-5236-g7dff7f376Ron Yorston2023-12-051-4/+8
|\|
| * start-stop-daemon: do not lose error messages with -bDenys Vlasenko2023-11-081-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta start_stop_daemon_main 1186 1206 +20 bb_daemonize_or_rexec 196 212 +16 bb_banner 47 46 -1 packed_usage 34656 34645 -11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 36/-12) Total: 24 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sleep: fix "sleep -- ARGS"Denys Vlasenko2023-10-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | function old new delta sleep_main 116 119 +3 printf_main 860 837 -23 single_argv 50 25 -25 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 3/-48) Total: -45 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: add options to control globbing of hidden filesRon Yorston2023-09-201-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add shell options: - 'nohiddenglob' excludes files with the hidden attribute from globbing - 'nohidsysglob' excludes files with the hidden and system attributes from globbing If both options are enabled 'nohiddenglob' takes precedence. These options also affect tab completion. Files that are hidden because they start with a period aren't affected (unless they also have the hidden attribute). Costs 160-208 bytes. (GitHub issue #367)
* | ps: increase length of 'comm' fieldRon Yorston2023-08-291-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Linux the command name associated with a process (as can be obtained from '/proc/<PID>/comm') is truncated to 16 characters. Thus upstream BusyBox only allows 16 characters for the 'comm' field in 'ps'. There's no need for such a constraint in busybox-w32. Moreover, the command name is used for the full command line ('args' field) in most cases. This field is allowed to be rather long in 'ps' so it's not expected to be truncated. Still, to avoid diverging too much from upstream it's best to have some measure of truncation. Increase the allowed length of the command name to 32 characters. Adds 16 bytes. (GitHub issue #358)
* | win32: UCRT: avoid I64 printf format warningsAvi Halachmi (:avih)2023-08-281-2/+3
| | | | | | | | | | | | | | | | Builds without warnings on: mingw-msvcrt gcc 13.2 i686/x86-64 (w64devkit). mingw-ucrt gcc 13.1/13.2 i686/x86-64 (winlibs). Where previously both the ucrt builds warned about I64.
* | Merge branch 'busybox' into mergeRon Yorston2023-08-101-0/+7
|\|
| * introduce and use exitcode_tDenys Vlasenko2023-07-171-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'busybox' into mergeRon Yorston2023-07-131-0/+4
|\|
| * ash: disable sleep as builtin, closes 15619Denys Vlasenko2023-07-101-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Has a few annoying problems: * sleepcmd() -> sleep_main(), the parsing of bad arguments exits the shell. * sleep_for_duration() in sleep_main() has to be interruptible for ^C traps to work, which may be a problem for other users of sleep_for_duration(). * BUT, if sleep_for_duration() is interruptible, then SIGCHLD interrupts it as well (try "/bin/sleep 1 & sleep 10"). * sleep_main() must not allocate anything as ^C in ash longjmp's. (currently, allocations are only on error paths, in message printing). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: code shrink: introduce and use [_]exit_FAILURE()Denys Vlasenko2023-06-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | win32: code shrink applet look-upRon Yorston2023-06-051-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Remove find_preferred_applet_by_name(). Instead add a reference to is_applet_preferred() in find_applet_by_name(). - Remove the global variable ash_path. Use a static instead, accessed by calling get_ash_path(). - Mark ash_applet_by_name() as NOINLINE. Saves 64-96 bytes. (GitHub issue #329)
* | win32: another BB_OVERRIDE_APPLETS fixRon Yorston2023-06-041-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support for conditionally replacing applets with external commands requires the ability to check whether a given command name is present on PATH. This was being done using the PATH environment variable, which works in commands run by the shell but not in the shell itself. - The shell uses the *shell* variable PATH to look for executables. This may not be the same as the *environment* variable. - 'command -p' uses an entirely different PATH. Applet look-up in the shell is now treated as a special case, with the actual PATH being used passed to the look-up code in a global variable. This doesn't affect tab completion in the shell: whether a completion is an applet or an external command is irrelevant. Costs 152-288 bytes. (GitHub issue #329)
* | libbb: don't build useless functionsRon Yorston2023-04-161-0/+6
| | | | | | | | | | | | | | | | | | | | The functions ndelay_on(), ndelay_off() and close_on_exec_on() don't do anything useful because our fcntl(2) implementation doesn't support the features they require. Replace them with stubs. Saves 176-208 bytes.
* | Merge branch 'busybox' into mergeRon Yorston2023-04-091-1/+1
|\|
| * libbb: consolidate NOMMU fix of restoring high bit in argv[0][0]Denys Vlasenko2023-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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>
* | ash: add support for INT trapRon Yorston2023-04-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The trap builtin now handles INT. As before, other signals (from a limited list) are accepted but their traps don't have any effect. There's some variability in how shells handle traps. This patch upholds that proud tradition. Various changes are needed to make this work: - Line editing has a new flag to ignore Ctrl-C. - If INT is being trapped or ignored don't call raise_interrupt(). - A minimal implementation of dotrap() is provided. - Call dotrap() when the read builtin or line input detect Ctrl-C. - Adjust Ctrl-C detection when the INT trap is changed. - Set may_have_traps when an INT trap is set. Costs 368-448 bytes. (GitHub issue #303)
* | win32: virtual terminal input fixesRon Yorston2023-03-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | - Disable ENABLE_PROCESSED_INPUT in raw mode. Otherwise ^C isn't immediately detected during shell command line editing with virtual terminal input enabled. - Switch read_key()/unix_readkey() to windows_read_key()/read_key(). This allows the shell `read` builtin to use windows_read_key(). Without this change `read` fails when virtual terminal input is enabled.
* | win32: enable Unix read_key() for virtual terminalRon Yorston2023-03-051-3/+2
| | | | | | | | | | | | | | Until now busybox-w32 has used a native Windows implementation of read_key(). Build the upstream Unix implementation and use it instead of the native version when virtual terminal input mode is enabled.
* | win32: changes to console mode handlingRon Yorston2023-03-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the environment variable BB_TERMINAL_MODE as a more general way of controlling console/terminal mode setting. The default remains unchanged: use virtual terminal mode for output if possible but fall back to the console API with emulated ANSI escape sequences. Currently valid settings are: 0 Force use of console mode 1 Force use of virtual terminal mode for output 5 Prefer virtual terminal mode for output, fall back to console Other values won't do anything useful until code elsewhere has been updated. BB_SKIP_ANSI_EMULATION remains available for backwards compatibility. If both variables are set BB_TERMINAL_MODE takes precedence.
* | Merge branch 'busybox' into mergeRon Yorston2023-01-051-1/+7
|\|
| * shell: fix compile failures in some configsDenys Vlasenko2023-01-031-1/+7
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2022-10-121-0/+1
|\|