summaryrefslogtreecommitdiff
path: root/win32 (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* win32: make location of Unix-style absolute paths configurableRon Yorston2020-08-311-1/+1
| | | | | | | | | | | | | | | | | Previously busybox-w32 was enhanced so certain Unix-style absolute paths of the form '/dir/file' were treated as being relative to the system drive. (Notionally as reported by %SYSTEMDRIVE% but in fact derived from the API call GetSystemDirectory().) Make the location of such files configurable by the BB_SYSTEMROOT environment variable. - BB_SYSTEMROOT should probably only refer to a Windows-style absolute path, but this isn't checked. - Set BB_SYSTEMROOT using the Windows Control Panel or setx, not as a shell variable: the shell itself won't see the environment variable.
* ash, ls: improve support for 'c:path'Ron Yorston2020-08-281-15/+0
| | | | | | | | | | Revert commit 249f68e3c (win32: append '/' to bare drive name in opendir). Instead add better handling for paths of the form 'c:path' to ls and expmeta() in ash. Adds 64 bytes.
* win32: code shrink Unix-style path handlingRon Yorston2020-08-232-42/+16
| | | | | | | | 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.
* win32: allow putenv() to set empty valuesRon Yorston2020-08-211-4/+18
| | | | | | | | | | | | | | | | WIN32 _putenv() can't set an environment variable with an empty value because 'NAME=' is treated as a request to delete the variable. Allow mingw_putenv() to set an empty value by first setting a fake value and then truncating it. This problem has always been present in mingw_putenv() but it became particularly pressing when ash started treating all applets as NOEXEC. The environment of NOEXEC applets is created by clearing the current environment and using putenv() to set a new one from the shell variables. Empty variable were not being set. See GitHub issue #197.
* win32: env.c code shrink and clarificationRon Yorston2020-08-211-7/+6
| | | | | | | | Use xasprintf() to create string in unsetenv(). Clarify when we're using WIN32 _putenv(). No change in functionality; saves 16 bytes.
* win32: use built-in applets for non-existent binaries with Unix-style pathsRon Yorston2020-08-132-2/+26
| | | | | | | | | | | | | | | | | | | | Shell scripts moved from Unix may contain hard-coded paths to binaries such as /bin/sh. A recent commit made it possible to execute such binaries reliably, but that does require them to be installed. As an alternative solution: if a binary with a standard Unix path prefix can't be found but is available as a built-in applet, run the applet. Add the function unix_path() to detect paths starting with /bin, /usr/bin, /sbin or /usr/sbin. Use this function in: - the 'which' applet - shellexec(), describe_command() and find_command() in ash - mingw_spawn_1() See GitHub issue #195.
* win32: handle Unix-style absolute paths for executablesRon Yorston2020-08-132-1/+25
| | | | | | | | | | | | | | | | | | | | | | 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.
* win32: use a static buffer in get_system_drive()Ron Yorston2020-08-131-14/+13
| | | | | | | Allocate static storage for the system drive string instead of making a new allocation on every call. This is easier to manage. Adds 16 bytes.
* win32: code shrinkRon Yorston2020-08-132-1/+9
| | | | | | | | | | Add a new function, has_path(), to detect that an executable name doesn't require a path look-up. Also, since is_absolute_path() is now only used in shell/ash.c move its definition there from include/mingw.h. Saves 128 bytes.
* win32: move code to fork (de)compressor to a functionRon Yorston2020-08-051-0/+22
| | | | | | | | Use a new common function, mingw_fork_compressor(), to implement fork_transformer() in open_transformer.c and vfork_compressor() in tar.c. Saves 160 bytes.
* win32: update strptime(3) implementationRon Yorston2020-08-031-12/+19
| | | | | | | | | | Update to latest code from gnulib. This adds a '%q' (quarter) field descriptor. Remove the 'neg' variable from the code to handle the '%z' (timezone) field descriptor. Since our struct tm lacks a tm_gmtoff member '%z' is only supported "for reasons of symmetry". Since the computed value is never used there's no need to negate it.
* win32: code shrink kill(2)Ron Yorston2020-07-251-31/+17
| | | | | | | | - Drop exit_code argument from kill_SIGTERM_by_handle() - Pass signal number rather than exit code to other functions - Merge kill_SIGKILL() and kill_SIGTEST() Saves 112 bytes.
* win32: update link to Microsoft document on command-line argumentsRon Yorston2020-07-211-1/+1
|
* win32: import strndup from gnulibRon Yorston2020-07-092-0/+37
|
* win32: return raw file attributes in struct mingw_statRon Yorston2020-07-091-0/+4
| | | | | | Until now the emulated stat(2) system calls have only returned a synthesised Unix-style mode value. Also return the raw Windows file attributes.
* ash: improve handling of UNC pathsRon Yorston2020-06-301-1/+2
| | | | | | | | | | | | | | Be more strict about identifying UNC paths in unc_root_len(). In updatepwd() in ash: - Skip duplicate leading slashes unless the directory is a UNC path. - Rewrite detection and handling of the five possible types of path. This improves cases like 'cd ///' and 'cd /xyz' when the current directory is a UNC path. See GitHub issue #192.
* win32: enable globbing by defaultRon Yorston2020-06-141-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.)
* win32: minor improvements to process spawningRon Yorston2020-06-121-3/+2
| | | | | | | | | | | | | | The function mingw_spawn_forkshell() was introduced to handle spawning a forkshell process. Since we know that: - the binary being executed doesn't meet any of the special cases handled by spawnveq() - the arguments don't require quoting we can call spawnve() directly instead of spawnveq(). Also, use xzalloc() to allocate new_argv so we don't need to set the final NULL pointer explicitly.
* winansi: suppress console flags redefinition warningBiswa962020-06-071-0/+5
| | | | Modern versions of MinGW-w64 define more console modes.
* time: detect when spawn failsRon Yorston2020-06-041-1/+1
| | | | | | | In the 64-bit build the time applet reported garbage when it was unable to run the program to be timed. The error return from mingw_spawn_pid() was incorrect.
* win32: fix networking problemsRon Yorston2020-06-031-2/+4
| | | | | | | | | The subprocess that handles incoming connections for httpd didn't work. It has an accepted connection on stdin and calls getpeername() to obtain its details, but getpeername() didn't initialise networking. ssl_client only seems to deal with file descriptors. Expose init_winsock() again and call it from ssl_client.
* win32: use lazy loading for certain DLLsRon Yorston2020-06-023-22/+36
| | | | | | | | | Only a handful of functions are used from shell32.dll, userenv.dll and psapi.dll. Mostly these functions are in out of the way places. By loading the functions only when required we can avoid the startup cost of linking the three DLLs in the common case that they aren't needed.
* win32: only initialise networking if necessaryRon Yorston2020-06-011-5/+36
| | | | | | 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: simplify spawning during forkshellRon Yorston2020-06-011-0/+9
| | | | | | | | | | | | | spawn_forkshell() uses mingw_spawn_proc() to start the child shell. mingw_spawn_proc() then calls mingw_spawn_1() which determines that "sh" is an applet, thus calling mingw_spawn_applet() which finally calls spawnveq(). Not only is this convoluted it also won't work if PREFER_APPLETS and SH_STANDALONE aren't enabled. Simplify matters by adding a new function, mingw_spawn_forkshell(), which is tailored for just this case.
* win32: changes to '#!' supportRon Yorston2020-05-241-10/+12
| | | | | | | | | | | | | Since the earliest days of busybox-w32 '#!' has searched PATH for the interpreter. This doesn't seem to be supported by precedent. In testing I also found that additional code was needed for the case where PATH has been altered in the current shell or is modified on the command line: PATH has to be extracted from envp rather than getenv("PATH"). Drop this non-standard feature. *NIX implementations disagree on whether the interpreter can itself be a script. Follow Linux and allow this with a limit of four levels of nesting.