| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Change how 'which' detects if it was run from a standalone shell:
the shell passes the undocumented '-s' option. This is stricter
and more reliable than the previous method of checking the name
of the binary.
Add a function to determine the binary associated with a given
applet name. This makes it possible for 'which' and 'command -v'
to list the correct binary even for applets other than 'busybox'.
For example, when the binary is called 'sh.exe' 'which sh' will
report its path.
In standalone shell mode 'command -V' and 'type' now report "xxx
is a builtin applet" rather than "xxx is xxx", which is true but
not very illuminating.
(GitHub issue #248)
|
|
|
|
|
|
|
|
|
| |
Provide a WIN32 implementation of clock_gettime(2), though only
with support for CLOCK_REALTIME. This makes it possible to enable
FEATURE_DATE_NANO which adds support for the %N date format.
MinGW-w64 has clock_gettime(2) but it's in the winpthreads library
and we don't want to bother with that.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Upstream commit 94eb1c4dc (libbb: better coreutils compatibility
for realpath) made some changes to xmalloc_realpath_coreutils().
This now needs to be updated to handle Windows paths.
- Expose the macro is_unc_path() and part of the recent change to
bb_get_last_path_component_nostrip() as a separate funtion,
get_last_slash();
- Convert a couple of errors relating to network filesystems to
ENOENT;
- Adjust xmalloc_realpath_coreutils() to handle Windows directory
separators, relative paths and UNC paths.
|
|
|
|
|
| |
As the comment pointed out is_absolute_path() was misnamed. Rename
it to is_relative_path() and change the sense of all tests.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Allow waitpid() to detect SIGTERM/SIGKILL by checking the (Windows)
status returned by GetExitCodeProcess() and updating the Unix
status to suit. This allows ash to detect when a process has been
'signalled'.
Provide our own implementation of strsignal(3) which returns
expanded text for SIGTERM/SIGKILL.
Costs 192 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Create mingw_strptime() to return timezone offset as a separate
argument (since Microsoft's struct tm doesn't have the required
member).
Import timegm() from musl.
Update parse_datestr() to use mingw_strptime().
Enable FEATURE_TIMEZONE in the default configuration.
GitHub issue #230.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Our realpath(3) implementation uses xmalloc_follow_symlinks() to
expand symlinks. This detects when symlinks are too deeply nested
but didn't set errno, so anything calling realpath(3) was unable to
say what had gone wrong. (For example, 'ls -L' or 'stat -L'.)
Set errno to ELOOP.
This then leads to the problem that Windows doesn't know about
ELOOP so reports 'Unknown error'. Add a replacement for strerror(3)
which returns a sensible message.
Costs 96 bytes.
|
|
|
|
|
|
|
|
|
|
| |
Provide a partial implementation of sync(2), so sync(1) can actually
do something in some circumstances:
- Only logical drives are handled.
- Flushing buffers requires administrative privileges. If run as
a normal user nothing will happen.
|
|
|
|
|
| |
Enable the sync applet by default. It doesn't actually do anything
useful but at least it prevents some scripts from failing.
|
|
|
|
| |
Avoid confusion between special devices and /dev/fd.
|
|
|
|
|
| |
The touch applet has been changed to use futimens(2)/utimensat(2).
Provide implementations of these for WIN32.
|
|
|
|
|
| |
Make is_absolute_path() a function rather than a macro and move it
from ash.c into mingw.c.
|
|
|
|
|
|
|
|
|
|
| |
Add a call to GetPerformanceInfo. Treat the SystemCache member of
the PERFORMANCE_INFORMATION structure as buffer RAM. Deduct it
from available RAM.
The numbers reported by 'free' move about in vaguely sensible
ways when I start and stop programs, though I still don't know
if they're in any way accurate.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is an experimental implementation of sysinfo(2)/free(1).
It uses the WIN32 API GlobalMemoryStatusEx() to obtain information
about memory.
It seems that the 'total pagefile' value includes total RAM as well
as pagefile and 'available pagefile' includes available RAM. So the
RAM values are deducted.
I've no idea what corresponds to Linux buffers and cache.
|
|
|
|
|
| |
Since there's only one call to mingw_spawn_forkshell() we might
as well just call spawnve() directly from ash.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Provide an implementation of symlink(2).
Calls to symlink(2) will fail in default Windows installations unless
running with elevated privileges. Failure to create a symlink when
extracting files from an archive is therefore treated as a non-fatal
error.
There are two ways to permit the creation of symlinks:
- Edit security policy to give users the 'Create symbolic links'
privilege. Unfortunately this doesn't work for users who are an
Administrator.
- Enable developer mode, which is available in later versions of
Windows 10.
The ability to create symlinks is not available in Windows XP
or ReactOS.
|
|
|
|
|
|
|
| |
There doesn't seem to be much advantage in having readlink(2) as a
configuration option. Making it unconditional reduces divergence from
upstream and allows the removal of a check for ENOSYS that's been in
busybox-w32 since the start.
|
|
|
|
|
| |
Don't compile some code that isn't currently supported for WIN32.
Saves 24 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
On reflection, the previous commit may have been ill-advised. There
are many calls to open_read_close() and most shouldn't be able to
access special devices. (Though in practice only a few are enabled
in busybox-w32.)
Nonetheless, I've implemented a new mechanism which uses the macro
MINGW_SPECIAL() to mark calls to functions that are allowed to
access special devices.
An unrelated change is to avoid compiling fputs_stdout() in
coreutils/printf.c for the POSIX build.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Perform code page translation for fputc(3). It's only used in a
few places but is needed to fix things like:
$ echo € | dos2unix
Ç
$ paste -d € file1 file2
1Ç2
Unfortunately it breaks the inventive use of dos2unix in GitHub
issue #203.
|
|
|
|
|
|
|
|
|
|
| |
Revert commit 249f68e3c (win32: append '/' to bare drive name in
opendir).
Instead add better handling for paths of the form 'c:path' to ls
and expmeta() in ash.
Adds 64 bytes.
|
|
|
|
|
|
|
|
| |
Replace auto_add_system_drive() with alloc_system_drive() which
leaves space for a possible filename extension. This makes it
possible to drop alloc_win32_extension() and auto_win32_extension().
Saves 144 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Shell scripts moved from Unix may contain hard-coded paths to
binaries such as /bin/sh. A recent commit made it possible to
execute such binaries reliably, but that does require them to be
installed. As an alternative solution: if a binary with a
standard Unix path prefix can't be found but is available as a
built-in applet, run the applet.
Add the function unix_path() to detect paths starting with /bin,
/usr/bin, /sbin or /usr/sbin.
Use this function in:
- the 'which' applet
- shellexec(), describe_command() and find_command() in ash
- mingw_spawn_1()
See GitHub issue #195.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As noted in commit 548ec7045 (win32: interpret absolute paths as
relative to %SYSTEMDRIVE%) a path starting with a '/' in the Unix
world is treated as relative to the current drive by Windows.
To avoid ambiguity that commit considered certain such paths to
be relative to %SYSTEMDRIVE%. Extend this to paths representing
executables.
Add the functions need_system_drive() and auto_add_system_drive()
to detect the need for a system drive prefix and to add it if
necessary. Use these functions in:
- the 'which' applet
- the find_executable() function
- tab-completion code
- PATH look-up, shellexec(), describe_command() and find_command() in ash
- parse_interpreter() and mingw_spawn_1()
With these changes executable paths starting with a slash are
handled consistently, whatever the current drive.
|
|
|
|
|
|
|
| |
Allocate static storage for the system drive string instead of
making a new allocation on every call. This is easier to manage.
Adds 16 bytes.
|
|
|
|
|
|
|
|
|
|
| |
Add a new function, has_path(), to detect that an executable name
doesn't require a path look-up.
Also, since is_absolute_path() is now only used in shell/ash.c move
its definition there from include/mingw.h.
Saves 128 bytes.
|
|
|
|
|
|
|
|
| |
Use a new common function, mingw_fork_compressor(), to implement
fork_transformer() in open_transformer.c and vfork_compressor()
in tar.c.
Saves 160 bytes.
|
|
|
|
|
|
|
|
| |
- Drop exit_code argument from kill_SIGTERM_by_handle()
- Pass signal number rather than exit code to other functions
- Merge kill_SIGKILL() and kill_SIGTEST()
Saves 112 bytes.
|
| |
|
|
|
|
|
|
| |
Until now the emulated stat(2) system calls have only returned a
synthesised Unix-style mode value. Also return the raw Windows
file attributes.
|
|
|
|
|
|
|
|
|
| |
The subprocess that handles incoming connections for httpd didn't
work. It has an accepted connection on stdin and calls getpeername()
to obtain its details, but getpeername() didn't initialise networking.
ssl_client only seems to deal with file descriptors. Expose
init_winsock() again and call it from ssl_client.
|
|
|
|
|
|
| |
A call to initialise networking is made during start up even if
the applet doesn't need it. Instead, only initialise networking
when a call is made to a function that definitely requires it.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
spawn_forkshell() uses mingw_spawn_proc() to start the child shell.
mingw_spawn_proc() then calls mingw_spawn_1() which determines
that "sh" is an applet, thus calling mingw_spawn_applet() which
finally calls spawnveq().
Not only is this convoluted it also won't work if PREFER_APPLETS
and SH_STANDALONE aren't enabled.
Simplify matters by adding a new function, mingw_spawn_forkshell(),
which is tailored for just this case.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Update the skip status on the first call to skip_ansi_emulation()
and whenever the BB_SKIP_ANSI_EMULATION variable changes.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
Implement getpeername(2).
Add mingw_spawn_detach() to allow the spawned process to detach from
the console.
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Have bs_to_slash() return a pointer to its argument. This allows
some calls to be chained, saving 32 bytes.
|
|
|
|
|
|
|
| |
Since we don't have a working clock_settime(2) there's no point
in claiming to support the '-s' option.
Saves 96 bytes
|
|
|
|
|
|
| |
- Update configuration files
- Omit unnecessary libraries
- Replace fake stime(2) with fake clock_settime(2)
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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().
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
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().
|