summaryrefslogtreecommitdiff
path: root/win32 (unfollow)
Commit message (Collapse)AuthorFilesLines
2022-05-23win32: changes to stat(2) implementationFRP-4716-g31467ddfcRon Yorston1-15/+22
- 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.
2022-05-23win32: code shrink fstat(2)Ron Yorston1-11/+8
Reduce duplicated code. Saves 16-48 bytes.
2022-05-22win32: let stat(2) return correct st_size for symlinkRon Yorston1-5/+8
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.
2022-05-22win32: code shrink readlink(2)Ron Yorston1-32/+12
Use PrintName rather than SubstituteName from the reparse data buffer. This avoids the need to normalise the name. Saves 240 bytes.
2022-05-22win32: code shrink directory testsRon Yorston1-15/+19
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.
2022-05-20ash: code shrinkRon Yorston1-46/+50
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.
2022-05-19chattr,lsattr: improve help messagesRon Yorston3-6/+26
List all attributes in the help from lsattr. Minor changes to attribute names in output.
2022-05-19lsattr: distinguish between junctions and symlinksRon Yorston3-3/+47
Use the new st_tag member of struct stat to display whether a reparse point is a junction or a symlink.
2022-05-19win32: return reparse tag in struct statRon Yorston2-6/+15
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.
2022-05-19chattr,lsattr: code shrinkRon Yorston4-51/+20
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.
2022-05-18ash: restore special variables when replaced by localRon Yorston1-0/+4
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)
2022-05-17jn: make junctions acceptable to WindowsRon Yorston1-5/+9
Junctions created by 'jn' contained incorrect data: the length of the target name was off-by-one. (GitHub issue #251)
2022-05-16jn: new appletRon Yorston5-1/+172
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.
2022-05-15win32: try to get link count for directoriesRon Yorston3-1/+36
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)
2022-05-14win32: treat junctions as symlinksRon Yorston1-6/+13
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)
2022-05-12Update default configurationRon Yorston2-2/+6
2022-05-11lineedit: case-insensitive matching for '~'Ron Yorston1-0/+4
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.
2022-05-10win32: make default PATH more likely to workRon Yorston1-7/+10
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)
2022-05-10top: code shrinkDenys Vlasenko1-11/+9
function old new delta display_process_list 1186 1168 -18 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-05-10top: code shrinkDenys Vlasenko1-11/+14
function old new delta display_process_list 1191 1186 -5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-05-10top: fix display of large PID/PPIDDenys Vlasenko1-2/+28
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>
2022-05-10ash: code shrinkRon Yorston1-2/+1
Changing one of the constants used by is_bb_var() saves a few bytes in the 32-bit build.
2022-05-08ash: export certain variables to the environment immediatelyRon Yorston6-6/+60
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.
2022-05-07win32: fix 'cd' to symlink with relative path as targetRon Yorston1-1/+1
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)
2022-05-07ash: don't set OLDPWD on startupRon Yorston1-1/+2
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)
2022-05-06win32: allow preference for applets to be disabled at runtimeRon Yorston4-5/+61
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.
2022-05-06win32: search PATH for missing Unix-style executablesRon Yorston4-59/+74
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.
2022-05-05win32: better fix for empty environment variablesRon Yorston3-9/+75
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)
2022-05-04win32: revert changes related to environment variablesRon Yorston2-12/+21
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)
2022-05-03win32: new code to set empty environment variableRon Yorston1-12/+8
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)
2022-05-03seedrng: do not hash in a constant string, it's not adding entropyDenys Vlasenko1-8/+8
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>
2022-05-02seedrng: restore error check on fsyncDenys Vlasenko1-9/+12
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>
2022-05-02seedrng: it's not a part of util-linux, move to miscutilsDenys Vlasenko1-0/+0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-05-02init: do not set HOMEDenys Vlasenko1-1/+5
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>
2022-05-02tsort: new appletDavid Leonard3-1/+299
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>
2022-05-02crond: implement support for setting PATH in crontab filesPaul Fox1-7/+16
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>
2022-05-01style fixDenys Vlasenko7-9/+9
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-05-01seedrng: manually inline seed_rngBernhard Reutner-Fischer1-21/+15
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>
2022-05-01seedrng: shorten --help, assorted small cleanupsDenys Vlasenko1-11/+10
function old new delta packed_usage 34295 34290 -5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-05-01seedrng: reduce MAX_SEED_LEN from 512 to 256Denys Vlasenko1-1/+5
As proposed by Jason. getrandom() is more likely to block on reads larger than this. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-05-01which,ash: changes to which/command/typeRon Yorston4-23/+67
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)
2022-05-01seedrng: do not hash lengths, they are very predictableDenys Vlasenko1-3/+5
function old new delta seedrng_main 982 930 -52 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-05-01seedrng: code shrinkDenys Vlasenko1-8/+10
function old new delta seedrng_main 994 982 -12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-05-01seedrng: explain why we need locking and fsync'ingDenys Vlasenko1-8/+18
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>
2022-04-30seedrng: remove redundant assignmentDenys Vlasenko1-3/+3
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-04-30seedrng: re-add fsync after unlink, and explain its purposeDenys Vlasenko1-1/+12
function old new delta seedrng_main 1003 1022 +19 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-04-30seedrng: include fiel/dir names in error messagesDenys Vlasenko1-3/+3
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>
2022-04-30seedrng: use more xfuncs where appropriateDenys Vlasenko1-12/+12
function old new delta .rodata 104929 104898 -31 seedrng_main 1050 1011 -39 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-04-30seedrng: code shrinkDenys Vlasenko1-5/+5
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>
2022-04-30seedrng: simplify read_new_seed() to not have error returnDenys Vlasenko1-14/+17
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>