aboutsummaryrefslogtreecommitdiff
path: root/libbb (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
| * libbb: extend "errno pointer" trick to other than __GLIBC__Denys Vlasenko2020-10-012-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * mount: support the sizelimit and offset option for loop devicesSteffen Trumtrar2020-10-011-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Starting with linux kernel v5.4 squashfs has a more strict parameter checking implemented. Unlike util-linux mount, busybox never supported the sizelimit option but simply forwards it to the kernel. Since v5.4 mounting will fail with squashfs: Unknown parameter 'sizelimit' Support the sizelimit parameter by setting it in the LOOP_SET_STATUS64 structure before handing it to the kernel. While at it also add support for the offset option, which currently will always be set to 0. function old new delta cut_out_ull_opt - 167 +167 singlemount 1230 1266 +36 set_loop 834 862 +28 losetup_main 479 483 +4 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 3/0 up/down: 235/0) Total: 235 bytes Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: fold common64_hash() into its only userDenys Vlasenko2020-09-301-47/+28
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | libbb: reinstate NULL check in last_char_is()Ron Yorston2020-08-231-1/+1
| | | | | | | | | | | | | | | | Upstream commit 79a4032ee removed the test for a NULL argument to last_char_is(). As reported in the upstream bug tracker this can cause tar to segfault: https://bugs.busybox.net/show_bug.cgi?id=13131
* | Merge branch 'busybox' into mergeRon Yorston2020-08-233-13/+7
|\|
| * build system: drop PLATFORM_LINUXRon Yorston2020-08-132-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PLATFORM_LINUX is a hidden configuration option which is disabled by default and enabled at over a hundred locations for features that are deemed to be Linux specific. The only effect of PLATFORM_LINUX is to control compilation of libbb/match_fstype.c. This file is only needed by mount and umount. Remove all references to PLATFORM_LINUX and compile match_fstype.c if mount or umount is enabled. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: shrink last_char_is(), no longer allow NULL string argumentDenys Vlasenko2020-07-191-10/+5
| | | | | | | | | | | | | | function old new delta last_char_is 40 28 -12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: code shrink Unix-style path handlingRon Yorston2020-08-232-9/+6
| | | | | | | | | | | | | | | | Replace auto_add_system_drive() with alloc_system_drive() which leaves space for a possible filename extension. This makes it possible to drop alloc_win32_extension() and auto_win32_extension(). Saves 144 bytes.
* | 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.
* | win32: handle Unix-style absolute paths for executablesRon Yorston2020-08-132-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As noted in commit 548ec7045 (win32: interpret absolute paths as relative to %SYSTEMDRIVE%) a path starting with a '/' in the Unix world is treated as relative to the current drive by Windows. To avoid ambiguity that commit considered certain such paths to be relative to %SYSTEMDRIVE%. Extend this to paths representing executables. Add the functions need_system_drive() and auto_add_system_drive() to detect the need for a system drive prefix and to add it if necessary. Use these functions in: - the 'which' applet - the find_executable() function - tab-completion code - PATH look-up, shellexec(), describe_command() and find_command() in ash - parse_interpreter() and mingw_spawn_1() With these changes executable paths starting with a slash are handled consistently, whatever the current drive.
* | Merge branch 'busybox' into mergeRon Yorston2020-07-097-32/+64
|\|
| * libbb: code shrink in last_char_is()Denys Vlasenko2020-06-301-8/+9
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * compare_string_array: code shrinkMartin Lewis2020-06-291-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code shrink and prevention of possible out of bounds access. function old new delta nth_string 36 26 -10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-10) Total: -10 bytes text data bss dec hex filename 981342 16915 1872 1000129 f42c1 busybox_old 981332 16915 1872 1000119 f42b7 busybox_unstripped Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * procps: code shrinkMartin Lewis2020-06-291-2/+10
| | | | | | | | | | | | | | | | | | | | | | function old new delta skip_whitespace_if_prefixed_with - 17 +17 procps_read_smaps 911 854 -57 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 17/-57) Total: -40 bytes Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * nologin: make it possible to build it as single appletDenys Vlasenko2020-06-241-5/+33
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * suppress a few compile warningsDenys Vlasenko2020-06-241-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * randomconfig fixesDenys Vlasenko2020-06-231-0/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * xstrndup: Use strndup instead of implementing it.Martin Lewis2020-06-091-14/+5
| | | | | | | | | | Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: avoid duplicated slashes in output of type/command builtinsRon Yorston2020-06-291-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Microsoft developers have a penchant for adding trailing slashes to entries in PATH: C:/Windows/System32/WindowsPowerShell/v1.0/ C:/Windows/System32/OpenSSH/ The 'type' and 'command -v' shell builtins return paths with duplicated slashes for executables in those directories. See GitHub issue #191. Bonus fixes: - handle backslashes as well as slashes in concat_path_file() - convert backslashes to slashes in the output of 'type', 'command -v'
* | 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.
* | ash: reset ANSI emulation when BB_SKIP_ANSI_EMULATION changesRon Yorston2020-04-131-0/+2
| | | | | | | | | | Update the skip status on the first call to skip_ansi_emulation() and whenever the BB_SKIP_ANSI_EMULATION variable changes.
* | httpd: enable in default configurationsRon Yorston2020-04-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enable the httpd applet in WIN32 default configurations. Some additional features have also been enabled: 'Ranges:' header Basic HTTP authentication Custom error pages GZIP content encoding Common Gateway Interface (CGI) and related features are not enabled. Basic HTTP authentication requires bb_simplify_abs_path_inplace(). This function shouldn't be used for WIN32 paths. In this case it's processing a URL which is OK.
* | libbb: rearrange command line processingRon Yorston2020-04-051-13/+11
| | | | | | | | Process the '--busybox' flag before checking argv[0].
* | win32: more improvements to 'c:file' pathsRon Yorston2020-03-291-1/+1
| | | | | | | | | | | | | | | | Tab-completion of 'c:file' paths was leaking memory and incorrectly included BusyBox applets and shell built-ins. Fix handling of 'c:file' paths used as arguments to spawn functions. Otherwise things like 'timeout 5 c:busybox sleep 99' don't work.
* | win32: improve handling of 'c:file' paths for executablesRon Yorston2020-03-181-1/+1
| | | | | | | | | | | | | | | | bb_basename() didn't properly handle paths of the form 'c:file'. Attempting to run 'c:busybox' resulted in 'c:busybox: applet not found'. The shell had a similar problem: trying to run 'c:busybox' reported 'sh: c:busybox: not found'.
* | Merge branch 'busybox' into mergeRon Yorston2020-02-151-3/+14
|\|
| * ash,hush: allow builtins to be tab-completed, closes 7532Ron Yorston2020-01-291-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta complete_cmd_dir_file 678 830 +152 get_builtin_name - 35 +35 optschanged 125 132 +7 hush_main 1069 1076 +7 save_command_ps_at_cur_history 76 78 +2 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 4/0 up/down: 203/0) Total: 203 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2020-01-088-21/+27
|\|
| * Remove stime() function callsAlistair Francis2019-11-191-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | stime() has been deprecated in glibc 2.31 and replaced with clock_settime(). Let's replace the stime() function calls with clock_settime() in preperation. function old new delta rdate_main 197 224 +27 clock_settime - 27 +27 date_main 926 941 +15 stime 37 - -37 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 2/0 up/down: 69/-37) Total: 32 bytes Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * read_key(): placate "warning: shifting a negative signed value is undefined"Denys Vlasenko2019-10-251-1/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * clang/llvm 9 fix - do not eliminate a store to a fake "const"Denys Vlasenko2019-10-252-2/+2
| | | | | | | | | | | | | | This is *much* better (9 kbytes better) than dropping "*const" optimization trick. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Remove syscall wrappers around clock_gettime, closes 12091Denys Vlasenko2019-10-241-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 12091 "Direct use of __NR_clock_gettime is not time64-safe". function old new delta runsv_main 1698 1712 +14 startservice 378 383 +5 get_mono 31 25 -6 date_main 932 926 -6 gettimeofday_ns 17 - -17 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 2/2 up/down: 19/-29) Total: -10 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * dpkg-deb: work around bogus error message when working with XZ compressed ↵Denys Vlasenko2019-10-111-5/+8
| | | | | | | | | | | | | | | | | | | | packages function old new delta unpack_xz_stream 2309 2317 +8 bb_full_fd_action 464 472 +8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * replace: count_strstr - Handle an edge case where sub is emptyMartin Lewis2019-10-091-0/+4
| | | | | | | | | | | | | | | | | | | | If sub is empty, avoids an infinite loop. function old new delta count_strstr 45 63 +18 Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: Converted safe_read to safe_write formatMartin Lewis2019-10-091-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | Changed safe_read to be symmetrical to safe_write, it shall never return EINTR because it calls read multiple times, the error is considered transient. function old new delta safe_read 44 57 +13 Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * time: Use 64 prefix syscall if we have toAlistair Francis2019-10-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some 32-bit architectures no longer have the 32-bit time_t syscalls. Instead they have suffixed syscalls that returns a 64-bit time_t. If the architecture doesn't have the non-suffixed syscall and is using a 64-bit time_t let's use the suffixed syscall instead. This fixes build issues when building for RISC-V 32-bit with 5.1+ kernel headers. If an architecture only supports the suffixed syscalls, but is still using a 32-bit time_t report a compilation error. This avoids us have to deal with converting between 64-bit and 32-bit values. There are currently no architectures where this is the case. Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Update copyright dateRon Yorston2020-01-081-1/+1
| |
* | Merge branch 'busybox' into mergeRon Yorston2019-08-1635-73/+209
|\|
| * unicode: code shrink in character width determinationDenys Vlasenko2019-07-231-0/+6
| | | | | | | | | | | | | | function old new delta bb_wcwidth 267 238 -29 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: include <crypt.h> only if necessaryDenys Vlasenko2019-07-161-0/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: reduce the overhead of single parameter bb_error_msg() callsJames Byrne2019-07-0230-65/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * libbb: deal with "declaration of 'link' shadows a global declaration" warningDenys Vlasenko2019-06-251-7/+7
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * pidof: support "pidof /path/to/binary" caseDenys Vlasenko2019-06-151-1/+5
| | | | | | | | | | | | | | function old new delta find_pid_by_name 230 227 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * readlink,realpath: fix a case with a symplink, closes 11021Denys Vlasenko2019-06-131-0/+29
| | | | | | | | | | | | | | function old new delta xmalloc_realpath_coreutils 125 201 +76 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * mount,losetup: use /dev/loop-control is it existsDenys Vlasenko2019-06-091-6/+36
| | | | | | | | | | | | | | | | | | | | | | function old new delta get_free_loop - 58 +58 set_loop 597 649 +52 losetup_main 482 476 -6 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 110/-6) Total: 104 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * tftp: optional tftp-hpa compatDenys Vlasenko2019-06-091-0/+1
| | | | | | | | | | | | | | function old new delta tftp_main 276 394 +118 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * passwd: do not set 0 as date of last password change, closes 11951Denys Vlasenko2019-06-071-1/+7
| | | | | | | | | | | | | | function old new delta update_passwd 1491 1505 +14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>