| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
| |
The user supplies field numbers with the -o, -1 and -2 options.
It feels more natural to convert these to 0-based field indices
in the code.
Saves 32-48 bytes.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
| |
When splitting the fields of a line, keep the string allocated
for the line and make the 'fields' array point into it rather
than allocating a new string for each field.
Saves 48 bytes.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Reduce the amount of duplicated code in readfields() by handling
a pushed back line inside the main loop, with a flag to indicate
the first pass through the loop.
Replace some memcpy() calls with structure assignments.
Fix a bug in the code to increase the size of the 'lines' array.
It set the capacity to either 8 or 0.
Saves 112-128 bytes.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Update the 'rpm' applet so it also respects the BB_SYSTEMROOT
environment variable.
Replace chdir_system_drive() with xchdir_system_drive(), which
exits on failure to change directory.
Saves 32-36 bytes.
(GitHub PR #603)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* dpkg: update prefix
The prefix now works properly with BB_SYSTEMROOT as it no longer
writes everything with a prefixed /
For example, with BB_SYSTEMROOT=C:/somepath, the /var/lib/dpkg directory
is now underneath that, rather than the root of that drive.
Also added handling so that the extracted files are also there.
* dpkg: prefix updates
For clarity, the .list files now always include leading slashes,
matching what happens in upstream.
There is then special handling under remove_file_array to turn them
back into relative paths. The handling assumes that files can be both,
since it does get called with some relative paths.
Adds 14-54 bytes.
|
| |
|
|
|
|
|
|
|
|
|
| |
Background jobs were being reported in shells other than an
interactive, top-level shell.
Suppress this unnecessary report.
Adds 16 bytes.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This script:
#!/bin/bash
(
( true ) &
( true ) &
( true ) &
( true ) &
( true ) &
)
resulted in a crash. The problem was introduced by commit
7b692ddf0c (ash: improved support for jobs built-in). This
commit copies the job table into child shells for use by the
'jobs' built-in.
The crash happens because when the job table is cleared in the
child it becomes available for reuse. If only four jobs are
required this is OK but going over four causes the table to be
reallocated. This doesn't work because in the child it's in
shared memory.
The fix is not to pass the job table to the child unless it's
required by the 'jobs' built-in. This is also more efficient.
Adds 0-16 bytes.
(GitHub issue #604)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Adopt some BusyBox idioms in join_main(). In particular:
- The '-a' and '-v' options are mutually exclusive. Enforce this
in getopt32() instead of by hand. Also, since they're mutually
exclusive we don't need a distinct list for each.
- Control some clean-up code with ENABLE_FEATURE_CLEAN_UP.
There are also a few cosmetic changes.
Saves 204-256 bytes.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
'make bloatcheck' didn't work in the ARM build because it didn't
handle the different output formats of llvm's 'objdump' and 'nm'.
Allow for 'objdump -h' printing 5 rather than 7 fields. This at
least gets us some output. 'nm' always seems to print symbol
sizes of zero, though, which isn't very useful.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
| |
Make the corners of the symbolic bitmap icon look more rounded.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
Reduce the colour depth of the bitmap icons from 24-bits colour/
8-bit alpha to 8-bit colour/1-bit alpha for aterm.ico and 1-bit
colour/1-bit alpha for sterm.ico.
This reduces the size of the standard builds by 21KB. The builds
targeting Windows 10/11 already used smaller PNG icons.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Recent changes to our mntent routines added support for Windows
volume names. If such a name is available use it in our sync(2)
implementation to flush file buffers. Failing that, use the drive
letter as before.
This handles edge cases where only one or other of the volume name
or drive letter is available.
Adds 32 bytes.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
| |
One Windows-specific line of code wasn't protected by #ifdef.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Revert "find: reset stat(2) flags before terminating"
This reverts commit 228ee18fbe8cf408440e7bbe91db4ef201312983.
* test: fix flags for stat with NOFORK
test is a NOFORK applet, so the flags under mingw_stat may not have been
reset before calling it. We have it so it also restores the flags after,
since it could be called in the middle of another applet.
This also needed a way to retrieve the flags, so they are just done
through the return value.
* Add comments about not having to restore flags
Just for future reference
* lineedit: use new flag restoring
* win32: simplify mingw_access calling
Since we now have a way to get the previous flags, mingw_access can be
changed to ignore any stat flags
* stat: comments from PR
Adds 32 bytes.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit a717c6844 (find: skip check for execute when not needed)
didn't reset stat(2) to its default behaviour (at my insistence).
This was incorrect. The '-exec cmd {} +' action calls a nofork
'cmd' directly without spawning a new process. If 'cmd' calls
'stat(2)' it won't be in its default state which can affect the
result.
Reintroduce the code to reset 'stat(2)'.
Adds 16 bytes.
(GitHub PR #600)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
See previous commits:
1fb1a65064748a54fba4bf4b5e8700f8e61f003f
6a7ccb6ca3bd9b661760879478ecf0d5f6112fc3
My testing shows a speedup of around 30%, but that will vary with
whether files are cached.
Test inside busybox repository with files cached:
Command | before | after
find >/dev/null | 0.83s | 0.56s
find -executable >/dev/null | 1.56s | 1.35s
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Update 'lsattr' to distinguish between mount points and junctions.
Use the new 'mntent' functions in 'df' to display mount points as
well as drive letters. If mount point is associated with a drive
letter this is displayed as the filesystem. The Windows-specific
'-w' option forces the volume name to be displayed instead, if
avaialable.
Adds 87-111 bytes.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add code to distinguish between volume mount points and junctions.
Volume mount points are to be treated like directries while
junctions are like symlinks.
Update the 'mntent' functions to scan drive letters first, then
volume names and their associated mount points. By default the
filesystem is returned as a drive letter, if possible, though
the volume name is also returned.
The function 'find_mount_point()' has been updated to use the
new 'mntent' routines.
Adds 772-803 bytes.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
The shell builtin 'pwd' takes a Windows-specific '-a' option to
display the current directory on each drive.
Use Windows APIs directly to scan for valid drives instead of
'getmntent()'. Future changes will result in 'getmntent()'
returning mounted volumes as well as drives.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 62e4c5d29 (win32: special treatment for virtual hard disk)
added special treatment for mount points associated with virtual
hard disks. One statement made there was incorrect: a VHD without
a drive letter containing no files *does* have a '.' directory.
The error message for this case was misleading.
The changes made to handle VHDs were insufficiently general:
- lstat(2) only resolved symlinks for the explicit path '.'.
It should also do so for paths of the form 'path/to/.'.
- opendir(3) only generated entries for '.' and '..' directories
when FindFirstFileA() failed for the path '.'. It should also
do so for any path which resolves to a volume mount point.
Make the necessary changes.
Adds 64-80 bytes.
(GitHub issue #597)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Virtual hard disks (VHD) without a drive letter gave incorrect
results in 'ls' and 'stat'. There were two problems:
- If the disk is empty it doesn't have a '.' directory.
- If it contains files the '.' directory is actually the mount
point, which looks like a symbolic link and can't be opened
as a directory.
Modify our 'stat(2)' and 'opendir(3)' implementations to handle
these quirks.
Adds 78-80 bytes.
(GitHub issue #597)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If busybox.exe was started from a Windows command line in a
directory which was the target of a symlink (or equivalent) 'ls'
and 'stat' were unable to report the correct details of the current
directory.
Call 'chdir()' from the BusyBox main program to update our notion
of our current directory.
Adds 16 bytes.
(GitHub issue #597)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Running 'C:/Windows/System32/cmd.exe' from the shell was found to
have the unxpected result of creating the directory '.exe'. This
is due to the weirdness of cmd.exe.
A similar problem with batch files was already being handled in
`spawnveq()` by converting forward slashes to backslashes in the
path to the executable file. Doing this unconditionally will fix
the above case too.
(GitHub issue #598)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The 'lsattr' applet identified three specific types of reparse
points: junctions, symbolic links and app exec links. Any other
type was just shown as a reparse point.
A junction is actually a specific type of mount point; a volume
mount is another. The description 'junction' has been changed to
the more generic 'mount point'. 'lsattr' doesn't distinguish
between volume mounts and junctions.
Change the help text to say 'Unidentified reparse point' for reparse
point which aren't a mount point, symlink or app exec link.
Adds 29 bytes.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
It was reported that a mounted volume looked like a broken symlink
and that changing to the mount directory failed.
Preserve the format of the volume name when resolving the link.
Adds 84-96 bytes.
(GitHub issue #597)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit bda604a70 (ash: prevent leakage of process handles) added
job tracking for process substitutions. This had the unwanted
side-effect that if the user tried to exit from the shell after
a command involving process substitution the shell reported that
background jobs were present and refused to exit.
Use the flag introduced in commit e6c716317 (ash: don't report
completion of process substitution) to avoid this.
Adds 16 bytes.
(GitHub issue #587)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
| |
The current implementation of 'stty' for Windows only uses a
limited subset of the flags in 'struct termios'. Remove some
unused features.
Saves 16-40 bytes.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
If echo has been disabled by the command 'stty -echo' the shell
'read' built-in should match its behaviour on Linux and not echo
keyboard input.
Adds 32-48 bytes.
(GitHub issue #594)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit a560fdf23 (win32: better handling of console state) changed
to using CONIN$/CONOUT$ to handle terminal modes.
In tcgetattr() CONOUT$ was used instead of CONIN$, leading to
incorrect mode bits being fetched.
Saves 8-16 bytes.
(GitHub issue #594)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When 'stty size' was run in a command substitution with stderr
redirected or 'stty -echo' with stdin redirected, it failed to
work properly. The redirections broke its connection to the
terminal.
To fix this, ioctl/tcsetattr/tcgetattr have been modified to use
CONIN$ or CONOUT$ to access the screen buffer. Using CON isn't
an adequate substitute in this case.
Also, if ioctl(fd, TIOCGWINSZ) fails, set errno.
Adds 112-116 bytes.
(GitHub issue #594)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
| |
Tab completion as arguments no longer reads a bit of each file to detect
whether it is executable.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The 'reboot' special time didn't work because the file to check
for a reboot couldn't be created. And in any case, the mechanism
used on Linux wouldn't work: Windows has no /var/run directory
which is cleared on reboot.
The crond.reboot file is now placed in the cron directory. If it
doesn't exist when crond starts, it's created but the reboot job
(if any) isn't run. If the file exists its modification time is
compared with the time of the current boot. If it's older update
its time and run the reboot job.
Adds 144-224 bytes.
|
| |
|
|
|
|
|
| |
Since we don't use syslog on Windows there's no point in having
an option to set it. Log to stderr by default instead.
Saves 88-96 bytes.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some users want a 'portable' busybox-w32 installation on removable
media. To help with this, certain files can be positioned relative
to the location of the executable.
crond and crontab now look for var/spool/cron/crontabs relative
to the binary, and use that as their working directory if it exists.
If it doesn't, fall back to the hardcoded absolute path. The '-c'
command line option can still be used to override the automatic
choice.
The '-c' option in crond now updates the cron directory variable as
well as that for crontabs.
Adds 128-144 bytes.
|
| |
|
|
|
|
|
| |
GCC 16 has an optimised memmove which inflates 64-bit builds by
20KB. This shouldn't happen with -Os, but it did. It's been
fixed in GCC, but until the new version trickles down to Fedora
44 explictly disabled the memmove built-in.
|
| | |
|
| |
|
|
|
| |
Add a note about excluding busybox.exe from monitoring by Windows
security.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If 'ls' is invoked without the '-l' option (or something that's
equivalent) and colour output isn't required, there's no need to
perform the expensive check for execute permission.
Allow 'ls' to inform stat(2) not to call has_exec_format(). This
has been combined with the existing mechanism to enable counting
subdirectories.
With this change the command 'ls | wc -l' used in issue #589
doesn't perform the test which upset Windows' anti-malware thing.
Adds 32-48 bytes.
(GitHub issue #589)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Commit bda604a70 (ash: prevent leakage of process handles) added
job tracking for process substitutions. This had the unwanted
side-effect that the completion of such processes was then
reported in interactive shells.
Set a flag in such jobs so their completion isn't reported.
Adds 32 bytes.
(GitHub issue #587)
|
| |
|
|
|
|
|
|
|
|
|
| |
Among the tests for 'ls' there are some for how it displays a
filename containing non-printable characters. These fail on
Windows because most of the characters used aren't allowed in
filenames there. This can cause the test process to hang.
Skip these tests on Windows.
(GitHub commit #592)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
When the shell invoked process substitution it retained a process
handle to the child. These handles could accumulate without limit.
The shell in upstream BusyBox doesn't bother to create a job
structure for process substitutions or here documents. This isn't
appropriate on Windows, where we need to track the child process
handles. Create job structures as required.
Saves 32-48 bytes.
(GitHub issue #587)
|
| |
|
|
|
|
|
| |
Now that /dev/urandom and /dev/zero can be used by all applets
there's no need to mention that dd has support for them.
Saves 32-56 bytes.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The 'ESC]J' sequence in 'reset' is unnecessary.
One or other of 'ESC]3J' and the explicit call to reset_screen()
should be sufficient, but the Win 10/11 terminal requires the
former while the Win 10 console requires the latter.
Saves 4 bytes in the 32-bit build.
(GitHub issue #161)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The 'reset' applet hasn't kept pace with developments elsewhere.
We now have support for 'stty sane', so the code in 'reset' which
calls that can be enabled.
Windows 10 and 11 have updated Terminal and Console programs, with
varying features and behaviours. Add ANSI emulation code to handle
clearing the scrollback buffer and use ANSI sequences in 'reset'
to do that. It was also necessary to retain the explicit call to
reset_screen(), or 'reset' didn't work properly in the Terminal I'd
installed in Windows 10.
Adds 92-128 bytes.
(GitHub issue #161)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Commit c4f24ec9d (libbb: try to mitigate 'cat /dev/urandom')
resulted in a 'cat' to the terminal taking ~25% longer than
before.
Raising the isatty() call out of the loop reduces the penalty
to ~1%.
Adds 16 bytes in the 32-bit build.
(GitHub issue #585)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Now that '/dev/urandom' can be used directly, people with a sense
of curiosity and adventure have tried running 'cat /dev/urandom'
or 'cat </dev/urandom'.
The 'cat' applet in BusyBox is so efficient and ANSI escape
handling is so inefficient that this overwhelms the capabilities
of the Windows console or terminal to the extent that it's unable
to process Ctrl-C requests in a timely manner.
To give it a chance to catch up, force 'cat' to take a short nap
from time to time (very short, zero length) but only when it's
writing to a tty.
The call to Sleep() is in a separate function to avoid unnecessary
bloat in 32-bit builds, where its presence upsets the stack and
requires much larger code for stack access.
Adds 48 bytes.
(GitHub issue #585)
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commits e23652908 and 686a0803f (ash: fix execution of applets via
Unix-style path) were necessary following a major revision of the
shell upstream.
Another problem was found:
$ sh
$ PATH="/usr/bin;$PATH" exec non-existent
resulted in a segfault. This happened because during a PATH search
tryexec() modified argv[0] when it detected a Unix-style path (in
this case '/usr/bin/non-existent') but failed to restore it if the
execution failed.
There were other issues:
- The logic of the new code failed to match the original: the test
for a Unix-style path should only have happened if an attempt to
execute the full path had already failed.
- The test for a script running an interpreter which is an applet
also modified argv. If the execution failed argv should have
been restored to its original state.
- During a PATH search the 'path' pointer walked through the
elements of the path. This pointer was also used to determine
if an applet was overridden by an executable. This is wrong:
the full PATH variable should have been used.
The code around tryexec()/shellexec() has been rewritten to take
these issues into account.
Adds 32-48 bytes.
(GitHub issue #584)
|
| |
|
|
|
|
|
|
| |
It wasn't possible to build ash if FEATURE_SH_STANDALONE was
disabled.
This issue was introduced during the large merge of upstream
changes to ash in commit e23652908.
|
| |
|
|
|
| |
Silence a compiler warning that 'arg' is an unused variable if
neither stty nor ttysize is defined.
|