aboutsummaryrefslogtreecommitdiff
path: root/win32/mingw.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* busybox: add --uninstall optionRon Yorston2019-01-051-0/+39
| | | | | | | | | | | | | | | | | | Add an option to allow hard links to be removed. busybox --uninstall file removes all hard links to the given file (including the file itself.) Since Microsoft Windows refuses to delete a running executable a BusyBox binary is unable to remove links to itself. busybox --uninstall -n file displays the names of all hard links to the given file. Although this feature is couched in terms of uninstalling BusyBox it's actually quite general: it can be used to delete or display hard links to any file.
* win32: reduce static storage needed for lazy loadingRon Yorston2019-01-041-6/+4
| | | | | | Only the generic function pointer and initialisation flag need to be in static storage. The DLL and function names and the specialised function pointer can be local.
* win32: add support for %T to strftimeRon Yorston2018-12-161-21/+30
| | | | | | | | Add the %T format specifier (same as %H:%M:%S) to our emulation of strftime. Rewrite so that common code to replace a format specifier with a string is shared.
* win32: special treatment for files with the '.sh' extensionRon Yorston2018-12-091-9/+10
| | | | | | | | | | | | Files with the extension '.sh' are considered to be executable. Those that start with a '#!' line will be run using the specified interpreter. If no '#!' is present the script will be run by the shell. When searching for an executable the '.sh' extension will be tested in the same way as the standard extensions understood by spawnve(). '.sh' takes precedence over the standard extensions.
* win32: add a case-insensitive version of is_suffixed_with()Ron Yorston2018-12-091-2/+1
|
* win32: use open_read_close() where possibleRon Yorston2018-12-091-6/+2
|
* win32: (another) fix to file extension testRon Yorston2018-12-071-1/+1
| | | | | | | It turns out '.bat' is a valid batch file name. Reduce the permitted length for filenames to allow for this. Also, actually *use* the file basename in the test this time.
* win32: fix to file extension testRon Yorston2018-12-071-2/+3
| | | | | | | When looking for the special WIN32 file extensions only consider the file's basename, not the full path. Otherwise a file called '.bat', for example, is considered executable by 'ls -a' and the shell tries to run './.bat'.
* win32: rework adding of extensions to filenamesRon Yorston2018-12-061-20/+32
| | | | | | | | | | | | | | | | | | | | | | | Previously there was one function to handle adding extensions to executable filenames, add_win32_extension(). Refactor this into three functions: add_win32_extension() appends the suffix to the argument string in-place. The argument must be long enough to cope with this, as is the case in ash where path_advance() adds 4 bytes to each filename for just this reason. alloc_win32_extension() is equivalent to the old add_win32_extension(). It allocates a string to hold the new filename then calls the new add_win32_extension() function. The caller is responsible for managing the returned string. auto_win32_extension() calls alloc_win32_extension() and saves the resulting string using auto_string(). It's used where the new filename is consumed immediately or the actual value isn't needed. Rewrite code to use the most appropriate function. Also reorder some code in find_executable() and find_command().
* win32: fix implementation of access(2)Ron Yorston2018-12-041-2/+5
| | | | | | | | | The WIN32 implementation of access(2) didn't return: - the correct value when a directory was tested for X_OK; - the correct error code when the target existed but execute permission wasn't available.
* win32: save a few bytes in fake times(2) implementationRon Yorston2018-11-271-5/+1
|
* realpath: implement realpath(3) and enable realpath(1)realpathRon Yorston2018-06-091-3/+56
| | | | | The implementation of realpath(3) is based on code by Stuart Dootson (studoot on GitHub).
* win32: save a few bytes in device file supportRon Yorston2018-03-231-35/+35
|
* win32: small changes to reduce size of binaryRon Yorston2018-03-221-11/+6
| | | | | | | | Reduce the size of the binary by about 32 bytes: - use xzalloc to allocate static buffers so we don't have to initialise them; - avoid duplicated code in spawnveq.
* win32: don't test DLLs for executable formatRon Yorston2018-03-181-0/+5
| | | | | | | | | | | Moving detection of file formats from access(2) to stat(2) in commit 650f67507 was acknowledged to slow down stat. One problematic case is c:/windows/system32 which contains about 2000 DLLs and was found to slow 'ls' unacceptably. Treat DLLs as a special case in has_exec_format. See GitHub issue #101.
* win32: add a function to convert backslashes to slashesRon Yorston2018-03-181-11/+14
|
* win32: try harder to get file attributesRon Yorston2018-03-171-0/+16
| | | | | | | | | Reading the attributes of files like c:/pagefile.sys fails with error code ERROR_SHARING_VIOLATION, which breaks 'ls'. If this happens try an alternative API call to get the attributes. See GitHub issue #101.
* ash: remove special treatment of device filesRon Yorston2018-03-151-1/+3
| | | | | Since device files are now handled in mingw_open there's no need for any special treatment in ash redirection.
* win32: restrict visibility of special devicesRon Yorston2018-03-151-7/+24
| | | | | | | | | | | | | | | Handling of the special devices /dev/zero and /dev/urandom was inconsistent: - they could be used as arguments to 'cat' but not 'od'; - they could not be used in shell redirection. Restrict the use of these devices to two places: - as input files to 'dd' with the 'if=' argument; - internally within 'shred'. See GitHub issue #98.
* win32: squeeze a few bytes out of strftimeRon Yorston2018-03-051-4/+6
|
* win32: reduce amount of static dataRon Yorston2018-03-041-5/+19
| | | | | | | It appears that uninitialised static variables are placed in the data section rather than bss, increasing the size of the binary. Rewrite some code to reduce the amount of static data.
* Minor improvements to buildRon Yorston2018-03-021-2/+1
| | | | | | | | | | | | Exclude source files in libbb that aren't used by busybox-w32. This speeds up the build marginally. They can always be reinstated if necessary. Provide fake routines for everything in inode_hash.c so that it can be excluded. inode_hash.c is now unchanged from upstream. Use last_char_is in has_exe_suffix_or_dot. It doesn't save any bytes but it makes the code neater.
* win32: make has_exec_format staticRon Yorston2018-03-011-55/+55
| | | | The only other caller (in spawnveq) has been removed.
* win32: don't add extensions to filenames ending with a dotRon Yorston2018-02-281-1/+7
| | | | | | | A filename ending with a dot is a signal to spawnve not to try adding extensions but to use the name unmodified. The add_win32_extension function should follow the same rule.
* win32: fix code to check for file extensionsRon Yorston2018-02-271-1/+1
| | | | | The has_win_suffix function didn't check that the extension started with a '.'. As a result the shell was unable to execute cmd.exe.
* win32: move detection of file formats to stat(2)Ron Yorston2018-02-261-51/+60
| | | | | | | | | | | | | | | | | | | | | Move the code to detect shell scripts and binary executables from mingw_access to a separate function, has_exec_format. Call this function in do_lstat to decide whether to set the executable bits in the file mode. This will slow down stat but has a couple of advantages: - shell scripts are highlighted in ls output - the test applet can use stat(2) to detect executable files The new function is used to handle another corner case in spawnveq: binary executables without the usual .exe extension are only run by spawnve if the file name ends with '.'. Two minor changes: - file_is_win32_executable has been renamed add_win32_extension to clarify what it does - a call to file_is_executable has been removed from find_command in ash as it resulted in unhelpful error messages.
* win32: improvements to stat(2) emulationRon Yorston2018-02-261-25/+18
| | | | | | | Set all mode bits rather than just setting user modes and then extending them to group and other. Combine common code in mingw_fstat.
* win32: add support for batch filesRon Yorston2018-02-261-12/+31
| | | | | | | | Support batch files with .bat and .cmd extensions, similar to what's done for .exe and .com. Check extensions in the same order as Windows' spawn function: .com, .exe, .bat, .cmd.
* win32: make /dev/urandom more randomRon Yorston2018-02-231-2/+1
|
* win32: handle /dev/zero and /dev/urandom in open and read functionsRon Yorston2018-02-221-2/+59
| | | | | | | | | | | | | | | | | | | | | | | Currently /dev/zero is handled as a special case in dd. Add hacks to the open and read functions in mingw.c to handle the zero and urandom devices. - Opening /dev/zero or /dev/urandom actually opens the special Windows file 'nul' which behaves like /dev/null. This allows manipulation of the file descriptor with things like seek and close - When /dev/zero or /dev/urandom is opened the resulting file descriptor is stored and used to override the behaviour of read. - No attempt is made to track duplicated file descriptors, so using these devices for redirections in the shell isn't going to work and won't be permitted. (Could be, but won't.) - Limited control of the special file descriptors is provided by allowing the internal variables to be changed. - The numbers from /dev/urandom aren't very random.
* date: support '-' format flag to remove zero paddingRon Yorston2017-12-091-0/+5
| | | | | | | The strftime provided by the Microsoft C runtime uses '#' as the format string flag to remove zero padding; glibc uses '-'. Support the use of the '-' flag for improved compatibility.
* ps: add support for CPU and elapsed time columnsRon Yorston2017-09-011-1/+17
| | | | | | | | It may be necessary to run ps as administrator to get information about processes belonging to other users. The code to detect GetTickCount64 at run-time was imported from Git for Windows.
* win32: shrink code to detect .exe filesRon Yorston2017-08-301-18/+20
| | | | | | | | Add a function (has_exe_suffix) to replace explicit code to check if a filename ends with '.exe. or '.com'. Also shrink code that checks for '.exe' or '.com' on PATH in shell's find_command function.
* win32: implement nanosleep and enable float sleep by defaultRon Yorston2017-01-181-0/+18
| | | | Don't expect sleeping for fractions of a second to be very accurate.
* win32: return an error when lseek is applied to a pipeRon Yorston2016-05-241-0/+14
| | | | | | | | | | | tail failed to process input from a pipe correctly: $ echo -n 54321 | tail -c 3 543 It was trying to use lseek as an optimisation but WIN32 lseek doesn't return an error whan applied to a pipe. Fix this by providing a wrapper for lseek.
* Silence a couple of compiler warningsRon Yorston2016-03-061-1/+2
|
* mingw: silently ignore O_NONBLOCK on file openRon Yorston2016-02-221-2/+1
|
* ln: enable in default configurationRon Yorston2015-10-191-0/+2
|
* win32: fix implementation of '%z' in strftimeRon Yorston2015-10-131-0/+27
| | | | | | | | Windows' strftime prints the name of the timezone rather than the timezone offset for '%z'. Add a hack to do it properly. Windows' strftime also uses its own version of the timezone name for '%Z'. A workaround for this is to set the TZ environment variable.
* win32: append '/' to bare drive name in opendirRon Yorston2015-09-301-0/+15
| | | | Make 'ls c:' and 'ls c:/*' do the right thing.
* win32: remove setitimer implementation and SIGALRM handlingRon Yorston2015-07-261-124/+0
| | | | | | | Commit 69f49ea imported a setitimer implementation from git. Since setitimer isn't used at all in BusyBox it can be removed. The same technique could be used to implement alarm but nothing in the WIN32 port uses that (yet).
* win32: silence some compiler warningsRon Yorston2015-07-151-1/+2
|
* mingw: fix conditions under which open(2) sets errno to EISDIRRon Yorston2015-05-291-1/+1
|
* mingw: buffer in do_stat_internal need not be staticRon Yorston2015-05-291-1/+1
|
* mingw: tidy up implementation of kill(2)Ron Yorston2015-05-291-1/+1
|
* mingw: provide fake getgroups and getgrouplistRon Yorston2015-05-181-0/+22
| | | | | This makes it possible to enable the id and groups applets, though the results they return are worthless.
* mingw: implement getpwnam (but only for current user)Ron Yorston2015-05-181-0/+12
| | | | This allows the shell to expand ~user.
* Allow globbing to be enabled with mingw64Ron Yorston2015-04-121-6/+15
| | | | | | | | | | mingw64 handles globbing differently from mingw32. Add code to allow globbing to be enabled. (By default mingw64 has globbing disabled, though the default can be changed when it's compiled.) Also change the configuration option from ENABLE_NOGLOB to ENABLE_GLOBBING, because double negatives make me think too much. The default is still for globbing to be disabled.
* mingw: changes to handling of directory permissionsRon Yorston2015-03-251-0/+21
| | | | | | | | | The read-only attribute on a directory in Microsoft Windows is quite different from write permission in POSIX. Modify rmdir(2) and chmod(2) to provide more POSIX-like behaviour: rmdir will remove a directory even if it's read-only chmod won't make a directory read-only
* test: fix access check bug; tweak fake file modeRon Yorston2015-03-241-0/+3
| | | | | | | | | | | Changing the fake uid from 0 to 1000 uncovered a problem with file access checks in test. Previously the tests were short-circuited because it thought we were root. With a non-root user the tests were performed, but the mode bits had been redefined for WIN32. Also adjust the fake file mode returned by stat so that the user and group modes are identical. Other users have the same modes as user but without write permission.