| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
If stat(2) knows a file exists but can't obtain additional metadata
for it give it root ownership and no permissions for other.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
Since st_nlink now depends on st_mode it should be set after
st_mode is initialised.
Rearrange the code to fetch extra metadata.
|
|
|
|
|
|
| |
When additional metadata was being fetched the code for non-disk
files used uninitialised data from the BY_HANDLE_FILE_INFORMATION
structure.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
umask() in the Microsoft C runtime takes different arguments to
umask(2). Implement a fake umask(2) that remembers the mask and
calls the Microsoft umask() with an appropriate value.
Since the mask won't be inherited by children use an environment
variable to pass any value set by the shell built-in umask.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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'.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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().
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
The implementation of realpath(3) is based on code by Stuart Dootson
(studoot on GitHub).
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Since device files are now handled in mingw_open there's no need
for any special treatment in ash redirection.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
The only other caller (in spawnveq) has been removed.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
Set all mode bits rather than just setting user modes and then
extending them to group and other.
Combine common code in mingw_fstat.
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Don't expect sleeping for fractions of a second to be very accurate.
|