| Commit message (Collapse) | Author | Files | Lines |
|
In xmalloc_follow_symlinks() the code to detect relative paths
needs to be altered for WIN32. We don't want C:/path to be
treated as a relative path.
|
|
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
That function would rename the _target_, not the link.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
In e86a3ddd8 (win32: make readlink(2) implementation unconditional,
2021-02-12), we removed the special casing of `errno == ENOSYS` when
trying to follow symlinks. However, that handling really was necessary:
- When we followed a symlink, and found a non-symlink, and then called
`readlink()` with that non-symlink, we got `errno == ENOSYS` on
Windows (translated from `ERROR_NOT_A_REPARSE_POINT`), and we did
want to stop the loop and return the current path in that case.
(Noted by Johannes Schindelin.)
- When readlink() called DeviceIoControl() for files on certain
filesystems (e.g. FAT or a CDROM) it returned `errno == ENOSYS`
(translated from ERROR_INVALID_FUNCTION).
Revert the part of the patch which handled `ENOSYS` on Windows.
|
|
When one tries to call `CreateFile()` with a reparse point, it will
trigger an `ERROR_INVALID_NAME` unless `FILE_FLAG_OPEN_REPARSE_POINT` is
passed. However, _when_ that flag is passed, it does not open a handle
to the symlink _target_, but to the symlink itself.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
Otherwise we're provoking buffer overruns.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
On Windows, there are file symlinks and directory symlinks. When trying
to `opendir()` a symlink marked as `file`, it will fail. Even if the
target is a directory. Because it's the wrong symlink type.
To address this, our `symlink()` function calls `stat(target, ...)` to
see whether the target exists and is a directory.
The problem is that this `target` can be a relative path, and the link
path can _also_ be a relative path. Example: `symlink("dir", "uh/oh")`.
In this example, the target might say `dir`, but it is relative to
`uh/oh`, i.e. we need to `stat("uh/dir", ...)`.
This is necessary to pass the `cp` tests because they first create such
a directory symlink and then try to copy it while dereferencing
symlinks, i.e. calling `opendir()` on the symlink.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
Make is_absolute_path() a function rather than a macro and move it
from ash.c into mingw.c.
|
|
Investigating why free(1) wasn't working on Windows 7 I found it's
possible for LoadLibraryEx to fail with exactly the flags we're
using. Work around this.
This probably also explains GitHub issue #204.
|
|
- If 'which' is run from an executable called 'which.exe' it
suggests we aren't in a standalone-shell-mode shell. Don't
run any standalone-shell-specific code.
- Use case-insensitive comparisons when testing the names of
executables.
- When the argument is 'busybox' any executable name starting
with 'busybox' should match.
- Since 'busybox' is now treated as an applet in standalone shell
mode there's no need to test for this explicitly.
|
|
Use another API call: EnumPageFiles(). This seems to provide more
reliable information about page file usage than the previous ad hoc
method. It also allows the call to GlobalMemoryStatusEx() to be
removed.
With these changes free(1) works sensibly on Windows XP, though not
ReactOS.
|
|
These items are already listed, albeit without `.exe` suffix.
Presumably, this is because BusyBox-w32 is traditionally cross-compiled
on Linux.
However, we are about to introduce a CI build definition that builds
BusyBox-w32 in MSYS2 (using mingw-w64-gcc), meaning that those
executables might very well exist _with_ `.exe` suffix.
Let's ignore those, too.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
|
|
The Windows/MSYS2/mingw-w64 toolchain has platform-specific
prefixes on many of its binaries but not all. As a result the
mingw cross-compilation configurations *nearly* work.
If we're cross compiling and the generated name $AR doesn't exist
as a binary assume were using MSYS2 and make the necessary tweaks.
|
|
On Windows, you cannot `rename(source, target)` if `target` exists or if
a file handle to `source` is still open.
This patch is similar in spirit to 02958a6ee (kbuild: simulate
force-renaming on Windows, 2017-02-01).
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
There seems to be a bug in the Windows/MSYS2/mingw-w64 toolchain
which results in the generated win32/resources/built-in.o lacking
relocation data.
Forcing an actual C program to be linked along with the resources
appears to be an effective workaround.
When the toolchain bug is resolved this commit can be reverted.
See GitHub issue #200.
|
|
To investigate GitHub issue #200 it was necessary to perform
build on Window using the MSYS2/mingw-w64 toolchain. This
threw up some issues:
- The settings for _WIN32_WINNT and __USE_MINGW_ANSI_STDIO differ
from those in Fedora resulting in compiler errors and warnings.
Force the defaults I'm used to.
- The workaround to allow native compilation of mconf.c was broken
by a subsequent upstream change. Make it work again.
|
|
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.
|
|
Fill the uptime member of the sysinfo structure. With this change
we can:
- use sysinfo(2) in the 'ps' applet;
- enable the 'uptime' applet (though without useful support for
load averages).
|
|
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.
|
|
Use the WIN32 API GetProcessAffinityMask() to obtain the number
of processors configured and the number available to the current
process. This only works for up to 64 processors.
|
|
Commit b0b7ab792 (winansi: code shrink) noted that combining reverse
vidoe escape sequences (e.g. ESC[7;27m) didn't work properly.
Make further changes to improve the situation:
- revert to keeping the current attributes in a static variable;
- when reverse video is enabled switch the intensity as well as the
colour components;
- move the code from set_console_attr() into its only caller,
process_escape();
- use 0xffff instead of 0 as a flag to indicate the attributes
haven't been initialised.
Saves 44 bytes and seems to work better.
|
|
|
|
|
|
The alternative console screen buffer (used by less and vi) doesn't
work in Wine.
Setting the environment variable BB_ALT_BUFFER to 0 causes a screen
reset instead.
|
|
Running the test suite on Wine failed because in
seq 4 0 8 | head -n 10
'seq' didn't detect the broken pipe when 'head' terminated and
carried on forever. Fix this by adding a call to ferror(3) in
winansi_vfprintf().
Also, use xstrdup() and xmalloc() in a couple of places.
|
|
Since there's only one call to mingw_spawn_forkshell() we might
as well just call spawnve() directly from ash.
|
|
|
|
|
|
Rewrite the recent change to tab completion so it only needs
one call to sprintf. Then replace sprintf with strcpy/stpcpy,
both there and in a couple of other places.
Saves 40 bytes.
|
|
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.
|
|
Windows distinguishes between symlinks to directories and files.
A symlink to a directory must be deleted by calling rmdir(2)
rather than unlink(2).
|
|
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.
|
|
Commit 9e341902d (libbb: copy entire match during tab-completion)
adjusted the display of matches during tab completion to make any
changes in case visible.
Unfortunately the presence of quoted special characters upsets
the display:
$ touch t+1+2+3 t+1+4+5
$ ls t+1<TAB>
changes the command to:
$ lst\+1\+
In such cases just revert to the upstream code which only displays
the tail of the match, giving:
$ ls t+1\+
|
|
|
|
|
|
Mark floating-point constants as being of type 'float'.
Saves 72 bytes.
|
|
|
|
Use a more accurate technique to map RGB colours to standard
Windows console colours. Since this costs 648 bytes it's
configurable but is enabled by default.
|
|
Refactor handling of ESC[38...m and ESC[48...m:
- At lower levels deal only with the standard console foreground
colours. This makes handling of foreground and background colours
more similar.
- Many '|=' assignments (to combine attribute values) have been replaced
by simple assinments.
- Use a common routine to convert RGB to console colours; colours
in the 8-bit 6x6x6 cube are scaled up to make use of this.
- Detect invalid escape sequences to avoid setting incorrect colour
values.
Saves 296 bytes.
|
|
Don't compile some code that isn't currently supported for WIN32.
Saves 24 bytes.
|
|
|
|
function old new delta
fputs_stdout - 12 +12
zxc_vm_process 7237 7230 -7
yes_main 85 78 -7
write_block 380 373 -7
wrapf 305 298 -7
strings_main 437 430 -7
show_bridge 353 346 -7
rev_main 384 377 -7
put_prompt_custom 58 51 -7
put_cur_glyph_and_inc_cursor 168 161 -7
print_numbered_lines 152 145 -7
print_named_ascii 130 123 -7
print_name 135 128 -7
print_login_issue 386 379 -7
print_ascii 208 201 -7
powertop_main 1249 1242 -7
od_main 1789 1782 -7
logread_main 518 511 -7
head_main 804 797 -7
display_process_list 1319 1312 -7
cut_main 1002 995 -7
bb_dump_dump 1550 1543 -7
bb_ask_noecho 393 386 -7
baseNUM_main 702 695 -7
expand_main 755 745 -10
dumpleases_main 497 487 -10
write1 12 - -12
putcsi 37 23 -14
print_login_prompt 55 41 -14
paste_main 525 511 -14
cat_main 440 426 -14
print_it 245 230 -15
print_addrinfo 1188 1171 -17
print_rule 770 750 -20
print_linkinfo 842 822 -20
httpd_main 791 771 -20
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/34 up/down: 12/-341) Total: -329 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Use a NULL value of maxsz_p to indicate to xmalloc_fgets_internal()
that the caller doesn't care about the maximum size of the buffer.
This allows the default maximum size to be set once in
xmalloc_fgets_internal() instead of separately in each caller.
function old new delta
xmalloc_fgets_internal 273 287 +14
xmalloc_fgets_str 30 9 -21
xmalloc_fgetline_str 33 12 -21
xmalloc_fgets_str_len 38 10 -28
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 14/-70) Total: -56 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Upstream printf outputs one character at a time which doesn't
play well with emulation of ANSI escape sequences. Previous
workarounds for this only applied in limited circumstances.
Try a different approach: replace putchar() and printf() calls
in the printf applet with custom routines which store the output
in memory. It's only really output at the end of the program or
when a newline is detected and a non-trivial amount has been
collected.
|
|
Extend ANSI emulation to include:
ESC[38;2;R;G;Bm 24-bit foreground colour
ESC[48;2;R;G;Bm 24-bit background colour
ESC[38;5;Nm 8-bit foreground colour
ESC[48;5;Nm 8-bit background colour
The colours are selected from the 16 standard console colours.
This is unlikely to be aesthetically pleasing but at least it's
better than raw escape sequences.
Also, add ESC[9m (strike through) as a known but unsupported
sequence.
|
|
Change the default 'skip ANSI emulation' setting which is used when
the environment variable BB_SKIP_ANSI_EMULATION is unset. Previously
it was 0 (always emulate) now it's 2 (detect whether or not the
terminal supports ANSI escape sequences and behave accordingly).
The default value is also now a build-time option.
|
|
The command 'nl -b n' should output no line numbers, just some
spaces as a placeholder followed by the actual file content.
Add tests for line numbering by cat and nl. The correct results
were obtained from coreutils.
function old new delta
print_numbered_lines 152 157 +5
.rodata 182456 182453 -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 5/-3) Total: 2 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
'[-p N]' should be '[-P N]' in the trivial usage message.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Selection of ranges for change/delete/yank by forward character
motion commands (SPACE or 'l') was incorrect. The range was
always one character whereas vi allows the size of the range to
be specified.
Fix this by executing the motion command the required number of times.
There is a complication when the range is at the end of a line. We need
to distinguish between a range which excludes the last character and
one which includes it. This requires comparing the actual range with
that expected from the command count. (With the additional quirk that
a command count of zero is equivalent to a command count of one.)
function old new delta
find_range 587 619 +32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 32/0) Total: 32 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|