summaryrefslogtreecommitdiff
path: root/win32 (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* dd: fix handling of 'conv=notrunc seek=N'Ron Yorston2020-05-201-3/+3
| | | | | | | | | | | | | | | | | | 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.
* inotifyd: WIN32 portRon Yorston2020-04-151-0/+0
| | | | | | | | | | | | Use ReadDirectoryChangesW to implement inotifyd for WIN32. There are limitations: - It's only possible to watch directories, not files. - The notification doesn't distinguish between different changes to file state. All changes other than creation, deletion and renaming are reported as 'c'.
* winansi: more fine-grained control of ANSI emulationRon Yorston2020-04-131-2/+34
| | | | | | | | | | | | | | | | Change the meaning of the BB_SKIP_ANSI_EMULATION variable: - if it isn't set or if it has any value other than 1 or 2, use ANSI emulation; - if it's set to 1, always emit ANSI escape codes; - if it's set to 2, attempt to enable virtual terminal processing in the current console. If that works emit ANSI escape codes, if not revert to ANSI emulation. On all platforms I've tested (Windows 10, Windows 8.1, ReactOS 0.4.13, plus ConEmu) BB_SKIP_ANSI_EMULATION=2 does the right thing.
* ash: reset ANSI emulation when BB_SKIP_ANSI_EMULATION changesRon Yorston2020-04-131-10/+7
| | | | | 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-062-7/+45
| | | | | | | | 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-052-3/+27
| | | | | | | Implement getpeername(2). Add mingw_spawn_detach() to allow the spawned process to detach from the console.
* win32: more improvements to 'c:file' pathsRon Yorston2020-03-291-2/+3
| | | | | | | | Tab-completion of 'c:file' paths was leaking memory and incorrectly included BusyBox applets and shell built-ins. Fix handling of 'c:file' paths used as arguments to spawn functions. Otherwise things like 'timeout 5 c:busybox sleep 99' don't work.
* dd: create a sparse file when seek=N is usedRon Yorston2020-03-241-0/+17
| | | | | | | 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: stat(2): return correct st_blocks for compressed/sparse filesRon Yorston2020-03-241-1/+13
| | | | | | Use GetCompressedFileSize to obtain the actual number of blocks for compressed or sparse files. Use this to return a more accurate value for st_blocks.
* win32: reduce size of strptime()Ron Yorston2020-02-161-74/+8
| | | | | | | | Our implementation of strptime() doesn't support alternative number formats. Rather than duplicate the code for the affected conversion specifications just return to the start of the switch statement. Saves 256 bytes.
* win32: save bytes in fnmatchRon Yorston2020-02-161-13/+55
| | | | | | | Replace several explicit string comparisons with a single call to index_in_strings(). Saves 304 bytes.
* win32: tidy up detection of device filesRon Yorston2020-02-161-9/+3
| | | | | | | 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: save a few bytes in statfsRon Yorston2020-02-161-3/+5
| | | | | | | Use memset() to fill the structure with zeroes, avoiding the need to set some members explicitly. Saves 16 bytes.
* win32: save space in statfsRon Yorston2020-02-151-20/+5
| | | | | | | | Place filesystem names in a single null-separated string and search it using index_in_strings(). Use the result (offset by 1 to allow for failure) to index an array of filesytem types. Saves 112 bytes.
* win32: rework device file detectionRon Yorston2020-02-151-6/+4
| | | | | | Improve get_dev_type() and use it to dectect /dev/null in mingw_xopen(). Saves 64 bytes.
* win32: code shrinkRon Yorston2020-02-131-11/+9
| | | | | 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-6/+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
* winansi: fix alternate screen buffer in Windows 7Ron Yorston2020-02-061-6/+10
| | | | | | | | | | | | | Closing 'vi' in Windows 7 resulted in the console window failing to echo any output correctly until the 'reset' builtin was run. This didn't happen in Windows XP, 8 or 10. The problem is fixed by only duplicating the console handle when switching *to* the alternate screen buffer. Add sanity checks so that switching to the alternate buffer requires the cached handled to be invalid, while it must be valid when switching from the alternate buffer.
* mingw: fix off-by-one error in mingw_strftime()Ron Yorston2020-01-191-1/+1
| | | | | | | | | | | | When a format specification is replaced the loop variable 't' should point to the last character of the replacement string in the new format buffer. In an extreme case if the original format string is "%z" and tm->tm_isdst is negative to indicate that no DST information is available the replacement string will be empty and 't' will point to the location before the start of the new format buffer. This is OK.
* mingw: fix use after free in file_owner()Ron Yorston2020-01-191-9/+6
| | | | | The security descriptor was being freed before its contents were accessed.
* Build fixesFRP-3329-gcf0fa4d13Ron Yorston2020-01-081-1/+1
| | | | | | - Update configuration files - Omit unnecessary libraries - Replace fake stime(2) with fake clock_settime(2)
* winansi: code shrinkRon Yorston2020-01-081-37/+31
| | | | | | | | | | | | | | Rework the ANSI emulation code to reduce its size. - Fetch console attributes when required rather than caching them. The init() function is no longer required; the only remaining initialisation is now performed in is_console(). - Turning off inverse video (ESC[27m) didn't work properly. This has been improved though it still doesn't work in some unlikely cases (ESC[7;27m). These changes save 180 bytes.
* Update copyright dateRon Yorston2020-01-081-1/+1
|
* winansi: restore correct attributes after lsRon Yorston2020-01-071-1/+7
| | | | | | | | | As reported in GitHub issue #178 the last colour set by the ls command is retained in the console. This is due to the previous commit reinitialising the stored attributes more frequently than it should. Attriubutes should only be initialised once.
* winansi: fix escape processing in Windows 10 release 1809Ron Yorston2020-01-061-20/+20
| | | | | | | | | | | | | | As reported in GitHub issue #177, ANSI escape sequences don't work reliably after shell redirection. The problem appears to be due to a change in the behaviour of dup2() in Windows 10 release 1809. The escape handling code kept a copy of the console handle for internal use. Prior to Windows 10 release 1809 this worked; since then unwinding shell redirections results in the actual console handle changing from time to time for reasons that are unknowable without access to the source code. Fix this by always fetching the console handle instead of caching it.
* 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.