summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* ash: correctly identify applet in getopt() error messagesRon Yorston2021-03-021-0/+2
| | | | | | | | | | | | | With the default configuration most applets are run from the shell via run_noexec_applet_and_exit(). If the applet runs getopt() and an error is detected the message takes the form: sh: unknown option -- q This happens because mingw-w64's implementation of getopt() uses the global variable __argv[0] as the name of the program. Avoid the misleading message by setting __argv[0] as appropriate.
* Post-merge build fixesRon Yorston2021-03-012-1/+2
|
* Merge branch 'busybox' into mergeRon Yorston2021-03-0121-330/+253
|\
| * bc: typo fix in commentDenys Vlasenko2021-02-261-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * dc: more docs in --helpDenys Vlasenko2021-02-261-13/+14
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * dc: document what non-GNU commands doDenys Vlasenko2021-02-261-5/+5
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * bc/dc: fix length(0) and length(0.000nnn) resultDenys Vlasenko2021-02-263-4/+23
| | | | | | | | | | | | | | function old new delta zxc_vm_process 6464 6498 +34 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * dc: correct --help textDenys Vlasenko2021-02-261-2/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | before: Tiny RPN calculator. Operations: +, -, *, /, %, ~, ^, |, p - print top of the stack without popping f - print entire stack k - pop the value and set the precision i - pop the value and set input radix o - pop the value and set output radix After: Tiny RPN calculator. Operations: Arithmetic: + - * / % ^ ~ - divide with remainder | - modular exponentiation v - square root p - print top of the stack without popping f - print entire stack k - pop the value and set precision i - pop the value and set input radix o - pop the value and set output radix function old new delta packed_usage 33519 33565 +46 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * trylink: do not drop libs from CONFIG_EXTRA_LDLIBSDenys Vlasenko2021-02-233-10/+13
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * echo: do not assume that free() leaves errno unmodifiedNatanael Copa2021-02-231-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | musl libc's mallocng free() may modify errno if kernel does not support MADV_FREE which causes echo to echo with error when it shouldn't. Future versions of POSIX[1] will require that free() leaves errno unmodified but til then, do not rely free() implementation. Should fix downstream issues: https://github.com/alpinelinux/docker-alpine/issues/134 https://gitlab.alpinelinux.org/alpine/aports/-/issues/12311 Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * lineedit: support empty PATH entries in tab completionRon Yorston2021-02-231-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Zero-length path prefixes can be specified in PATH as a leading or trailing colon or two adjacent colons. POSIX says that the use of zero-length prefixes to refer to the current directory is a legacy feature. Nonetheless the shells in BusyBox respect this feature, as does 'which'. Tab-completion of executables using PATH should support this too. function old new delta complete_cmd_dir_file 934 931 -3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3) Total: -3 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * diff: code shrinkRon Yorston2021-02-221-1/+1
| | | | | | | | | | | | | | | | | | | | function old new delta diff_main 1515 1495 -20 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-20) Total: -20 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * dnsd: check that we don't read past packetDenys Vlasenko2021-02-221-5/+12
| | | | | | | | | | | | | | function old new delta dnsd_main 1296 1304 +8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * udhcp: reuse stringsDenys Vlasenko2021-02-213-10/+14
| | | | | | | | | | | | | | | | text data bss dec hex filename 1019916 559 5020 1025495 fa5d7 busybox_old 1019906 559 5020 1025485 fa5cd busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ntpd: log responses to clients at log level 3Denys Vlasenko2021-02-211-0/+6
| | | | | | | | | | | | | | function old new delta recv_and_process_client_pkt 670 706 +36 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ntpd: without INITIAL_FREQ_ESTIMATION code, state variable is not needed tooDenys Vlasenko2021-02-211-52/+36
| | | | | | | | | | | | | | function old new delta update_local_clock 917 872 -45 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ntpd: remove unused USING_INITIAL_FREQ_ESTIMATION codeDenys Vlasenko2021-02-211-182/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ntpd: increase loglevel to 3 for "poll:32s sockets:0 interval:64s" messageDenys Vlasenko2021-02-211-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * udhcpc: clarify bcast/unicast sends in logs, include server IDDenys Vlasenko2021-02-201-8/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: sending discover sending select for 192.168.1.173 lease of 192.168.1.173 obtained, lease time 43200 sending renew to 192.168.1.1 lease of 192.168.1.173 obtained, lease time 43200 After: broadcasting discover broadcasting select for 192.168.1.173, server 192.168.1.1 lease of 192.168.1.173 obtained from 192.168.1.1, lease time 43200 sending renew to server 192.168.1.1 lease of 192.168.1.173 obtained from 192.168.1.1, lease time 43200 function old new delta udhcpc_main 2580 2610 +30 send_select 104 130 +26 send_renew 82 99 +17 send_discover 94 89 -5 send_decline 93 88 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/2 up/down: 73/-10) Total: 63 bytes text data bss dec hex filename 1019732 559 5020 1025311 fa51f busybox_old 1019898 559 5020 1025477 fa5c5 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: fix '--help' handling in FEATURE_SH_NOFORK=yDenys Vlasenko2021-02-183-10/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * ash: placate -Werror=format-securityDenys Vlasenko2021-02-183-3/+21
| | | | | | | | | | | | | | | | | | | | "In function 'sprint_status48': error: format not a string literal and no format arguments" function old new delta sprint_status48 160 158 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * applets/usage_pod.c: placate gccDenys Vlasenko2021-02-151-1/+1
| | | | | | | | | | | | "error: format not a string literal and no format arguments" Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Makefile.flags: fix the OS detection for libresolvMartin Kaiser2021-02-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 054493350 ("Do not add -lresolv on non-Linux systems") adds a condition to link with libresolv only on linux systems. The check requires that CONFIG_UNAME_OSNAME equals Linux. This works only if the uname applet is enabled. Otherwise, CONFIG_UNAME_OSNAME is empty, regardless of the platform. By default, CONFIG_UNAME_OSNAME is the output of uname -o. For most linux systems, uname -o returns "GNU/Linux" and the check fails. In this case, linking a static busybox fails because of missing symbols from libresolv. networking/lib.a(nslookup.o): In function `add_query': nslookup.c:789: undefined reference to `__res_mkquery' networking/lib.a(nslookup.o): In function `parse_reply': nslookup.c:355: undefined reference to `ns_initparse' nslookup.c:361: undefined reference to `ns_parserr' nslookup.c:404: undefined reference to `ns_name_uncompress' nslookup.c:418: undefined reference to `ns_get16' nslookup.c:419: undefined reference to `ns_name_uncompress' .. nslookup.c:456: undefined reference to `ns_get16' ... nslookup.c:469: undefined reference to `ns_name_uncompress' ... nslookup.c:489: undefined reference to `ns_get32' ... collect2: error: ld returned 1 exit status This patch uses the output of $CC -dumpmachine to detect the target platform for which we compile. Both gcc and clang support -dumpmachine. Like the original patch, we link against libresolv only if our target platform is linux-based. Fixes: 054493350 ("Do not add -lresolv on non-Linux systems") Signed-off-by: Martin Kaiser <martin@kaiser.cx> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* | libbb: fix detection of relative paths in xreadlink.csymlinkRon Yorston2021-03-012-1/+5
| | | | | | | | | | | | In xmalloc_follow_symlinks() the code to detect relative paths needs to be altered for WIN32. We don't want C:/path to be treated as a relative path.
* | Allow `rename()` to work across drivesJohannes Schindelin2021-03-011-1/+2
| | | | | | | | Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* | Do not use `rename()` for symlinksJohannes Schindelin2021-03-011-5/+8
| | | | | | | | | | | | That function would rename the _target_, not the link. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* | Fix `xmalloc_readlink()` againRon Yorston2021-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In e86a3ddd8 (win32: make readlink(2) implementation unconditional, 2021-02-12), we removed the special casing of `errno == ENOSYS` when trying to follow symlinks. However, that handling really was necessary: - When we followed a symlink, and found a non-symlink, and then called `readlink()` with that non-symlink, we got `errno == ENOSYS` on Windows (translated from `ERROR_NOT_A_REPARSE_POINT`), and we did want to stop the loop and return the current path in that case. (Noted by Johannes Schindelin.) - When readlink() called DeviceIoControl() for files on certain filesystems (e.g. FAT or a CDROM) it returned `errno == ENOSYS` (translated from ERROR_INVALID_FUNCTION). Revert the part of the patch which handled `ENOSYS` on Windows.
* | win32: let `resolve_symlinks()` _really_ resolve symbolic linksJohannes Schindelin2021-03-011-1/+9
| | | | | | | | | | | | | | | | | | When one tries to call `CreateFile()` with a reparse point, it will trigger an `ERROR_INVALID_NAME` unless `FILE_FLAG_OPEN_REPARSE_POINT` is passed. However, _when_ that flag is passed, it does not open a handle to the symlink _target_, but to the symlink itself. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* | readlink(): do `NUL`-terminate the resultJohannes Schindelin2021-03-011-2/+3
| | | | | | | | | | | | Otherwise we're provoking buffer overruns. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* | win32(symlink): fix logic to determine the type of the symlinkJohannes Schindelin2021-03-011-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Windows, there are file symlinks and directory symlinks. When trying to `opendir()` a symlink marked as `file`, it will fail. Even if the target is a directory. Because it's the wrong symlink type. To address this, our `symlink()` function calls `stat(target, ...)` to see whether the target exists and is a directory. The problem is that this `target` can be a relative path, and the link path can _also_ be a relative path. Example: `symlink("dir", "uh/oh")`. In this example, the target might say `dir`, but it is relative to `uh/oh`, i.e. we need to `stat("uh/dir", ...)`. This is necessary to pass the `cp` tests because they first create such a directory symlink and then try to copy it while dereferencing symlinks, i.e. calling `opendir()` on the symlink. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* | win32: move is_absolute_path()Ron Yorston2021-03-013-3/+10
| | | | | | | | | | Make is_absolute_path() a function rather than a macro and move it from ash.c into mingw.c.
* | win32: workaround for lazy loading issue on Windows 7Ron Yorston2021-03-011-0/+14
| | | | | | | | | | | | | | | | Investigating why free(1) wasn't working on Windows 7 I found it's possible for LoadLibraryEx to fail with exactly the flags we're using. Work around this. This probably also explains GitHub issue #204.
* | which: changes to standalone shell supportRon Yorston2021-02-251-19/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - If 'which' is run from an executable called 'which.exe' it suggests we aren't in a standalone-shell-mode shell. Don't run any standalone-shell-specific code. - Use case-insensitive comparisons when testing the names of executables. - When the argument is 'busybox' any executable name starting with 'busybox' should match. - Since 'busybox' is now treated as an applet in standalone shell mode there's no need to test for this explicitly.
* | win32: update sysinfo(2) implementation (again)Ron Yorston2021-02-231-14/+31
| | | | | | | | | | | | | | | | | | | | Use another API call: EnumPageFiles(). This seems to provide more reliable information about page file usage than the previous ad hoc method. It also allows the call to GlobalMemoryStatusEx() to be removed. With these changes free(1) works sensibly on Windows XP, though not ReactOS.
* | .gitignore: support building on WindowsJohannes Schindelin2021-02-213-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | These items are already listed, albeit without `.exe` suffix. Presumably, this is because BusyBox-w32 is traditionally cross-compiled on Linux. However, we are about to introduce a CI build definition that builds BusyBox-w32 in MSYS2 (using mingw-w64-gcc), meaning that those executables might very well exist _with_ `.exe` suffix. Let's ignore those, too. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* | Add Windows build info to README.mdRon Yorston2021-02-211-3/+7
| |
* | win32: work around MSYS2 toolchain weirdnessRon Yorston2021-02-211-0/+9
| | | | | | | | | | | | | | | | | | The Windows/MSYS2/mingw-w64 toolchain has platform-specific prefixes on many of its binaries but not all. As a result the mingw cross-compilation configurations *nearly* work. If we're cross compiling and the generated name $AR doesn't exist as a binary assume were using MSYS2 and make the necessary tweaks.
* | applet_tables: simulate force-renaming on WindowsJohannes Schindelin2021-02-211-0/+9
| | | | | | | | | | | | | | | | | | | | On Windows, you cannot `rename(source, target)` if `target` exists or if a file handle to `source` is still open. This patch is similar in spirit to 02958a6ee (kbuild: simulate force-renaming on Windows, 2017-02-01). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
* | win32: workaround for '0-bit reloc' on MSYS2Ron Yorston2021-02-212-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | There seems to be a bug in the Windows/MSYS2/mingw-w64 toolchain which results in the generated win32/resources/built-in.o lacking relocation data. Forcing an actual C program to be linked along with the resources appears to be an effective workaround. When the toolchain bug is resolved this commit can be reverted. See GitHub issue #200.
* | win32: fixes to build on Windows/MSYS2/mingw-w64Ron Yorston2021-02-214-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | To investigate GitHub issue #200 it was necessary to perform build on Window using the MSYS2/mingw-w64 toolchain. This threw up some issues: - The settings for _WIN32_WINNT and __USE_MINGW_ANSI_STDIO differ from those in Fedora resulting in compiler errors and warnings. Force the defaults I'm used to. - The workaround to allow native compilation of mconf.c was broken by a subsequent upstream change. Make it work again.
* | win32: update sysinfo(2) implementationRon Yorston2021-02-192-15/+23
| | | | | | | | | | | | | | | | | | | | Add a call to GetPerformanceInfo. Treat the SystemCache member of the PERFORMANCE_INFORMATION structure as buffer RAM. Deduct it from available RAM. The numbers reported by 'free' move about in vaguely sensible ways when I start and stop programs, though I still don't know if they're in any way accurate.
* | win32: add uptime to sysinfo(2), enable uptime appletRon Yorston2021-02-194-8/+5
| | | | | | | | | | | | | | | | | | | | Fill the uptime member of the sysinfo structure. With this change we can: - use sysinfo(2) in the 'ps' applet; - enable the 'uptime' applet (though without useful support for load averages).
* | free: implement sysinfo(2) and enable free(1)Ron Yorston2021-02-185-2/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | This is an experimental implementation of sysinfo(2)/free(1). It uses the WIN32 API GlobalMemoryStatusEx() to obtain information about memory. It seems that the 'total pagefile' value includes total RAM as well as pagefile and 'available pagefile' includes available RAM. So the RAM values are deducted. I've no idea what corresponds to Linux buffers and cache.
* | nproc: port to WIN32 and enable by defaultRon Yorston2021-02-173-4/+34
| | | | | | | | | | | | Use the WIN32 API GetProcessAffinityMask() to obtain the number of processors configured and the number available to the current process. This only works for up to 64 processors.
* | winansi: code shrink and improvementsRon Yorston2021-02-171-41/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit b0b7ab792 (winansi: code shrink) noted that combining reverse vidoe escape sequences (e.g. ESC[7;27m) didn't work properly. Make further changes to improve the situation: - revert to keeping the current attributes in a static variable; - when reverse video is enabled switch the intensity as well as the colour components; - move the code from set_console_attr() into its only caller, process_escape(); - use 0xffff instead of 0 as a flag to indicate the attributes haven't been initialised. Saves 44 bytes and seems to work better.
* | libbb: make banner shorterRon Yorston2021-02-161-2/+2
| |
* | winansi: don't check return from xmallocRon Yorston2021-02-161-3/+0
| |
* | winansi: allow alternative screen buffer to be disabledRon Yorston2021-02-151-0/+7
| | | | | | | | | | | | | | | | The alternative console screen buffer (used by less and vi) doesn't work in Wine. Setting the environment variable BB_ALT_BUFFER to 0 causes a screen reset instead.
* | winansi: allow test suite to run on WineRon Yorston2021-02-151-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Running the test suite on Wine failed because in seq 4 0 8 | head -n 10 'seq' didn't detect the broken pipe when 'head' terminated and carried on forever. Fix this by adding a call to ferror(3) in winansi_vfprintf(). Also, use xstrdup() and xmalloc() in a couple of places.