aboutsummaryrefslogtreecommitdiff
path: root/scripts/basic/Makefile (unfollow)
Commit message (Collapse)AuthorFilesLines
2026-07-02dpkg: update prefix (#603)mbartlett211-20/+53
* 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.
2026-06-30ash: only report background jobs in root shellRon Yorston1-1/+1
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>
2026-06-30ash: only copy jobtab if needed for job hackRon Yorston1-6/+9
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>
2026-06-30join: code shrinkRon Yorston1-35/+17
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>
2026-06-30build system: allow bloatcheck to work (a bit) for llvmRon Yorston1-1/+1
'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>
2026-06-26win32: tweak bitmap icon appearanceRon Yorston1-0/+0
Make the corners of the symbolic bitmap icon look more rounded. Signed-off-by: Ron Yorston <rmy@pobox.com>
2026-06-23win32: shrink bitmap iconsRon Yorston2-0/+0
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>
2026-06-23sync: handle certain edge casesRon Yorston1-2/+9
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>
2026-06-22test: fix POSIX buildRon Yorston1-0/+2
One Windows-specific line of code wasn't protected by #ifdef. Signed-off-by: Ron Yorston <rmy@pobox.com>
2026-06-22Fix the flags for stat (again) (#601)mbartlett216-30/+33
* 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.
2026-06-19find: reset stat(2) flags before terminatingRon Yorston1-1/+7
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>
2026-06-19find: skip check for execute when not neededmbartlett211-0/+25
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
2026-06-15df,lsattr: support Unix-like mount pointsmount_pointRon Yorston3-1/+24
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>
2026-06-15win32: Unix-like support for volume mountsRon Yorston5-98/+229
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>
2026-06-15ash: scan drives directly for 'pwd -a'Ron Yorston1-8/+6
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>
2026-06-08win32: extend handling of virtual disksRon Yorston3-7/+20
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>
2026-06-07win32: special treatment for virtual hard diskRon Yorston2-4/+14
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>
2026-06-06win32: update current directory to target of symlinkRon Yorston1-0/+4
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>
2026-06-06win32: avoid problems with forward slashes in path to cmd.exeRon Yorston1-3/+5
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>
2026-06-05lsattr: clarify output for reparse/mount pointsRon Yorston2-4/+4
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>
2026-06-04win32: special treatment for mounted volumesRon Yorston1-0/+9
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>
2026-05-31ash: don't treat process substitutions as background jobsRon Yorston1-3/+7
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>
2026-05-26stty: code shrinkRon Yorston2-4/+12
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>
2026-05-24ash: read built-in should respect stty -echoRon Yorston1-1/+11
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>
2026-05-22win32: fix incorrect change to tcgetattr()Ron Yorston1-1/+1
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>
2026-05-22win32: better handling of console stateRon Yorston2-25/+35
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>
2026-05-20win32: skip check for execute with tab-completionmbartlett211-0/+8
Tab completion as arguments no longer reads a bit of each file to detect whether it is executable.
2026-05-19crond: fix reboot special timeRon Yorston1-0/+31
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.
2026-05-19crond: drop '-S' optionRon Yorston1-5/+22
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.
2026-05-19crond,crontab: executable-relative cron directoriesRon Yorston2-4/+40
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.
2026-05-19win32: don't use built-in memmoveRon Yorston1-1/+1
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.
2026-05-18Add markup to README.mdRon Yorston1-1/+1
2026-05-18Update README.mdRon Yorston1-0/+1
Add a note about excluding busybox.exe from monitoring by Windows security.
2026-05-18win32: allow stat(2) to skip costly check for executeRon Yorston4-20/+43
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)
2026-05-17ash: don't report completion of process substitutionRon Yorston1-2/+20
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)
2026-05-17testsuite: skip tests for handling of non-printable charactersRon Yorston1-1/+8
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)
2026-05-13ash: prevent leakage of process handlesRon Yorston1-4/+7
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)
2026-05-12dd: remove note about /dev/urandom and /dev/zeroRon Yorston1-3/+0
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.
2026-05-12reset: code shrink and clarificationRon Yorston1-4/+3
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)
2026-05-11reset: add support for stty and Windows TerminalRon Yorston2-23/+22
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)
2026-05-10libbb: reverse performance regression in bb_copyfd_*Ron Yorston1-1/+4
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)
2026-05-08libbb: try to mitigate 'cat /dev/urandom'Ron Yorston1-0/+11
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)
2026-05-07Update README.mdRon Yorston1-1/+1
2026-05-06ash: further fixes to merge of upstream changesFRP-6075-g169694ebdRon Yorston1-24/+60
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)
2026-05-05ash: fix build failure if SH_STANDALONE is disabledRon Yorston1-0/+4
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.
2026-05-05win32: silence warning in ioctl(2)Ron Yorston1-0/+2
Silence a compiler warning that 'arg' is an unused variable if neither stty nor ttysize is defined.
2026-05-04win32: add FAST_FUNC annotationsRon Yorston23-238/+250
I've been far too lax in applying FAST_FUNC annotations. These can make function calls smaller and faster, but only on 32-bit systems and for non-static, non-variadic functions with non-void arguments. Saves 4680 bytes in the 32-bit build; 64-bit builds are unaffected.
2026-05-03crond: build tweaksRon Yorston8-42/+42
Using 'depends on FEATURE_SYSLOG' is unreliable because FEATURE_SYSLOG can't be set directly. A POSIX build with all applets that need syslog disabled *except* crond may fail. Revert to using 'select FEATURE_SYSLOG' in crond and exclude the unused syslog code on Windows. If crond is unable to run sendmail report this in the error message. Update all default Windows configurations. (GitHub PR #561)
2026-05-03Add crond and crontab (#561)mbartlett215-21/+227
* Enable crontab * Enable crond * Allow sendmail to be used in crond This also adds another option to the mingw_popen_fd function to capture stderr as well. And also added the options to support WNOHANG as well as an unused status in mingw_wait3 * Check current uid when running crond * Only show tail for mailto jobs * Use system drive for cron * crond: add missing feature check * crond: use spawn_detach for background operation
2026-04-27win32: disable urandom/zero devices if dd is disabledRon Yorston2-2/+12
Support for /dev/urandom and /dev/zero relies on having a working dd. If the dd applet is disabled attempts to access them should fail. Theoretically a third-party dd utility could also work, but let's not encourage that sort of heresy.