aboutsummaryrefslogtreecommitdiff
path: root/include/mingw.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* which,ash: changes to which/command/typeRon Yorston2022-05-011-0/+1
| | | | | | | | | | | | | | | | | | | Change how 'which' detects if it was run from a standalone shell: the shell passes the undocumented '-s' option. This is stricter and more reliable than the previous method of checking the name of the binary. Add a function to determine the binary associated with a given applet name. This makes it possible for 'which' and 'command -v' to list the correct binary even for applets other than 'busybox'. For example, when the binary is called 'sh.exe' 'which sh' will report its path. In standalone shell mode 'command -V' and 'type' now report "xxx is a builtin applet" rather than "xxx is xxx", which is true but not very illuminating. (GitHub issue #248)
* date: enable FEATURE_DATE_NANORon Yorston2022-04-221-0/+1
| | | | | | | | | Provide a WIN32 implementation of clock_gettime(2), though only with support for CLOCK_REALTIME. This makes it possible to enable FEATURE_DATE_NANO which adds support for the %N date format. MinGW-w64 has clock_gettime(2) but it's in the winpthreads library and we don't want to bother with that.
* realpath: improved support for Windows pathsRon Yorston2021-10-131-0/+3
| | | | | | | | | | | | | | | | Upstream commit 94eb1c4dc (libbb: better coreutils compatibility for realpath) made some changes to xmalloc_realpath_coreutils(). This now needs to be updated to handle Windows paths. - Expose the macro is_unc_path() and part of the recent change to bb_get_last_path_component_nostrip() as a separate funtion, get_last_slash(); - Convert a couple of errors relating to network filesystems to ENOENT; - Adjust xmalloc_realpath_coreutils() to handle Windows directory separators, relative paths and UNC paths.
* win32: rename is_absolute_path()Ron Yorston2021-10-121-1/+1
| | | | | As the comment pointed out is_absolute_path() was misnamed. Rename it to is_relative_path() and change the sense of all tests.
* ash: improve signal handlingRon Yorston2021-09-211-0/+1
| | | | | | | | | | | | Allow waitpid() to detect SIGTERM/SIGKILL by checking the (Windows) status returned by GetExitCodeProcess() and updating the Unix status to suit. This allows ash to detect when a process has been 'signalled'. Provide our own implementation of strsignal(3) which returns expanded text for SIGTERM/SIGKILL. Costs 192 bytes.
* win32: changes to allow timezones in datesRon Yorston2021-09-171-0/+3
| | | | | | | | | | | | | | Create mingw_strptime() to return timezone offset as a separate argument (since Microsoft's struct tm doesn't have the required member). Import timegm() from musl. Update parse_datestr() to use mingw_strptime(). Enable FEATURE_TIMEZONE in the default configuration. GitHub issue #230.
* win32: better handling of nested symlinksRon Yorston2021-08-121-0/+3
| | | | | | | | | | | | | | Our realpath(3) implementation uses xmalloc_follow_symlinks() to expand symlinks. This detects when symlinks are too deeply nested but didn't set errno, so anything calling realpath(3) was unable to say what had gone wrong. (For example, 'ls -L' or 'stat -L'.) Set errno to ELOOP. This then leads to the problem that Windows doesn't know about ELOOP so reports 'Unknown error'. Add a replacement for strerror(3) which returns a sensible message. Costs 96 bytes.
* win32: partial implementation of sync(2)Ron Yorston2021-06-071-1/+2
| | | | | | | | | | 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.
* sync: enable in default configurationRon Yorston2021-06-071-1/+1
| | | | | Enable the sync applet by default. It doesn't actually do anything useful but at least it prevents some scripts from failing.
* win32: rename update_dev_fd() as update_special_fd()Ron Yorston2021-06-071-1/+1
| | | | Avoid confusion between special devices and /dev/fd.
* win32: implement futimens(2)/utimensat(2)Ron Yorston2021-05-141-0/+10
| | | | | The touch applet has been changed to use futimens(2)/utimensat(2). Provide implementations of these for WIN32.
* win32: move is_absolute_path()Ron Yorston2021-03-011-0/+1
| | | | | Make is_absolute_path() a function rather than a macro and move it from ash.c into mingw.c.
* win32: update sysinfo(2) implementationRon Yorston2021-02-191-2/+0
| | | | | | | | | | 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.
* free: implement sysinfo(2) and enable free(1)Ron Yorston2021-02-181-0/+22
| | | | | | | | | | | | | 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.
* ash: code shrinkRon Yorston2021-02-141-1/+0
| | | | | Since there's only one call to mingw_spawn_forkshell() we might as well just call spawnve() directly from ash.
* win32: implement symlink(2)Ron Yorston2021-02-121-1/+1
| | | | | | | | | | | | | | | | | | | | | 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: 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.
* win32: code shrinkRon Yorston2021-02-061-4/+0
| | | | | Don't compile some code that isn't currently supported for WIN32. Saves 24 bytes.
* tls: avoid unnecessary changes to POSIX build, part 2Ron Yorston2021-01-251-0/+4
| | | | | | | | | | | | | | 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.
* Merge branch 'busybox' into mergeRon Yorston2021-01-141-0/+1
|
* winansi: intercept calls to fputc(3)Ron Yorston2020-12-071-0/+2
| | | | | | | | | | | | | 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.
* ash, ls: improve support for 'c:path'Ron Yorston2020-08-281-6/+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-231-9/+1
| | | | | | | | 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: use built-in applets for non-existent binaries with Unix-style pathsRon Yorston2020-08-131-0/+1
| | | | | | | | | | | | | | | | | | | | 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-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | 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-131-1/+1
| | | | | | | | | | 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/+1
| | | | | | | | 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: code shrink kill(2)Ron Yorston2020-07-251-1/+1
| | | | | | | | - 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: import strndup from gnulibRon Yorston2020-07-091-0/+5
|
* win32: return raw file attributes in struct mingw_statRon Yorston2020-07-091-0/+1
| | | | | | Until now the emulated stat(2) system calls have only returned a synthesised Unix-style mode value. Also return the raw Windows file attributes.
* win32: fix networking problemsRon Yorston2020-06-031-0/+1
| | | | | | | | | 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: only initialise networking if necessaryRon Yorston2020-06-011-1/+7
| | | | | | 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/+1
| | | | | | | | | | | | | 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.
* dd: fix handling of 'conv=notrunc seek=N'Ron Yorston2020-05-201-1/+1
| | | | | | | | | | | | | | | | | | Commit e6680912a (dd: create a sparse file when seek=N is used) broke the use of 'conv=notrunc seek=N' to modify existing files. Rename seek_sparse() to make_sparse() and: - add an argument to specify the start of the sparse region; - call make_sparse() before ftruncate(); - call make_sparse() only if: * we can determine the size of the file; * the file is not open in append mode; * the file is being extended. This should fix GitHub issue #186.
* ash: reset ANSI emulation when BB_SKIP_ANSI_EMULATION changesRon Yorston2020-04-131-0/+1
| | | | | Update the skip status on the first call to skip_ansi_emulation() and whenever the BB_SKIP_ANSI_EMULATION variable changes.
* time: WIN32 portRon Yorston2020-04-061-1/+2
| | | | | | | | Port the time applet to WIN32. This requires the implemntation of a replacement for wait3(2). Only elapsed, user and system times are supported, not the memory and i/o statistics reported by GNU time.
* win32: new functions: getpeername(2), mingw_spawn_detach()Ron Yorston2020-04-051-0/+3
| | | | | | | Implement getpeername(2). Add mingw_spawn_detach() to allow the spawned process to detach from the console.
* dd: create a sparse file when seek=N is usedRon Yorston2020-03-241-0/+1
| | | | | | | When the seek=N argument is used mark the file as sparse and set the range that is sparse. See https://stackoverflow.com/questions/4011508/how-to-create-a-sparse-file-on-ntfs
* win32: tidy up detection of device filesRon Yorston2020-02-161-1/+1
| | | | | | | Define NOT_DEVICE as -1 so the return value of index_in_strings() when no device name is matched is NOT_DEVICE. Make the logic in mingw_open() clearer.
* win32: code shrinkRon Yorston2020-02-131-1/+1
| | | | | Have bs_to_slash() return a pointer to its argument. This allows some calls to be chained, saving 32 bytes.
* date: code shrinkRon Yorston2020-02-111-1/+0
| | | | | | | Since we don't have a working clock_settime(2) there's no point in claiming to support the '-s' option. Saves 96 bytes
* Build fixesFRP-3329-gcf0fa4d13Ron Yorston2020-01-081-1/+1
| | | | | | - Update configuration files - Omit unnecessary libraries - Replace fake stime(2) with fake clock_settime(2)
* win32: allow nanosecond precision in file timesRon Yorston2019-08-161-16/+19
| | | | | | Modern Linux kernels use struct timespec to represent file times, thus allowing nanosecond precision. Update the WIN32 emulation of struct stat and stat(2) to do the same.
* win32: try to make working directory names consistentRon Yorston2019-04-021-0/+1
| | | | | | | | | | | | | | | Standardise the path names used for the current working directory by: - resolving with realpath(3); - making the drive name or host name uppercase. The first only really works for physical drives; results for mapped drives are patchy. The standardisation is applied in two places: - at the end of updatepwd() in ash; - when a symbolic link is resolved in mingw_chdir().
* win32: fix compilation error; update default configurationsRon Yorston2019-03-311-0/+1
|
* win32: improved support for c:path path namesRon Yorston2019-03-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Microsoft Windows permits path names of the form 'c:path', without a path separator after the colon. The system records a current directory for each drive and the path is interpreted relative to that. Since Windows API calls understand 'c:path' path names many commands in busybox-w32 already work with them. This commit adds the following: - The 'cd' shell built-in interprets 'c:path' path names correctly. Previously it treated them as relative to the shell's concept of the current working directory, not the current directory of the specified drive. - The 'pwd' shell built-in takes the '-a' option to list the current directory for all drives. - 'c:path' path names are subject to tab-completion. Paths of the form 'c:path' don't work for mapped network drives or paths that have been associated with a drive using SUBST. See GitHub issue #147.
* win32: interpret absolute paths as relative to %SYSTEMDRIVE%Ron Yorston2019-03-281-0/+3
| | | | | | | | | | | | | | | | | | | | | | BusyBox contains hardcoded references to absolute paths which are unique in the *nix world but on Microsoft Windows are interpreted as being on the current drive. To make these unique again consider them to be relative to %SYSTEMDRIVE%. Support this by adding functions to: - determine the system drive (not using the environment variable); - change a process's current directory to the root of the system drive; - make relative paths absolute before changing directory (if needed). The following applications have been modified: - ash references /etc/profile from the system drive; - dpkg places its data store on and installs files to the system drive; - rpm installs files to the system drive; - man looks for configuration files and man pages on the system drive. See GitHub issue #158.
* win32: share code to find root prefix of pathRon Yorston2019-03-231-0/+3
| | | | | | | Move unc_root_len() from ash to mingw32.c and use it in the new function root_len(), which can be used in make_directory(). This reduces changes to upstream code and saves a few bytes.
* win32: add function to convert slashes to backslashesRon Yorston2019-03-151-1/+2
| | | | | | | | | There are now two places where slashes are converted to backslashes throughout a string so it makes sense to create a function to do this. To avoid confusion rename convert_slashes() to bs_to_slash() and call the new function slash_to_bs().