aboutsummaryrefslogtreecommitdiff
path: root/win32 (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* win32: better detection of Alt key releaseRon Yorston2021-08-021-1/+2
| | | | | | | | | | | | | | Commit 7874ca73b (win32: allow characters to be entered as ALTNNN) made it possible to enter characters using Alt and a character code on the numeric pad. This required detecting the release of the Alt key. Sometimes this caused a problem when using Alt+Tab to cycle between applications. If Alt was released before Tab the code passed a tab character to the application. Avoid such issues by looking specifically for the release of the Alt key.
* win32: code shrink using is_prefixed_with()Ron Yorston2021-07-281-16/+18
| | | | | | | Use is_prefixed_with() rather than strncmp() in a few places, and the case-insensitive analogues. Saves 96 bytes in 64-bit build, 192 bytes in 32-bit.
* win32: code shrink has_exec_format()Ron Yorston2021-07-281-13/+11
| | | | | | | | | | | | | | In the code to detect binaries: - use '|' rather than '+' to combine bytes; - fix the test that the PE header is within the buffer; - once we have the offset to the PE header make a pointer to it; - cosmetic changes. Saves 96 bytes.
* win32: special case for devices files in stat(2)Ron Yorston2021-07-251-5/+20
| | | | | | | | | | | | | | | | | | | | | | The diff applet calls stat(2) on the files it's asked to process. This includes /dev/null when the -N flag is used and /dev/fd/* files when process substitution is used. Treat device files as a special case in get_file_attr(), returning a fake set of attributes with FILE_ATTRIBUTE_DEVICE set. This value is unused elsewhere in busybox-w32. Ensure it's unset in other cases. When FILE_ATTRIBUTE_DEVICE is set: - adjust some permissions; - avoid calling has_exec_format() as this opens/closes the file which breaks process substitution. These changes improve the behaviour of diff but they also have other effects. For example, the stat and ls applets now report details of device files. There may be unintended consequences.
* tar: use external program for lzma/xz compressionRon Yorston2021-07-221-3/+9
| | | | | | | | | The lzma and xz applets don't support compression. Any attempt to generate a tar file using these compressors should try to use an external program. (Which probably won't work on a typical Windows system, but hey, at least we made the effort.) See GitHub issue #222.
* mingw: update select(2) to latest gnulib versionRon Yorston2021-07-171-18/+36
|
* winansi: add missing va_end()Ron Yorston2021-07-111-0/+1
|
* win32: changes to mntent implementationRon Yorston2021-06-272-49/+69
| | | | | | | | | | | | | | | | Make the structure returned by getmntent(3) static so it persists after endmntent(3) closes the stream. No current caller in the WIN32 port needs this functionality but it's good to match the documented behaviour. Populate more fields of the mntent structure in find_mount_point(). This is required to support the df -t and -T flags recently added upstream. The static structures used here are allocated on demand. Separate static structures are used in each case because df iterates through mounts calling statfs(2) on each and the WIN32 implementation of statfs(2) calls find_mount_point().
* win32: handle -1 return status from execve(2)Ron Yorston2021-06-191-2/+3
| | | | | | | | The implementations of execve(2) and execvp(3) were unable to distinguish between failure and a program returning a status of -1. Check the error return code to discriminate between these cases. See GitHub issue #218.
* win32: add local dirent implementationRon Yorston2021-06-133-0/+116
| | | | | | | | | | | | Add a cut down version of the dirent implementation from git. The git developers said: The mingw-runtime implemenation of opendir, readdir and closedir sets errno to 0 on success, something that POSIX explicitly forbids. This also avoids having to link against libssp.a (commit 13eb34205) and reduces the size of the binary by 2KB.
* win32: partial implementation of sync(2)Ron Yorston2021-06-071-0/+23
| | | | | | | | | | Provide a partial implementation of sync(2), so sync(1) can actually do something in some circumstances: - Only logical drives are handled. - Flushing buffers requires administrative privileges. If run as a normal user nothing will happen.
* win32: let virtual /dev/fd/<num> files be openedRon Yorston2021-06-071-0/+20
| | | | Add support for virtual /dev/fd files to represent file descriptors.
* win32: rename update_dev_fd() as update_special_fd()Ron Yorston2021-06-071-2/+2
| | | | Avoid confusion between special devices and /dev/fd.
* win32: implement futimens(2)/utimensat(2)Ron Yorston2021-05-141-1/+81
| | | | | The touch applet has been changed to use futimens(2)/utimensat(2). Provide implementations of these for WIN32.
* win32: fix creation of symlinks in 64-bit Windows 7Ron Yorston2021-05-131-1/+1
| | | | | | | | The 64-bit build of busybox-w32 failed to create symbolic links on Windows 7 but claimed to have succeeded. The declaration of CreateSymbolicLinkA had the wrong return value. See GitHub issue #217.
* winansi: fix ansi emulationRon Yorston2021-03-051-12/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | The following commands (reported in GitHub issue #201): printf "\033[38;2;255;0;0mX\033[m\n" printf "\033[38;2;255;0;0m;\033[m\n" produce different results. The first correctly displays a red 'X' while the second incorrectly displays a white ';'. The problem is that process_24bit() overruns the extent of the escape sequence. As a result the loop in process_escape() which handles 'ESC[...m' sequences sees the ';' in the text as a continuation of the escape sequence. Fix this by: - reworking process_24bit() so that the overrun is avoided; - changing the test in the loop in process_escape() so that even if an overrun happens it stops processing at the end of the escape sequence. Also, save a few bytes by replacing '++str' with 'str + 1' in a few places.
* libbb: fix detection of relative paths in xreadlink.csymlinkRon Yorston2021-03-011-1/+1
| | | | | | 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>
* 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-011-0/+9
| | | | | 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.
* 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.
* 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-211-3/+1
| | | | | | | | | | | | | 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-191-13/+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-191-3/+2
| | | | | | | | | | 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-181-0/+24
| | | | | | | | | | | | | 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.
* 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.
* 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.
* ash: code shrinkRon Yorston2021-02-141-9/+0
| | | | | Since there's only one call to mingw_spawn_forkshell() we might as well just call spawnve() directly from ash.
* win32: code shrinkRon Yorston2021-02-131-1/+1
| | | | | | | | Rewrite the recent change to tab completion so it only needs one call to sprintf. Then replace sprintf with strcpy/stpcpy, both there and in a couple of other places. Saves 40 bytes.
* win32: implement symlink(2)Ron Yorston2021-02-121-0/+35
| | | | | | | | | | | | | | | | | | | | | Provide an implementation of symlink(2). Calls to symlink(2) will fail in default Windows installations unless running with elevated privileges. Failure to create a symlink when extracting files from an archive is therefore treated as a non-fatal error. There are two ways to permit the creation of symlinks: - Edit security policy to give users the 'Create symbolic links' privilege. Unfortunately this doesn't work for users who are an Administrator. - Enable developer mode, which is available in later versions of Windows 10. The ability to create symlinks is not available in Windows XP or ReactOS.
* win32: allow symlinks to directories to be unlinkedRon Yorston2021-02-121-1/+13
| | | | | | Windows distinguishes between symlinks to directories and files. A symlink to a directory must be deleted by calling rmdir(2) rather than unlink(2).
* win32: make readlink(2) implementation unconditionalRon Yorston2021-02-121-4/+0
| | | | | | | There doesn't seem to be much advantage in having readlink(2) as a configuration option. Making it unconditional reduces divergence from upstream and allows the removal of a check for ENOSYS that's been in busybox-w32 since the start.
* winansi: code shrinkRon Yorston2021-02-081-13/+13
| | | | | | Mark floating-point constants as being of type 'float'. Saves 72 bytes.
* winansi: more accurate colour mappingRon Yorston2021-02-071-20/+99
| | | | | | Use a more accurate technique to map RGB colours to standard Windows console colours. Since this costs 648 bytes it's configurable but is enabled by default.
* winansi: code shrinkRon Yorston2021-02-071-90/+71
| | | | | | | | | | | | | | | | | | | Refactor handling of ESC[38...m and ESC[48...m: - At lower levels deal only with the standard console foreground colours. This makes handling of foreground and background colours more similar. - Many '|=' assignments (to combine attribute values) have been replaced by simple assinments. - Use a common routine to convert RGB to console colours; colours in the 8-bit 6x6x6 cube are scaled up to make use of this. - Detect invalid escape sequences to avoid setting incorrect colour values. Saves 296 bytes.
* winansi: tweak colour mappingRon Yorston2021-02-041-19/+9
|
* winansi: extend ANSI emulationRon Yorston2021-02-031-49/+177
| | | | | | | | | | | | | | | | Extend ANSI emulation to include: ESC[38;2;R;G;Bm 24-bit foreground colour ESC[48;2;R;G;Bm 24-bit background colour ESC[38;5;Nm 8-bit foreground colour ESC[48;5;Nm 8-bit background colour The colours are selected from the 16 standard console colours. This is unlikely to be aesthetically pleasing but at least it's better than raw escape sequences. Also, add ESC[9m (strike through) as a known but unsupported sequence.
* winansi: change default 'skip ANSI emulation' settingRon Yorston2021-02-031-13/+3
| | | | | | | | | Change the default 'skip ANSI emulation' setting which is used when the environment variable BB_SKIP_ANSI_EMULATION is unset. Previously it was 0 (always emulate) now it's 2 (detect whether or not the terminal supports ANSI escape sequences and behave accordingly). The default value is also now a build-time option.
* tls: avoid unnecessary changes to POSIX build, part 2Ron Yorston2021-01-251-0/+9
| | | | | | | | | | | | | | On reflection, the previous commit may have been ill-advised. There are many calls to open_read_close() and most shouldn't be able to access special devices. (Though in practice only a few are enabled in busybox-w32.) Nonetheless, I've implemented a new mechanism which uses the macro MINGW_SPECIAL() to mark calls to functions that are allowed to access special devices. An unrelated change is to avoid compiling fputs_stdout() in coreutils/printf.c for the POSIX build.
* Update copyright messageRon Yorston2021-01-131-1/+1
| | | | Hey, look! It's 2021 already.
* win32: handle various Alt key modifiers in termiosChristopher Wellons2021-01-131-2/+16
| | | | | | | | | | This patch restores support for Bash-stle Alt commands present in the original BusyBox: * Alt-b, Alt-LeftArrow backward word * Alt-f, Alt-RightArrow forward word * Alt-BackSpace delete word backward * Alt-d delete word forward
* win32: make realpath() return an error if necessaryRon Yorston2020-12-121-1/+0
| | | | | | | | | | | | resolve_symlinks() uses GetFinalPathNameByHandleA which is loaded at runtime because it isn't available in all versions of Windows. If GetFinalPathNameByHandleA isn't available resolve_symlinks() (and hence realpath()) should return a NULL pointer to indicate an error, not the original path. Not returning NULL causes an infinite loop in do_lstat(). See GitHub issue #204.
* winansi: intercept calls to fputc(3)Ron Yorston2020-12-071-1/+19
| | | | | | | | | | | | | Perform code page translation for fputc(3). It's only used in a few places but is needed to fix things like: $ echo € | dos2unix Ç $ paste -d € file1 file2 1Ç2 Unfortunately it breaks the inventive use of dos2unix in GitHub issue #203.