| Commit message (Collapse) | Author | Files | Lines |
|
- Use repeated calls to readlink(2) rather than xmalloc_realpath()
when asked to follow symlinks.
- Drop the non-standard feature that caused readlink(2) to return
only the target string length.
This improves compatibility with BusyBox on Linux at a cost of
16-32 bytes.
|
|
Reduce duplicated code. Saves 16-48 bytes.
|
|
Previously stat(2) set st_size to the length of the canonicalised
symlink target. Call readlink(2) to get the actual length of the
target string.
|
|
Use PrintName rather than SubstituteName from the reparse data
buffer. This avoids the need to normalise the name.
Saves 240 bytes.
|
|
Add a function to check if a file is a directory and use it in
various places.
Replace some uses of S_ISDIR() with a test of the Windows file
attributes.
Saves 32-48 bytes.
|
|
Commit 6f8b2f450 (ash: forkshell code shrink) noted that certain
global variables were being passed around in the forkshell structure
unnecessarily.
In fact, since the variables are global there's no need to pass
them to the *_size()/*_copy() functions at all. This only saves
32 bytes of bloat (the compiler got there ahead of us) but it does
make the code tidier.
|
|
List all attributes in the help from lsattr.
Minor changes to attribute names in output.
|
|
Use the new st_tag member of struct stat to display whether a
reparse point is a junction or a symlink.
|
|
If a file is a junction or symlink return its tag in the st_tag
member of struct stat.
get_symlink_data() and is_symlink() also return the tag or zero,
as appropriate.
|
|
Drop fgetsetflags() and move its functionality into chattr and
lsattr. Raw file attributes are available from struct stat.
In chattr don't compile code related to the unused (on Windows)
OPT_SET option.
|
|
Commit 3194a475d (ash: export certain variables to the environment
immediately) caused the special variables BB_OVERRIDE_APPLETS,
BB_SKIP_ANSI_EMULATION and BB_SYSTEMROOT to be exported to the
environment.
If one of these variables is replaced by a local variable its
previous value should be re-exported on leaving the local context
(function or simple command).
(GitHub issue #256)
|
|
Junctions created by 'jn' contained incorrect data: the length
of the target name was off-by-one.
(GitHub issue #251)
|
|
Add a Windows-specific applet to create a directory junction.
Usage: jn DIR JUNC
where DIR must be an existing directory on a local drive and JUNC
must not currently exist.
There isn't a simple WIN32 API to create directory junctions.
The implementation of mklink in ReactOS provided useful inspiration.
|
|
On Unix the link count of a directory reflects the number of
subdirectories it contains. Enhance readdir(3) to return file
types and use this to count subdirectories when stat(2) is called
for a directory.
As with other features that might slow down stat(2) this is
controlled by the build-time setting FEATURE_EXTRA_FILE_DATA.
(Commit d82db8e9a 'win32: make stat(2) fetch additional metadata').
(GitHub issue #254)
|
|
Directory junctions were always followed to their target so they
appeared to *be* directories. This resulted in counter-intuitive
behaviour:
- a directory junction could be removed with rmdir even though
the directory wasn't empty;
- 'rm -rf' on a directory junction deleted it but also deleted
the contents of the linked directory.
A better approximation is to treat directory junctions as
symbolic links.
(GitHub issue #254)
|
|
|
|
Use case-insensitive matching when determining if the directory
name in the prompt can be shortened using '~'.
This doesn't seem to have been a problem, as directories are often
canonicalized, but it doesn't have any great cost.
|
|
The default PATH defined as BB_PATH_ROOT_PATH is used:
- to set PATH in the shell if the environment variable doesn't exist;
- as the default in 'which' if there's no PATH env var;
- when the option 'command -p' is given.
Replace the Unix-centric default with something more likely to work
on Microsoft Windows. No guarantees, though.
(GitHub issue #253)
|
|
function old new delta
display_process_list 1186 1168 -18
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
function old new delta
display_process_list 1191 1186 -5
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
function old new delta
display_process_list 1077 1191 +114
.rodata 104803 104807 +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 118/0) Total: 118 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Changing one of the constants used by is_bb_var() saves a few bytes
in the 32-bit build.
|
|
The environment variables BB_OVERRIDE_APPLETS, BB_SKIP_ANSI_EMULATION
and BB_SYSTEMROOT affect of the behaviour of the shell itself.
Setting them as shell variables is insufficient for them to affect
the current shell.
When these three variables are exported from the shell they are
now placed in the environment immediately. Conversely, when
they're unset or unexported they're removed from the environment.
|
|
Commit 69d328022 (win32: track current directory of mapped drives)
replaced a call to xmalloc_realpath() with one to xmalloc_readlink().
This was incorrect. Although the argument is now guaranteed to
be a symlink it's still necessary to resolve it to an absolute path.
Otherwise the fix in commit 585d17d26 (win32: canonicalize path in
chdir(2)) doesn't work for symlinks with a relative path as their
target.
(GitHub issue #147)
|
|
Commit f9b753e70 (ash: set current working directory on startup)
set the current working directory of an interactive, non-login
shell during startup to ensure drives mapped to a network share
and symlinks were reported correctly.
It had the side effect of setting OLDPWD. This is unnecessary
because the current working directory won't have changed.
(GitHub issue #253)
|
|
The default busybox-w32 configuration enables the PREFER_APPLETS
and SH_STANDALONE features. Sometimes it may be desirable to
override the default preference for applets, for example, if an
applet needs to be replaced by an external program with additional
features.
Add support for the environment variable BB_OVERRIDE_APPLETS.
Its value may be:
- a single dash ('-'): all applets are overridden;
- a space-separated list of names: only the specified applets
are overridden.
|
|
Commit 41ef232fc5 (win32: use built-in applets for non-existent
binaries with Unix-style paths) alters what happens when trying
to find an executable. If all of the following apply:
- the pathname starts with one of the standard directories for Unix
executables (/bin, /usr/bin, /sbin, /usr/sbin);
- the file isn't found relative to the system root;
- the basename matches an applet
then the applet is run.
Further extend the procedure so that if the first two conditions are
met and either:
- the PREFER_APPLETS and SH_STANDALONE features are enabled and the
basename *doesn't* match an applet
or
- the PREFER_APPLETS and SH_STANDALONE features are disabled
then PATH is searched for the basename.
This affects:
- how interpreters and binaries are spawned by mingw_spawn_interpreter()
and mingw_spawnvp();
- how 'which' and the shell search for binaries.
Special steps need to be taken in the shell to avoid treating shell
built-ins and functions as applets.
As a consequence of this change:
- An executable that isn't an applet, say curl.exe, can be run as
/usr/bin/curl so long as it's in a directory in PATH. It doesn't
have to be in C:/usr/bin.
- If the PREFER_APPLETS and SH_STANDALONE features are disabled binaries
can be run using paths referring to standard Unix directories even if
they're installed elsewhere in PATH.
|
|
It appears the CRT and OS each have a copy of the environment.
mingw_putenv() fools the CRT into accepting an empty environment
variable by calling _putenv("V=0") then truncating the new value
by hand. But _putenv() also updates the OS environment with the
fake 'V=0' value. Commit 5b48ca53b (win32: pass NULL to spawnve,
not environ) resulted in this fake value being used and hence empty
variables getting the value '0'.
- Add a call to SetEnvironmentVariable() in mingw_putenv() to update
the OS environment.
- Restore the use of NULL environment pointers in mingw_spawnvp().
- Add a test.
(GitHub issue #250)
|
|
Revert the change to mingw_putenv() in the previous commit.
When compiling for MSVCRT (i.e. not for UCRT) revert some of the
changes from commit 5b48ca53b (win32: pass NULL to spawnve, not
environ).
(GitHub issue #250)
|
|
Windows environment variables: a never-ending source of fun.
It seems the recent hack to work around problems in UCRT breaks
the hack to set empty environment variables. The change to the
empty variable isn't reflected in the environment seen by the C
runtime.
Use the WIN32 API to set the empty variable then set a dummy
variable to make the C runtime take notice.
(GitHub issue #250)
|
|
function old new delta
seedrng_main 906 880 -26
.rodata 104899 104873 -26
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-52) Total: -52 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Or else security people will never stop nagging us.
function old new delta
seedrng_main 884 906 +22
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
function old new delta
.rodata 104906 104899 -7
init_main 786 776 -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-17) Total: -17 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
function old new delta
tsort_main - 578 +578
.rodata 104884 104906 +22
applet_names 2759 2765 +6
applet_main 1596 1600 +4
packed_usage 34290 34288 -2
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/1 up/down: 610/-2) Total: 608 bytes
Signed-off-by: David Leonard <d+busybox@adaptive-enterprises.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
It's very inconvenient for a cron user not to be able to set a
"personal" PATH for their cron jobs, as is possible with other crons
function old new delta
load_crontab 868 942 +74
.rodata 104878 104884 +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 80/0) Total: 80 bytes
Signed-off-by: Paul Fox <pgf@foxharp.boston.ma.us>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
We can now remove a separate buffer
function old new delta
seedrng_main 930 884 -46
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
function old new delta
packed_usage 34295 34290 -5
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
As proposed by Jason.
getrandom() is more likely to block on reads larger than this.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
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)
|
|
function old new delta
seedrng_main 982 930 -52
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
function old new delta
seedrng_main 994 982 -12
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Also, do not test for locking errors: on Linux, they do not happen.
function old new delta
.rodata 104900 104878 -22
seedrng_main 1022 994 -28
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
function old new delta
seedrng_main 1003 1022 +19
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
function old new delta
.rodata 104898 104900 +2
seedrng_main 1011 1003 -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 2/-8) Total: -6 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
function old new delta
.rodata 104929 104898 -31
seedrng_main 1050 1011 -39
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Struct initializers do this double init:
># util-linux/seedrng.c:88: struct pollfd random_fd = {
movl $0, 132(%esp) #, random_fd
movl $0, 136(%esp) #, random_fd
...
># util-linux/seedrng.c:88: struct pollfd random_fd = {
movl %eax, 140(%esp) # _110, random_fd.fd
movw $1, 144(%esp) #, random_fd.events
and close(random_fd.fd) needs to pull the item from the stack:
pushl 132(%esp) # random_fd.fd
call close #
function old new delta
seedrng_main 1076 1050 -26
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
gcc in fact detects this and does this transformation
when generating code - no object code changes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|