aboutsummaryrefslogtreecommitdiff
path: root/win32 (follow)
Commit message (Collapse)AuthorAgeFilesLines
* uname: Check for PROCESSOR_ARCHITECTURE_ARM as wellHEADmasterMartin Storsjö2025-12-081-0/+5
| | | | Return "armv7" in this case.
* win32: add a config for 32-bit build with UnicodeRon Yorston2025-12-021-2/+3
| | | | | | | | | | | | | | | | | | | Now that a binary with a UTF-8 manifest can run on Windows XP it's possible to configure a build which supports Unicode on Windows 10+ but which still runs on legacy systems. - Add the config file mingw32w_defconfig. This is a 32-bit build with the UTF-8 manifest which also runs on legacy systems. - A new config option, FEATURE_FAIL_IF_UTF8_MANIFEST_UNSUPPORTED, allows the check for legacy systems to be skipped. - An incompatibility with Windows XP in writeCon_utf8() has been fixed. See this GitHub issue for details: https://github.com/skeeto/w64devkit/issues/315
* win32: update UTF-8 manifestRon Yorston2025-12-011-5/+5
| | | | | | | | | | | | | | It seems that the UTF-8 manifest can be adjusted to avoid binaries failing to run on Windows XP. Make the necessary adjustment. This doesn't affect the legacy builds, only those with Unicode enabled. Nor does it change the code which prevents Unicode builds from running on platforms that don't support the manifest. See this GitHub issue for details: https://github.com/skeeto/w64devkit/issues/315
* win32: avoid failure when localtime() argument is out of rangeRon Yorston2025-11-261-1/+16
| | | | | | | | | | | | | | | | | | | | The implementation of localtime(3) in the Microsoft Windows runtime only accepts arguments between the Unix epoch (1970) and either 2038 or 3000 for 32-bit or 64-bit systems respectively. For values outside those limits it returns a NULL pointer. Unfortunately, upstream BusyBox hardly ever bothers to check the return value. Thus, when a call to stat(2) returned an all-zero FILETIME for a file, the 'stat' applet failed. An all-zero FILETIME represents a date in 1600, which is clearly before the Unix epoch. Add a wrapper to localtime(3) which detects an out-of-range value and returns a valid 'struct tm' for the Unix epoch. This is easier than adding checks on the return value of every call to localtime(3). Adds 32-48 bytes. (GitHub issue #548)
* mkdir: correctly report directory creationRon Yorston2025-11-221-2/+1
| | | | | | | | | | | | | | | | | | | | | | | It was found that 'mkdir -p --verbose C:/' incorrectly reported that 'C:/' was created. Commit 0e0b5e9ff8 (mingw.c: ignore EACCES from mkdir if directory exists) fixed a failure to create directories but caused the `mkdir` applet to issue the wrong diagnostic. The underlying problem is in the Windows runtime implementation of _mkdir(): it can return the wrong errno in some cases, EACCES instead of EEXIST. Having the mkdir(2) wrapper return the correct errno should fix both the directory creation and verbose diagnostic problems. The website referenced in the previous commit is no longer available. archive.org has a copy: https://web.archive.org/web/20150224075238/http://www.apijunkie.com/APIJunkie/blog/post/2009/12/22/_mkdir-C-runtime-library-function-might-return-unexpected-error-values.aspx (GitHub issue #546)
* win32: allow use of /dev/ttyRon Yorston2025-11-101-9/+14
| | | | | | | | | Treat /dev/tty as an alias for Windows' 'con' device. The code is similar to that used for /dev/null. Adds 24-48 bytes. (GitHub issue #538)
* compress PNG icons moreViktor Szakats2025-11-072-0/+0
| | | | | aterm.png: 2477 -> 2303 (-174 bytes) sterm.png: 1022 -> 774 (-248 bytes)
* win32: allow the use of PNG format iconsRon Yorston2025-11-064-0/+8
| | | | | | | | | | | Convert the icons to PNG format (by simply exporting them from GIMP and selecting the 'Compressed (PNG)' chackbox). Allow these to be selected instead of ICO format at build time. Use the PNG icons by default in the Unicode and aarch64 builds. Saves 26KB in those cases. (GitHub PR #540)
* manifest: integrate into resources.rc, reduce binary sizeViktor Szakats2025-11-064-58/+50
| | | | | | | | | | It also makes the version number within the manifest use the version macros, replacing the hard-coded "6.0.0.0". Unicode: 32668 -> 32188 (-480 bytes) non-Unicode: 32412 -> 31956 (-456 bytes) with icons included.
* stty: drop 'rows' and 'columns' settingsFRP-5857-g3681e397fRon Yorston2025-10-101-2/+2
| | | | | | | | | Setting the console dimensions doesn't work reliably. Drop support for the 'rows' and 'columns' settings. Saves 752-768 bytes. (GitHub issue #58)
* flock: enable by defaultRon Yorston2025-10-092-0/+133
| | | | | | | | | Use the Gnulib implementation of flock(2) to allow the flock applet to be enabled. Costs 900-984 bytes. (GitHub issue #528)
* win32: use RtlGenRandom for /dev/urandomRon Yorston2025-10-094-253/+17
| | | | | | | | | Use the (somewhat ancient) Microsoft RtlGenRandom() function to provide random data for /dev/urandom. Saves 176-240 bytes. (GitHub issue #519)
* Allow building with older mingw-w64/gccRon Yorston2025-10-011-0/+4
| | | | | | | | | Recent versions of busybox-w32 rely on features which are only available in contemporary versions of mingw-w64 and gcc. Allow building on somewhat older toolchains. (GitHub issue #527)
* win32: use correct errno for fopen() of directoryRon Yorston2025-09-191-1/+6
| | | | | | | | | | We already fixed up errno when a directory was opened by open(). Do the same for fopen(). This allows grep to give a more useful error message when it's asked to open a directory. Adds 64 bytes. (GitHub issue #521)
* ash: redir: Retry open on EINTRRon Yorston2025-09-101-0/+1
| | | | | | Apply upstream commit 9b67dde8c. Adds 8 bytes in the 32-bit build.
* win32: fix return value of isatty()Ron Yorston2025-08-171-1/+1
| | | | | | | | | | | Changes to the ls applet upstream assumed that the return value of isatty() followed the C standard and would be 0 or 1. The wrapper for Windows' _isatty() didn't allow for it returning a non-zero value for a tty, not 1. This confused ls. Fix the wrapper. (GitHub issue #513)
* Merge branch 'busybox' into mergeRon Yorston2025-08-151-1/+2
|
* stty: fix build for Windows XPRon Yorston2025-08-071-0/+10
| | | | | | | | The ioctl() to get the size of the terminal windows used functions which weren't available on Windows XP. Load these dynamically to avoid failure. Adds 160 bytes.
* stty: enable a minimal Windows implementationRon Yorston2025-07-254-23/+73
| | | | | | | | | | | | | | | | Implement a minimal stty applet for Windows. - Display and set terminal rows and columns - Enable/disable raw/cooked mode - Enable/disable echo mode - Implement 'stty sane' to reset raw/cooked/echo Adds 2120-2304 bytes. (GitHub issue #58)
* win32: deduplicate die_if_error()Ron Yorston2025-07-111-0/+9
| | | | | | | There were two copies of the static function die_if_error(). Replace these with a single external function. Saves 16 bytes.
* win32: update implementation of select(2)Ron Yorston2025-05-261-2/+5
| | | | | | | | Apply gnulib commit 034af0e401 (select, pselect: Fix test failure on native Windows). * lib/select.c (rpl_select): Fail if nfds is out-of-range. * lib/pselect.c (pselect): Likewise.
* win32: update implementation of strptime(3)Ron Yorston2025-05-261-18/+18
| | | | Changes are mostly cosmetic.
* win32: update inet_pton(3) implementationRon Yorston2025-05-261-0/+1
| | | | | | | | | | | | | | | | | | | Apply musl commit 7e13e5ae (inet_pton: fix uninitialized memory use for IPv4-mapped IPv6 addresses). When a dot is encountered, the loop counter is incremented before exiting the loop, but the corresponding ip array element is left uninitialized, so the subsequent memmove (if "::" was seen) and the loop copying ip to the output buffer will operate on an uninitialized uint16_t. The uninitialized data never directly influences the control flow and is overwritten on successful return by the second half of the parsed IPv4 address. But it's better to fix this to avoid unexpected transformations by a sufficiently smart compiler and reports from UB-detection tools. Adds 16 bytes.
* win32: update glob(3) implementationRon Yorston2025-05-261-1/+1
| | | | | | | | | | | Apply musl commit 79bdacff (glob: fix wrong return code when aborting before any matches). when the result count was zero, glob was ignoring a possible GLOB_ABORTED error code and returning GLOB_NOMATCH. whether this happened could be nondeterministic and dependent on the order of dirent enumeration, in cases where multiple matches were present and only some produced errors.
* win32: fake directories in readdir(2)Ron Yorston2025-03-171-5/+23
| | | | | | | | | | | | | | The emulation of readdir(2) didn't include the '.' and '..' directories in the root of a logical drive. This resulted in the 'ls' applet (and others) not matching the expected Unix behaviour. Alter the emulation of readdir(2) to include fake '.' and '..' directories if necessary. Adds 88-112 bytes. (GitHub issue #487)
* win32: retry when command needs elevated privilegesRon Yorston2025-02-032-0/+64
| | | | | | | | | | | | | | Some installer programs have an entry in their manifest to indicate that they need elevated privileges. The shell in busybox-w32 was unable to run such programs. When a program fails to run with ERROR_ELEVATION_REQUIRED, try again using ShellExecuteEx() with the 'runas' verb to give it elevated privileges. Adds 272-288 bytes. (GitHub issue #481)
* win32: fix compilation with FEATURE_SH_NOFORK disabledRon Yorston2024-12-311-0/+2
| | | | | Compiling with FEATURE_SH_NOFORK disabled resulted in an error and a warning. Fixing these doesn't change the default build.
* win32: code shrink quote_arg()Ron Yorston2024-12-301-24/+20
| | | | | | | | Alter quote_arg() to perform a single pass over the string in the case where no change is required. Based on a proposal by @avih in GitHub PR #317. Saves 16 bytes.
* ash: strip trailing slash from directory if necessaryRon Yorston2024-12-291-0/+5
| | | | | | | | | | | The previous commit removed trailing dots and spaces from the last component of a pathname when changing directory. If the result has a trailing slash remove that too. But not if it's a drive root, to avoid 'cd C:/' showing a current directory of 'C:'. Adds 48 bytes. (GitHub issue #478)
* ash: match behaviour of cmd.exe in cd builtinRon Yorston2024-11-191-0/+13
| | | | | | | | | | | | | | The Windows API strips trailing dots and spaces from the last component of a path. cmd.exe handles this quirk when changing directory by adjusting its idea of the current directory to match reality. The shell in busybox-w32 didn't do this, leading to some confusion. Fix the shell's cd builtin so it works more like cmd.exe. Adds 64-80 bytes. (GitHub issue #478)
* win32: update poll(2) to match latest gnulib versionRon Yorston2024-10-251-5/+6
|
* win32: workaround for pipe writability in poll(2)Ron Yorston2024-10-251-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | A CGI script was found to hang when a large amount of data was posted: #!/bin/sh echo "Content-type: text/plain;" echo if [ "$REQUEST_METHOD" = "POST" ]; then dd of=my.dat bs=1 count=${CONTENT_LENGTH} echo -n "success." else echo -n "error!" fi This appears to be due to problems determining whether a pipe is writable on Windows. The Git for Windows project has a workaround in their copy of GNUlib's poll(2) implementation. The details are in the commit message: https://github.com/git-for-windows/git/commit/94f4d01932279c419844aa708bec31a26056bc6b Apply the same workaround here. Saves 220-272 bytes. (GitHub issue #468)
* win32: close exec'ing process if possibleRon Yorston2024-10-131-0/+3
| | | | | | | | | If a process performing an exec is an orphan there's no reason for it to wait for its child's exit code. Let it exit immediately. Adds 16 bytes. (GitHub issue #461)
* kill: fix regression in 'kill -9'Ron Yorston2024-10-121-6/+7
| | | | | | | | | | | | | | 'kill -9' was found to fail with an 'Invalid argument' error. This is a regression introduced by commit 569de936a (kill: killing a zombie process should fail). Use the correct argument to OpenProcess() for SIGKILL so it can query the exit code of the target process. Adds 16 bytes. (GitHub issue #465)
* win32: fix problem interrupting shell loopRon Yorston2024-10-111-11/+13
| | | | | | | | | | | | | | | | | It proved to be almost impossible to interrupt a loop like: while true; do sleep 1; done where 'sleep' was an external program, not an applet. The issue was introduced by commit 0475b7a64 (win32: convert exit codes). This passed a POSIX error code to the exit() in wait_for_child() so a parent was unable to detect when its child was interrupted. Pass the Windows exit code to exit() instead. Work around the changes introduced by commit 790e377273 (win32: revert 'don't set error mode'). Adds 16-32 bytes.
* win32: fix regression in chdir(2)Ron Yorston2024-10-101-7/+9
| | | | | | | | | | | | | When mingw_chdir() was introduced it canonicalised its argument (585d17d26). This had the side effect of making its case match that of the directory as stored on disk. Subsequent changes retained that behaviour for symlinks but not otherwise (69d328022, b99032390). This was noted to affect the appearance of the directory specified by the (undocumented) 'sh -d' option. Fix the case of non-symlink directories too. Adds 16-32 bytes.
* id: code shrinkRon Yorston2024-10-091-0/+2
| | | | | | | | The bogus user/group ids we use on Windows are very limited. Make these limitations explicit in the 'id' applet. Saves 464 bytes.
* Merge branch 'busybox' into mergeRon Yorston2024-10-081-1/+1
|
* win32: drop workaround for Wine console bufferRon Yorston2024-09-271-7/+0
| | | | | | | | | | | | | | Commit 1ade2225d2 (winansi: allow alternative screen buffer to be disabled) added a workaround for the broken alternative screen buffer in the Wine console. The problem has been fixed in Wine for well over a year: https://bugs.winehq.org/show_bug.cgi?id=54287 Remove the workaround. Saves 80-96 bytes.
* ash: optimise running of scriptsRon Yorston2024-08-191-8/+1
| | | | | | | | | | | | | | | | | | | | | | The BusyBox shell detects certain cases where forking a command is unnecessary (last command in a script or subshell, for example) and calls execve(2) instead. This doesn't help in the Windows port because execve(2) is implemented by creating a process. There is one case where it is possible to apply this optimisation: if the command is a script and the script interpreter is an applet. - Have evalcommand() pass a flag to indicate this situation to shellexec(). Also, allocate two spare elements before the start of the argv array. - If the flag is TRUE shellexec() passes the shell's PATH variable down to tryexec() so it can perform a test for applet override. - If tryexec() finds that all the necessary conditions apply it can run a script by directly invoking the interpreter's main(). Adds 192-224 bytes.
* win32: code shrinkRon Yorston2024-08-163-16/+16
| | | | | Add the FAST_FUNC qualifier to several Windows-specific functions. This has no effect in 64-bit builds but saves 336 bytes for 32-bit.
* win32: fix strftime(3) '%s' formatRon Yorston2024-08-141-1/+1
| | | | | | | | | | | | The '%s' format of our strftime(3) wrapper (display number of seconds since the Unix epoch) returned incorrect results on 64-bit systems for times more than 2^31 seconds after the epoch. Use the correct format. Adds 16 bytes. (GitHub issue #446)
* win32: fix another problem with stat(2)Ron Yorston2024-08-091-2/+3
| | | | | | | | | | | If we can't open a file to preserve its access time (perhaps because it doesn't belong to us) just try again without bothering about the access time. I thought I'd already done that, but that must have been in an alternative reality. Adds 16 bytes. (GitHub issue #443)
* su: detect inability to raise privilegeRon Yorston2024-08-031-22/+22
| | | | | | | | | | | | When privilege has been dropped by the 'drop' applet, the 'su' applet is unable to raise it again because ShellExecuteEx() thinks it unnecessary. Detect this situation, report an error and return exit code 2. Costs 72-112 bytes. (GitHub issue #437)
* win32: consolidate executable handling in popen.cRon Yorston2024-07-201-31/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | Commit f444dc586 (win32: only search PATH for compressor) made mingw_fork_compressor() perform a PATH lookup for the xz and lzma compression programs. This avoided relying on CreateProcess() to perform the search. Other callers of the pipe creation code should also avoid reliance on CreateProcess's executable search: - Move the applet test and PATH lookup into mingw_popen_internal(). The first argument to CreateProcess() will always be a path to an executable. - mingw_fork_compressor() uses the new "w+" mode to indicate that xz and lzma compressors should be found on PATH. - mingw_popen() no longer needs to check for an applet itself, as that's now handled in mingw_popen_internal(). - spawn_ssl_client() in 'wget' can rely on the popen code to look up the 'ssl_client' applet. - Remove unnecessary argument checks in mingw_popen_internal(). Adds 0-24 bytes.
* win32: code shrink popen(3)Ron Yorston2024-07-191-40/+13
| | | | | | | | | | | - Replace the half-baked code to quote the command passed to popen(3) with a call to quote_arg(). - Where the command to be run is a non-overridden applet in the current binary pass the path to the binary to CreateProcess() instead of adding '--busybox' to the command. Saves 128-136 bytes.
* win32: code shrink mingw_spawn_interpreter()Ron Yorston2024-07-141-11/+8
| | | | | | | Rewrite mingw_spawn_interpreter() to remove a duplicated recursive call. Saves 32-48 bytes.
* ash: read profile script relative to binaryRon Yorston2024-07-081-0/+8
| | | | | | | As well as trying to read '/etc/profile' also look for the script 'etc/profile' relative to the location of the running binary. Adds 64-96 bytes.
* win32: code shrink system drive handling (2)Ron Yorston2024-07-071-1/+1
| | | | | | Now that get_system_drive() no longer returns a NULL pointer on error chdir_system_drive() needs to check for an empty string instead.
* win32: code shrink system drive handlingRon Yorston2024-07-071-27/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | A previous commit (e3bfe3695) revised the use of getsysdir() to obtain the system directory, and hence the system drive. See the commit message for the history to that point. Further improvements are possible: - Remove getsysdir() and push the calls to GetSystemDirectory() down into get_system_drive() and get_proc_addr(). - Check the return value of GetSystemDirectory(). It's unlikely to fail, but better safe than sorry. - Instead of making all callers of get_system_drive() check for a NULL return value always return a non-NULL pointer. If the drive can't be found an empty string is returned instead (which is what the callers were using anyway). - The function need_system_drive() was only used in one place (in httpd). Move the code there and remove the function. - Use concat_path_file() where possible. Saves 76-144 bytes.