aboutsummaryrefslogtreecommitdiff
path: root/win32 (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* win32: allow nanosecond precision in file timesRon Yorston2019-08-161-12/+29
| | | | | | 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: trim leading and trailing spaces from shebang optionsRon Yorston2019-05-031-0/+4
| | | | | | | | | | | | Commit 97e2c4a05 (win32: changes to treatment of scripts) attempted to use strtok(3) to simplify the parsing of shebang lines. Unfortunately it resulted in leading and trailing whitespace being left in the option string. Fix this by trimming the options before they're returned. Reported-by: Niklas DAHLQUIST <niklas.dahlquist@st.com> Signed-off-by: Ron Yorston <rmy@pobox.com>
* vi: use alternate screen bufferRon Yorston2019-04-071-6/+68
| | | | | | | Implement the "ESC[?1049h" and "ESC[?1049l" ANSI escape sequences to switch between the alternate and normal screen buffers. This allows vi to restore the original screen contents on exit.
* winansi: code shrinkRon Yorston2019-04-071-20/+13
| | | | Add a common function to clear a section of the screen buffer.
* winansi: code shrinkRon Yorston2019-04-061-46/+17
| | | | | | | | | Use INVALID_HANDLE_VALUE (not NULL) to indicate that the console and console_in handles haven't been initialised. Replace many explicit comparisons against INVALID_HANDLE_VALUE with tests on the return value of GetConsoleScreenBufferInfo() which fails for an invalid handle.
* win32: try to make working directory names consistentRon Yorston2019-04-021-1/+26
| | | | | | | | | | | | | | | 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: track current directory of mapped drivesRon Yorston2019-04-011-4/+7
| | | | | | | | | | | Drives mapped to a network share or path didn't have their current directory tracked when using path names of the form 'c:path'. This was because commit 585d17d26 used realpath(3) to canonicalise paths in chdir(2). Use readlink(2) instead so that mapped drives aren't canonicalised but symlinks are resolved. See GitHub issue #147.
* df: display origin of mapped driveRon Yorston2019-04-011-1/+8
| | | | | | | | | | | | | | When a drive is mapped to a network share or a path display the mapping in the 'Filesystem' column of df's output. Since this changes the mnt_fsname field of the mntent structure a slight alteration is needed to print_all_cwd() in ash. Revert the change in commit a8c63f25b that enabled FEATURE_DF_FANCY in the default configuration. None of the additional options is very useful. See GitHub issue #164.
* win32: improved support for c:path path namesRon Yorston2019-03-301-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | 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: update implementation of setmntent(3)Ron Yorston2019-03-302-4/+7
| | | | | | | - The arguments to setmntent(3) are unused: add a macro to drop them at call sites. - Allow remote drives.
* win32: interpret absolute paths as relative to %SYSTEMDRIVE%Ron Yorston2019-03-281-0/+56
| | | | | | | | | | | | | | | | | | | | | | 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/+35
| | | | | | | 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: improve filesystem detection and displayRon Yorston2019-03-202-7/+13
| | | | | | | | | | Miscellaneous improvements: - Enable '-a' option to display all filesystems in df(1). - Detect the UDF CDROM filesystem and display it in 'stat -f'. - Let getmntent(3) handle CDROM and floppy devices, ignoring those that have no media. - Set number of inodes and filesystem flags to 0 in statfs(2).
* win32: change stat(2) error code in certain casesRon Yorston2019-03-201-1/+0
| | | | | | | | | | | | | | | Commit 325fee1f9 (win32: change handling of trailing slashes in stat(2)) caused stat(2) to return EINVAL in some cases when ENOENT might have been more appropriate. This caused the command: rm -f dir/* to report an error when the directory was empty, contrary to its expected behaviour of saying nothing. Fixes GitHub issue #155.
* winansi: more robust handling of invalid escape sequencesRon Yorston2019-03-191-34/+46
| | | | | | | | Commit 399b1dd64 (winansi: support escape sequence to set window title) failed to handle some invalid escape sequences correctly. Make the code more robust. Fixes GitHub issue #153.
* win32: add function to convert slashes to backslashesRon Yorston2019-03-152-10/+16
| | | | | | | | | 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().
* lineedit: add a command to change backslashes to slashesRon Yorston2019-03-151-6/+0
| | | | | | | | | | | When a path name is copied to a console application using drag and drop the path separator is backslash. To handle this situation in the shell add an editing command (Ctrl-Z) to convert all backslashes on the current line to slashes. See GitHub issue #149. Also remove some unused code from read_key().
* win32: realpath(3): remove trailing slashRon Yorston2019-03-141-1/+4
| | | | | | | | | If the path is that of a drive mapped to a network share _fullpath() leaves the trailing slash on the drive name and it remains present after the call to resolve_symlinks(). Remove a trailing slash from the resolved path unless it's preceded by a colon.
* Update copyright dateRon Yorston2019-03-141-1/+1
|
* win32: consolidate file metadata optionsRon Yorston2019-03-121-8/+2
| | | | Merge FEATURE_IDENTIFY_OWNER into FEATURE_EXTRA_FILE_DATA.
* win32: changes to user idsRon Yorston2019-03-101-20/+30
| | | | | | | | | | | | | | | | Formalise the use of 0 as the uid of a process running with elevated privileges: - Rewrite getuid(2) to return DEFAULT_UID by default and 0 if the process has elevated privileges. - geteuid(2) and the corresponding functions for groups are aliases for getuid(2). - Change root's home directory to be whatever GetSystemDirectory() returns, probably C:/Windows/System32 in most cases. - Remove the special handling of geteuid(2) in the line editing code. With these changes the shell started by 'su' is a lot more like a *nix root shell.
* winansi: support escape sequence to set window titleRon Yorston2019-03-091-12/+32
| | | | | | | | To set the window title from the command line: echo -en '\e]0;Hello World\007' The same sequence can be used in the shell's prompt (PS1).
* su: change title of console windowRon Yorston2019-03-091-0/+6
|
* win32: add a function to detect running with elevated privilegesRon Yorston2019-03-091-0/+18
| | | | | Add is_admin() and use it to alter the command prompt in the line editor when running with admin privileges.
* win32: extend normalisation of paths in realpath(3)Ron Yorston2019-03-081-2/+20
| | | | | | | | | | | The code to normalise paths in resolve_symlinks(), which is used by realpath(3), was incomplete and unable to handle UNC paths. Make an ASCII version of normalize_ntpath() to extend the cases covered. This fixes a regression introduced by commit 585d17d26 (win32: canonicalize path in chdir(2)): it wasn't possible to change to a directory with a UNC path.
* win32: canonicalize path in chdir(2)Ron Yorston2019-03-061-0/+13
| | | | | | | | | | | | Provide an implementation of chdir(2) which canonicalizes the path to resolve symlinks. Otherwise changing to a symlinked directory confuses 'ls -l' because it thinks '.' is a link rather than a directory. OTOH, using 'cd' in the shell to change to a symlinked directory now results in a mismatch between the shell's idea of where we are and what's displayed in the prompt. But upstream BusyBox does that too so it must be OK.
* win32: implement readlink(2)Ron Yorston2019-03-061-0/+65
| | | | | | | | | | Provide an implementation of readlink(2) based on code from Git for Windows. This version only supports symbolic links, not mount points, as the latter seem to work well enough as-is. With this change the ls and stat applets can display the targets of symbolic links. The readlink applet has been enabled in the default configuration.
* win32: let realpath(3) succeed on WinXP/ReactOSRon Yorston2019-03-061-8/+14
| | | | | | Allow realpath(3) to return successfully on platforms that don't support GetFinalPathNameByHandleA(). It may still have done some useful work.
* win32: drop argument from err_win_to_posix()Ron Yorston2019-03-063-9/+9
|
* win32: improved results for symlinks from stat(2)Ron Yorston2019-03-051-36/+56
| | | | | | | | The file size and times reported when Windows follows a symlink are incorrect. To get the correct values canonicalize the path and try again. Also fetch the correct device id and inode for symlinks.
* win32: change handling of trailing slashes in stat(2)Ron Yorston2019-03-041-40/+11
| | | | | | | | | | The code to implement stat(2) works around the fact that getting the attributes of a file fails if its name ends with a path separator. Directory names with a trailing path separator work fine. Why bother with this workaround? Linux doesn't. Instead try to return a meaningful error code.
* win32: simplify utimes(2) implementationRon Yorston2019-03-041-31/+6
| | | | | | | | | | | SetFileTime only needs FILE_WRITE_ATTRIBUTES access, not full read/write access. Therefore it isn't necessary to change the permissions of read-only files. The flag FILE_FLAG_BACKUP_SEMANTICS is required to access directories but does no harm if used on a file. As a result there's no need to get file attributes.
* win32: let stat(2) report numeric uids for local usersRon Yorston2019-03-021-8/+47
| | | | | | | | | | | Further extend file identification so stat(2) returns the relative identifier as a numeric uid for files with owner SIDs that look like a local or domain user. See: https://blogs.technet.microsoft.com/markrussinovich/2009/11/03/the-machine-sid-duplication-myth-and-why-sysprep-matters/ https://cygwin.com/cygwin-ug-net/ntsec.html
* win32: make stat(2) try to identify the owner of filesRon Yorston2019-03-011-7/+64
| | | | | Extend stat(2) so it tries to determine whether a file belongs to the current user or not. If not it's said to belong to root.
* win32: make more use of common lazy loading codeRon Yorston2019-02-272-27/+10
|
* win32: fake permissions/ownership for inaccessible filesRon Yorston2019-02-251-0/+5
| | | | | If stat(2) knows a file exists but can't obtain additional metadata for it give it root ownership and no permissions for other.
* uname: drop support for ia64Ron Yorston2019-02-211-4/+3
|
* win32: use manifest provided by MinGW-w64Ron Yorston2019-02-213-33/+0
| | | | | | | | | The manifest included here wasn't effective in telling Windows about version compatibility. Use the default manifest provided by MinGW-w64 instead. On Fedora this requires installing the mingw32-windows-default-manifest and/or mingw64-windows-default-manifest packages.
* win32: remove unused include filesRon Yorston2019-02-202-0/+0
| | | | | | Upstream commit d9aabfe578 (make busybox more portable) moved a couple of include files into platform-dependent code so we no longer need dummy versions.
* win32: stat(2) succeeds if fetching extra metadata failsRon Yorston2019-02-191-11/+3
| | | | | | | | | Some files can't be opened to fetch additional metadata. When that happens allow stat(2) to successfully return what data it has. In a few cases where the inode number is used to determine if files are identical ignore invalid inode numbers.
* win32: tidy up stat(2) implementationRon Yorston2019-02-181-21/+22
| | | | | | | Since st_nlink now depends on st_mode it should be set after st_mode is initialised. Rearrange the code to fetch extra metadata.
* win32: avoid use of uninitialised metadata in stat(2)Ron Yorston2019-02-181-2/+8
| | | | | | When additional metadata was being fetched the code for non-disk files used uninitialised data from the BY_HANDLE_FILE_INFORMATION structure.
* ash: updated support for hiding consoleRon Yorston2019-02-171-0/+16
| | | | | | | | Move the code to hide the console to a separate function in win32/mingw.c. Use lazy loading to avoid problems on platforms where the require APIs aren't supported (PR #70). Enable console hiding in the default 64-bit configuration.
* win32: make stat(2) fetch additional metadataRon Yorston2019-02-161-4/+35
| | | | | | | | | | | | | | | Modify the WIN32 implementation of stat(2) to fetch inode number, device id and number of hardlinks. This requires opening a handle to the target file so it will be slower. A number of features can be enabled or start to work: - tar can detect if an archive is being stored in itself; - find can support the -inum and -links options; - ls can display inode numbers; - diff can detect attempts to compare a file with itself; - du has better support for hardlinked files; - cp can detect attempts to copy a file over itself.
* win32: add a function to remove CRs from a text bufferRon Yorston2019-02-141-0/+11
|
* win32: don't try to run non-existent scriptRon Yorston2019-02-071-1/+1
| | | | | | In parse_interpreter return an error when the file doesn't exist. The current code tries to run non-existent scripts with a .sh suffix, thus breaking the test ash-misc/exec.tests.
* win32: add support for the euro currency symbolRon Yorston2019-02-022-0/+89
| | | | | | | | | | | | | | | | | | | | | | The euro currency symbol was added to some OEM code pages. See: https://www.aivosto.com/articles/charsets-codepages-dos.html Add a configuration option (enabled by default) to support this. When enabled: - The read_key() function requests wide character key events. This allows the euro symbol to be entered regardless of the console OEM code page, though it needs to be available in the ANSI code page. - Conversions between OEM and ANSI code pages in winansi.c are modified to work around a bug in the Microsoft routines. - If the OEM code page is 850 when BusyBox starts it's changed to 858. This is the only currently supported OEM code page. Also, the shell read builtin is modified to use read_key() whenever input is being taken from the console.
* win32: allow characters to be entered as ALTNNNRon Yorston2019-01-261-3/+34
| | | | | | | | | | | | It wasn't possible to enter characters using Alt and the decimal character code. This was because the character is generated when the Alt key is released but the WIN32 implementation of read_key() ignored all key up events. Modify read_key() to ignore numbers entered on the numeric keypad with Alt pressed and to detect when Alt is released. Fixes GitHub issue #136.
* ps: fix long output when desktop compatibility is disabledRon Yorston2019-01-081-0/+3
| | | | | | | | In desktop mode the state column is disabled and doesn't affect output. When desktop mode is disabled the state column is displayed in long output. Put some fake data in the column to improve the display.
* ps: display interpreted script name in comm columnRon Yorston2019-01-081-1/+2
| | | | | | | | | | | When an interpreted script is being run the comm column in ps should display the name of the script not the name of the interpreter. Use a fake applet pathname to indicate which argument contains the script. This also allows pidof to obtain the pid of a script.