summaryrefslogtreecommitdiff
path: root/win32 (follow)
Commit message (Collapse)AuthorAgeFilesLines
* win32: rmdir(2) shouldn't delete symlinksFRP-4487-gd239d2d52Ron Yorston2021-10-171-1/+8
| | | | | | | | On Linux rmdir(2) refuses to delete a symlink to a directory on the obvious grounds that a symlink isn't a directory. Windows' rmdir() is less discriminating. Make our implementation of rmdir(2) behave more like Linux.
* win32: code shrinkRon Yorston2021-10-161-9/+16
| | | | | | | | | There are a few places in mingw.c where we want to determine if a file is a symbolic link. Previously these called mingw_lstat() which collects far more information than is actually needed. Create a new is_symlink() function which does the minimum work necessary.
* realpath: improved support for Windows pathsRon Yorston2021-10-131-3/+2
| | | | | | | | | | | | | | | | 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: fix creation of relative symlinksRon Yorston2021-10-121-2/+5
| | | | | | | | Symlinks containing '.' or '..' (such as '../target', './target' or 'dir/./target') were successfully created but couldn't be accessed. It turns out Windows requires paths of that form to use backslashes rather than forward slashes.
* win32: rename is_absolute_path()Ron Yorston2021-10-121-8/+8
| | | | | As the comment pointed out is_absolute_path() was misnamed. Rename it to is_relative_path() and change the sense of all tests.
* win32: use is_dir_sep() everywhereRon Yorston2021-10-121-4/+3
| | | | | The is_dir_sep() macro, which has been around since the start of busybox-w32, can be used instead of is_path_sep().
* ash: improve signal handlingRon Yorston2021-09-211-0/+9
| | | | | | | | | | | | 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: limited version of timegm(3)Ron Yorston2021-09-181-84/+13
| | | | | | | | | | | | | timegm(3) from musl checks that the calculated time_t value can be broken out into a struct tm without overflow. The limiting factor is that tm_year is an int. Our only use of timegm(3) is followed by a call to localtime(3). The Microsoft version of this only works for time_t values between 0 and INT_MAX (32-bit) or 0 and 32535215999 (64-bit). Enforce these limits in timegm(3), thus avoiding the use of musl's __secs_to_tm() and saving 624 bytes.
* win32: don't affect POSIX buildRon Yorston2021-09-171-1/+1
|
* win32: changes to allow timezones in datesRon Yorston2021-09-173-5/+238
| | | | | | | | | | | | | | 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: use inet_pton() from muslRon Yorston2021-09-031-183/+75
| | | | Saves 88 bytes.
* win32: fix entropy collection for isaacRon Yorston2021-09-021-20/+10
| | | | | | | | | The condition to detect the end of the environment string was wrong. Don't bother calculating the MD5SUM of the environment, just XOR the bytes into the data. This reduces bloat by 320 bytes but only in the non-default case.
* win32: code shrinkRon Yorston2021-08-271-0/+2
| | | | | | | | Turn off the 'if-conversion' optimisation for err_win_to_posix(). My tests actually have this being slightly faster than with the optimisation enabled, though within the variation of the measurement. Saves 288 bytes.
* win32: code shrink uname(2)Ron Yorston2021-08-161-8/+4
| | | | | | | If GetVersionEx() fails just assume the OS version numbers remain set to zero and print them as-is. Saves 48 bytes.
* win32: implement utimes(2) using utimensat(2)Ron Yorston2021-08-151-38/+18
| | | | Saves 176 bytes.
* win32: tidy up fetching of system directoryRon Yorston2021-08-141-14/+17
| | | | | | | | | | | | Add a new function, getsysdir(), to fetch and cache the system directory. This avoids the non-intuitive use of getpwuid() in get_system_drive(). The call to GetSystemDirectory() in get_proc_addr() can't be replaced because getsysdir() calls realpath() which requires a call to get_proc_addr(). No change in the size of the binary.
* win32: code shrinkRon Yorston2021-08-141-14/+14
| | | | | | | | | There doesn't seem to be any need to call OpenThreadToken() in file_owner(): OpenProcessToken() should suffice. Also, tidy up gethomedir() without any change in functionality. Saves 56 bytes.
* win32: treat devices as character special filesRon Yorston2021-08-131-1/+3
| | | | | | | | | | | | | Commit 15fcbd19c (win32: special case for devices files in stat(2)) added special treatment in stat(2) for device files. As a result of this change device files appeared to be regular files which broke the use of /dev/null with noclobber in the shell. Device files now appear as character special files (as they do on Unix). GitHub issue #225.
* win32: better handling of nested symlinksRon Yorston2021-08-121-0/+8
| | | | | | | | | | | | | | 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: code shrink character class detectionRon Yorston2021-08-095-18/+83
| | | | | | | Add a routine to detect the names of character classes. Use it in fnmatch(3) and regcomp(3), replacing local code in the former. Saves 216 bytes.
* win32: fix fnmatch(3) handling of xdigitRon Yorston2021-08-091-1/+1
| | | | | | | | | | | | | | | | The glob pattern '[[:xdigit::]]*' didn't return the matches expected. It turns out the implementation (from glibc) fails to detect 'xdigit' as a valid character class. Changing the definition of CHAR_CLASS_MAX_LENGTH to 7 fixes the problem. This was never an issue in glibc because it uses a different definition. More modern versions of fnmatch(3) in glibc and gnulib also make CHAR_CLASS_MAX_LENGTH long enough. The code for fnmatch(3) was taken from glibc at commit 7814856974388a856a575fa45f88d502c8a1ab29. This was the last version before the code was rearraged to better support multibyte characters.
* win32: tidy up time conversionsRon Yorston2021-08-091-7/+3
| | | | | | | Remove filetime_to_time_t(): it's no longer used. Align style of time{spec,val}_to_filetime() to make it easier to compare what they do.
* win32: code shrinkRon Yorston2021-08-083-12/+11
| | | | | | | | | Save a few bytes: - When collecting entropy prefer functions we call elsewhere. - In uname(2) set 32-bit processor type to i686 and tweak it for i386.
* win32: improved keycode detectionRon Yorston2021-08-061-42/+33
| | | | | | | | | | | | | | In read_keys(): - Identify all keys on the numeric pad used to enter character codes. Otherwise Alt-Left/Alt-Right on the numeric pad are treated as word movements in command line editing, preventing the entry of character codes containing 4 or 6. - Add modifier flag bits to the virtual keycodes we care about. This means, for example, that only the unmodified Up/Down arrow keys move through shell history, not Up/Down plus arbitrary modifiers.
* win32: code shrink read_key()Ron Yorston2021-08-061-11/+5
| | | | No change in functionality. Saves 16 bytes.
* 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.