aboutsummaryrefslogtreecommitdiff
path: root/win32 (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-042-21/+15
| | | | | | 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 PATHRon Yorston2018-12-141-20/+0
| | | | | | | | | | | | | | | | | The PATH shell variable is a special case. It can be exported to the environment where it might be interpreted by native applications which assume the separator is ';'. Hence: - require that the separator used in PATH is ';' - enforce this by intercepting calls to setvareq() that set PATH and adjusting its value if necessary. As a result of this the code to parse PATH can be simplified by replacing the hardcoded Unix ':' path separator by the platform- dependent macro PATH_SEP. The MANPATH variable is also required to use ';' as its separator but since it's less likely to be used this isn't enforced.
* win32: emulate SIGPIPERon Yorston2018-12-111-3/+23
| | | | | | | | | | | | | | | | | | | The code to check whether a write error is due to a broken pipe can now either: - return with error EPIPE; - cause the process to exit with code 128+SIGPIPE. The default is the latter but the behaviour can be changed by issuing signal(SIGPIPE, SIG_IGN) and signal(SIGPIPE, SIG_DFL) calls. No actual signal is involved so kill can't send SIGPIPE and handlers other than SIG_IGN and SIG_DFL aren't supported. This does, however, avoid unsightly 'broken pipe' errors from commands like the example in GitHub issue #99: dd if=/dev/urandom | tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
* win32: special treatment for files with the '.sh' extensionRon Yorston2018-12-092-36/+46
| | | | | | | | | | | | 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-092-12/+4
|
* win32: allow execution of empty batch file to succeedRon Yorston2018-12-081-0/+8
| | | | | | | Microsoft Windows' spawnve returns ERROR_BAD_EXE_FORMAT when passed an empty batch file. Work around this by skipping spawnve and returning success.
* 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: improve execution of batch filesRon Yorston2018-12-071-26/+8
| | | | | | | | | It appears that when a batch file is executed the first argument must contain backslashes if it's a relative path. Absolute paths work either way. In both cases the extension is optional. This allows for a considerable simplification of the special case in spawnveq.
* win32: rework adding of extensions to filenamesRon Yorston2018-12-062-22/+34
| | | | | | | | | | | | | | | | | | | | | | | 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.
* ash: fix a couple of test casesRon Yorston2018-12-041-3/+1
| | | | | | | | | | | | | | The ash tests exitcode_EACCES and exitcode_ENOENT both failed. In commit 92dbd3c09 a test was added to tryexec to check that the file being run existed and was executable. The error codes returned by this test were incorrect. The slightly later commit f5783ef14 added a similar test in spawnveq which got the error codes right. Remove the test from tryexec and some superfluous error messages from spawnveq.
* win32: save a few bytes in process scanningRon Yorston2018-11-271-14/+7
| | | | | | Recalculate the system boot time on every pass through the process scanning loop. It's less efficient than storing the value in a static variable but not noticeably so and it saves a few bytes.
* win32: save a few bytes in fake times(2) implementationRon Yorston2018-11-271-5/+1
|
* Allow build objects to go to a separate directoryRon Yorston2018-11-212-3/+4
| | | | | | | | Fix the build system so the KBUILD_OUTPUT environment variable can be used as intended: to specify that object files are placed in a separate directory from the source. Also ensure that busybox-w32.manifest is deleted by 'make mrproper'.
* win32: use string_array_len to obtain size of argv arrayRon Yorston2018-10-261-8/+4
| | | | Saves 16 bytes.
* win32: rename resource filesRon Yorston2018-07-248-6/+6
| | | | | Since more than just icon resources are now provided give various files more appropriate names.
* win32: make version info and manifest resources configurableRon Yorston2018-07-242-3/+7
|
* win32: tweaks to manifestRon Yorston2018-07-242-26/+26
| | | | | | - Use CRLF line endings in manifest file. - Add '-b' option to sed command to insert version in manifest file.
* win32: add manifest resourceRon Yorston2018-07-123-0/+31
| | | | | Add a manifest to declare the requested execution level of the busybox-w32 executable.
* win32: better error message in kill(2)Ron Yorston2018-07-121-0/+2
| | | | | | When the process architecture of busybox-w32 didn't match that of the target process the error reported was 'Function not implemented'. Change this to 'Permission denied'.
* 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: remove some code from procps_scanRon Yorston2018-04-101-3/+0
| | | | | Now that we're calling memset to clear data for each process it's no longer necessary to zero the process times by hand.
* win32: don't leak pipe data structuresRon Yorston2018-04-071-58/+66
| | | | | | | | | | | | popen uses an array of pipe_data structures to record information that's later used by pclose. pclose releases the structure after use. The lower-level pipe function mingw_popen_fd was also using this array of structures but didn't provide any way to release them. Avoid this leak by letting mingw_popen_fd use a local structure instead.
* ps: indicate forkshell processes in listingRon Yorston2018-04-051-1/+1
|
* win32: exclude termios codeRon Yorston2018-04-052-14/+0
| | | | | The code to manipulate terminal settings serves no purpose in WIN32. Use conditional compilation to exclude much of it.
* win32: ensure timeout works in read_keyRon Yorston2018-04-051-4/+4
| | | | | | Move the wait for timeout into the while loop of read_key. Otherwise the timeout won't be checked after any event that doesn't result in a value being returned.
* ps: obtain applet names from other BusyBox processesRon Yorston2018-04-041-18/+89
| | | | | | | | | | | | | | | Remove the code which passed applet names to child processes using environment variables. This only allowed ps to display names for its ancestors. Instead attempt to read applet names from the memory of unrelated processes. The Microsoft documentation alone wasn't enough to figure out how to do this. Additional hints from: https://stackoverflow.com/questions/4298331/exe-or-dll-image-base-address https://stackoverflow.com/questions/14467229/get-base-address-of-process
* win32: improvements to get_terminal_width_heightRon Yorston2018-04-032-18/+23
| | | | | | | | - move winansi_get_terminal_width_height from winansi.c to ioctl.c, the only caller; - check both stdout and stderr for a connection to a console; - omit unnecessary code in get_terminal_width_height (because the WIN32 implementation ignores the file descriptor).
* win32: simplify isatty replacementRon Yorston2018-04-031-5/+1
| | | | | Don't treat input and output file descriptors differently: if we aren't connected to a console GetConsoleMode will fail for either.
* win32: return correct exit status from waitpidRon Yorston2018-03-291-1/+5
| | | | | | | | | | | The exit status from _cwait wasn't being correctly returned. This resulted, for example, in the exit status of xargs being incorrect. Running this: $ ls | xargs ls in a directory containing filenames with spaces should cause 'ls' to fail and 'xargs' to return an exit status of 123.
* win32: save a few bytesRon Yorston2018-03-291-4/+3
| | | | | | | | In the recently-added code to pass applet names to child processes use local arrays to build the environment variables rather that allocating them every time. mingw_spawn can call mingw_spawn_proc instead of mingw_spawn_1.
* win32: improve dependency checking for resourcesRon Yorston2018-03-291-2/+5
|
* ps: display applet names in process listingRon Yorston2018-03-281-1/+16
| | | | | | | | | | | | | | | | In standalone shell mode all busybox-w32 applets are displayed as 'busybox.exe' in a process listing. I haven't found a satisfactory way to query a running instance of busybox-w32 to determine which applet it's running. Handle a couple of cases: - the process running the process scan knows its own PID and knows which applet it is; - just before invoking applet_main set an environment variable whose name contains the PID and whose value is the current applet name. Children running a process scan will inherit their parent's environment and can therefore match the parent's PID to its applet name.
* ps: clear status for each processRon Yorston2018-03-281-0/+2
| | | | | | | | | The original procps_scan function takes care to clear the status information before handling each process. Do the same for the WIN32 version. This requires moving the snapshot handle to the part of the structure that isn't cleared on each iteration.
* Add a VERSIONINFO resource to the binaryRon Yorston2018-03-282-2/+34
| | | | | | | | | | If icons are enabled we might as well store some version information. The string manipulation is based on this: https://stackoverflow.com/questions/8540485/how-do-i-split-a-string-in-make Closes issue #108.
* win32: changes to kill(2)Ron Yorston2018-03-271-14/+20
| | | | | | | | | The names of the callbacks to kill processes with a given signal were confusing because they referred to the implementation rather than the intent. Create the new function kill_SIGTERM_by_handle which is more efficient when a handle to the process to be killed is already available.
* Allow icon resources to be included in the binaryRon Yorston2018-03-277-0/+39
| | | | | Include two styles of icon from the GNOME Adwaita theme. These are enabled by default and add 30 Kbytes to the size of the binary.
* win32: save a few bytes in device file supportRon Yorston2018-03-231-35/+35
|
* win32: allow use of shell's PRNG for /dev/urandomRon Yorston2018-03-222-5/+82
| | | | | | Allow either ISAAC or the shell's built-in pseudo-random number generator to be used for /dev/urandom. The latter is smaller so it's the default.
* win32: tighten up code slightly in isaac.cRon Yorston2018-03-221-13/+5
|
* win32: small changes to reduce size of binaryRon Yorston2018-03-222-13/+8
| | | | | | | | 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.
* win32: tidy up popen implementationRon Yorston2018-03-151-206/+75
| | | | | | | | | Make mingw_popen_fd sufficiently general that it can be used to implement the other two popen routines. mingw_popen now just creates a command line and passes it to mingw_popen_fd. The one call to mingw_popen2 has been replaced by a call to mingw_popen_fd.
* wget: add support for httpsRon Yorston2018-03-151-0/+103
| | | | | | | | | | | | | | | | Allow wget to support https URLs. Changes are: - Add mingw_popen2 which uses a named pipe to allow bidirectional communication with a child process; - Modify ssl_client to accept a WIN32 handle instead of a file descriptor as an argument; - Allow tls_get_random to open /dev/urandom; - Using the above changes implement a WIN32 version of spawn_ssl_client in wget. This closes GitHub issue #75. Also, enable authentication in wget.