About Download Development

Toybox combines common Linux command line utilities together into a single BSD-licensed executable that's simple, small, fast, reasonably standards-compliant, and powerful enough to turn Android into a development environment. See the links on the left for details.


February 21, 2017

Only six people in the Galaxy knew that the job of the Galactic President was not to wield power but to attract attention away from it. Zaphod Beeblebrox was amazingly good at his job.

- The Hitchhiker's Guide to the Galaxy

Despite everything, Toybox 0.7.3 (git commit) is out. The new commands this time are ftpget, ftpput, microcom, and ascii.

We also had two command _demotions_ out of defconfig: hostid got moved to toys/example and switched to "default n" because despite still being in posix the concept of a unique 32 bit number identifying a system is something Linux outgrew about the time Pauline Middelink wrote the first IP Masquerading code. And Elliott did a complete rewrite of dmesg introducing two codepaths that I didn't get a chance to unify and didn't want to hold up the release for, so that's back in pending.

New features: Rob added units to find -atime and friends (with the legacy -amin alias). Elliott added color and -w to dmesg, fallocate -o, and improved file's ELF parsing. Steve Muckle added -d and finit_module support to modprobe. Rob and Elliott tweaked the ps/top display format a bit more (extending the USER field from 8 to 18 chars and putting + at the end of string fields that got truncated). df -a isn't entirely new, but wasn't documented and needed a bugfix.

Bugfixes: Last release broke oneit because -c didn't get moved to xopen_stdio() (oops). Rob and Elliott simultaneously spotted ps padding each line to 99999 chars when there's no tty (serial console or adb); now it pads to 80 in that case but also switches on -w to avoid field truncation. The "tty" field also sometimes had trailing debris (that's fixed now). And "top" was endlessly redrawing with out tty because receipt of the ANSI size probe results would set SIGWINCH, and handling that sent another ansi probe. (Sigh.) And while we're there, replace "ADDR" with "BIT" in ps -l so there are more than 4 chars left for the "CMD" field on 64 bit systems.

Izabera pointed out that split -b and -l can't mix, and suggested seq should multiply to avoid accumulating rounding errors from repeated fractional increments. Wang Xiao Jian fixed a bug in sort -k. Elliott let getprop use the @ character in property names, and Dimitry Invaov removed the name length limit for system properties. Elliott also improved some error reporting and improved top -H's display of thread names.

Josh Gao pointed out that recursive operations on . and .. could be ignored in chmod -R (and the resulting generic fix to dirtree_notdotdot() fixed it in several other places).

Justin Cormack caught tar producing a warning to stdout that screwed up "tar c" to stdout. Rob fixed an option parsing bug (where switching off a --longopt in menuconfig confused the parser), and another one where an option excluding itself (ala "abc[-ab][!abc]" with "command -a -b") would segfault.

There's some sort of gcc stack over-optimization bug where musl-libc's version of vfork() doesn't get marked with attribute(returns_twice) so stack varabiles in the same function after that get semi-randomly overwritten when the optimizer decides to reclaim the space. So add the attribute to the function the XVFORK() wrapper macro calls. (It's a nommu thing.)

Fixed a couple variable size mismatch bugs that were only tested on 64 bit (printf %x 64) or only tested on 32 bit (modprobe), removed some unnecessary casts in stat.

Continuing attempts to build under Android NDK brought up that posix defines the global 'stdout' as a macro, which bionic turns into an array member, but a function was using it as an argument name. (How that ever worked in the AOSP build, I couldn't tell you, but the argument got renamed anyway.)

Several commits argued with clang's warning generation, eventually settling on a variant of __attribute__((__shut_up__)).

Android should no longer give spurious error messages when you "ps -A | head" about EPIPE on output. (Older versions of bionic set an error handler on SIGPIPE, but it shouldn't do that now. More recent versions of adb set the SIGPIPE handler to SIGIGN instead of SIGDFL, leading to write returning an error message instead of silently killing the program. So we set it back to the default.)

Docs: Removed website link to the gmane archive (which didn't survive gmane's change of ownership). The FAQ now answers a _second_ question. (Woo!) Some roadmap updates.

Build tweaks: Upgraded "make install_airlock" target to only warn about missing commands (unless $PEDANTIC is set) when it sets up the hermetic build path. (The plan is still to implement everything but the toolchain binaries in toybox, but in the meantime we're symlinking other stuff from the $HOST that isn't ready yet. See mkroot for an example using this.)

Elliott and Rob continue to poke at building toybox with Android's NDK, but it's a work in progress (thread). Various changes removing libcutils dependencies and adding an selinux dependency to getprop are fallout from this.

Cross-compiling from Macs needs to use "gsed" instead of apple's version, so teach the build to use that name if it exists in the $PATH. If you try to build without running config first, you should get better error reporting now. Added a workaround for Centos' broken "which" command producing output when it _can't_ find a name in the $PATH.

Library: The new dirtree flag DIRTREE_PROC skips non-numeric entries so things like ps and top can scan /proc more efficiently.

October 21, 2016

Probability factor of one to one. We have normality. I repeat, we have normality. Anything you still can't cope with is therefore your own problem.

- The Hitchhiker's Guide to the Galaxy

Toybox 0.7.2 (git commit) is out.

During this development cycle, Elliott Hughes got interviewed on the ADB podcast and Rob Landley got interviewed on Linux Luddites (again). Both talk about toybox and many other things. The web page also grew a new FAQ page, currently with just the one.

New comands added to defconfig are tunctl, log, start, stop, and sendevent. The commands file and netstat got promoted out of pending. Pending added chrt, setfattr, and getfattr, and saw a lot of cleanups to diffstat and dd but not enough to promote them to defconfig yet. A new toys/net directory was added, moving ifconfig, netcat, netstat, rfkill, and tunctl there so far.

Upgrades: All commands now parse --version when they understand --help, but "true" and "false" should now ignore their arguments entirely. We taught stat to handle "%12x" and "%.12x" printf-style escapes, which apparently other versions do. The ifconfig output now shows the interface's device driver. Added patch -d and --dry-run, wc can now do -cm together, find has a NOP -noleaf so scripts that use that don't break, add -c to md5sum and sha1sum. Elliott taught ps to treat extra aguments as additional -p pids, implemented xxd -s, did a number of upgrades to file (added -HL, support for ar files, improved ELF support to report android API level and stripped/not stripped and it no longer prints a guessed build ID type). Elliott also added optional build-time support for using openssl's assembly-optimized md5sum/sha1sum implementations (leading to a new design policy on shared libraries).

Bugfixes: Too many fixes to "ps" and "touch" to list, from both Elliott and Rob. Rob taught sed to handle s/[[:space:]/]// type sequences properly, switched grep to a better workaround for glibc bug 17829, made sed -i preserve ownership when run as root, made du max out at 2 terabytes instead of 2 gigabytes on 32-bit systems (it was always designed to, but was missing a typecast), fixed the option parsing infrastructure (config options that remove command line options got the placeholders wrong), fix to printf for printing octal digits and handling the (posix-mandated) difference between %b and non-%b octal output, reading from "-" no longer closes stdin when done, netcat -L works with nommu (although it may need more portability work), and you can now "make test_scankey" if you want to. Several commands (stat, makedeves, chgrp, cp, find) handled user name lookup failure badly (stat was segfaulting if you interrogated a file belonging to a nonexistent user, "chown 12345 file" errored out if you didn't have that user in /etc/passwd... now they should all print/accept the number when appropriate). "LC_ALL=C ls -Cs --color" produces the same output as other versions (two spaces padding, -k hardwired on).

Kyungsik Lee fixed a bug in cp (readlink() doesn't actually null terminate the string it reads in), Elliott Hughes made pgrep/pkill return success/failure, fixed trailing whitespace in netstat, fixed a SMACK symbol conflict due to linux/xattr.h changing, fixed ls -sh, and added a lot of stuff to the roadmap page. Izabera pointed out cmp -l and -s can't be selected at the same time, that timeout was never actually checking -v, that ls should default to -q when output is to a tty, and that "file -" would sometimes try to open "-" instead of stdin. Usischev Yury pointed out a use after free error, and that id shouldn't call exit() directly. Matthias Urhahn pointed out that stat(2) returns hardwired 512-byte units, so stat.c was wrong. David Hedges pointed out that route could only handle 10 character interface names when the kernel can do 15 (it's still in pending for a reason, but fixed). Evgenii Stepanov found and helped diagnose one of the more subtle ps bugs fixed this time around.

Calling "make test_blah" no longer causes make to error out if the last test fails (and thus returns a nonzero error code). Building single commands and the multiplexer used to require a "make clean" between them (because they had different config files both of which were older than generated/config.h so it didn't get rebuilt; now it just always rebuilds it).

The defconfig build is now slightly less broken on older centos versions (although the consensus is that Centos is just generally broken).

Several commands were over-using xprintf(), which flushes its output to check for error (something you only need to do maybe once per line, and even then maybe only in loops because xexit() flushes and checks ferror() for you and adjusts the exit code if we wrote stuff to stdout that couldn't be printed). Lots of little flushes are inefficient, so most things can use normal printf(). (Retransmission of short writes is presumably libc's problem since it's buffering the output and all.)

Library: New library functions readlink0() and readlinkat0() which properly null terminates the symlink value (which the stock libc function inexplicably doesn't). The new do_lines() function interates reading lines from a filehandle and calling a function on each line. New function pollinate() factoring out netcat's poll() loop so things like telnet can use it. New functions getusername() and getgroupname() return a char * given a uid/gid (and return a string representation of the number if the lookup fails), and xgetpwnamid/xgetgrnamid were renamed to xgetuid/xgetgid and now return an integer instead of a struct (also helping handle lookup failures, you can still return the uid/get for "12345").

Switched atolx() to use long long internally. Renamed xopen() to xopen_stdio() and made a new xopen() that never returns stdin, stdout, or stderr (duping /dev/null into the filehandles as necessary). New function xopenro() opens a file read only with one less argument, and understands that "-" means stdin. New flag WARN_ONLY tells these functions to just print a warning on failure, and return -1 instead of exiting. Misc new functions like openro() which defaults to the WARN_ONLY behavior and notstdio() which dup()s a filehandle up beyond stdin/out/err backfilling with /dev/null as necessary. The WARN_ONLY flag let us remove the failok argument from loopfiles().

New TOYFLAG_NOHELP disables --help processing (which "true" and "false" should not do).

The test suite now has NOSPACE=1 to ignore whitespace (using diff -b to check results), which helps TEST_HOST pass the same tests as toybox. Fixes to chattr and date tests. It also has a new variable $C with the absolute path to the command being tested (bypassing shell builtins), and a function testcmd() which is just like testing() except it prepends the command name ($C) to the test command line as well as the test description.

June 2, 2016

When the 'Drink' button is pressed it makes an instant but highly detailed examination of the subject's taste buds, a spectroscopic analysis of the subject's metabolism, and then sends tiny experimental signals down the neural pathways to the taste centres of the subject's brain to see what is likely to be well received. However, no-one knows quite why it does this because it then invariably delivers a cupful of liquid that is almost, but not quite, entirely unlike tea.

- The Hitchhiker's Guide to the Galaxy

Toybox 0.7.1 (git commit) is out. (Yes, I forgot to update the --version string, but I already uploaded the binaries.)

The website has https support now, you can "make cat ps ls" to get standalone commands (and "make list list_pending" to see what's available), and a whole lot of bugfixes and new options to existing commands.

New Commands

Rob implemented ulimit. In pending, Elliott Hughes implemented file. and Lipi Lee implemented a simple wget. (Pending also had minor cleanups to more and lsof, but no promotions this time around.)

New Options

Izabera implemented env -u, suggested adding seq -w, made factor use full unsigned 64 bit math even on 32 bit platforms, pointed out base64 -w0 should disable wrapping, and sped up wc -c. Elliott Hughes added mount -o relatime, xxd -p -r, and od -w. Sameer Pradhan (or possibly Bilal Qureshi) suggested adding stat -tL -c %m%t%T. Tom Cherry added getprop -Z. Paul Barker added hostname -b and -F. Rob added ls -b, made ls -q work with utf8, made sed -f - read from stdin, and added top -O (like ps -O).

Elliott and Rob added Thread support to ps and top, with -o TID, TNAME. We also added -o PCY (android scheduling policy), -o BIT (process is 32 or 64 bit), and -o TNAME now shows the parent command name for threads.


Rob added the sed invocations to convert tabs/spaces and back to design.html. Isaac Dunham updated hexedit's help text. Jakob Flierl pointed out a broken URL in the README.

Rob also redid the naming scheme of sed's pattern manipulation code to remove the gratuitous references to Roger Zelazny's "Amber" series, since it was confusing people.


Grep -H and -n should now work properly with -ABC. Andy Chu pointed out an out of bounds access for zero length lines in rev, fixed a buffer overflow in diff -r, and fixed operator precedence in expr (although Rob is rewriting chunks of expr so toysh can use its plumbing for $(( )) ). Patrick Ohly fixed the too-aggressive suid permission dropping logic. Josh Gao fixed a segfault when find -iname got no argument, and made tail -f work right with just one file argument. Tom Marshall cleaned up tar's long filename support and improved the tar tests, and reported another find bug (with -iname -o -iname not tracking copy lifetimes properly) that got fixed.

Elliott Hughes fixed wc -c to not trust zero length files to actually be zero length (/proc does that), fixed "mount -o rw,remount /system" on Android, removed trailing spaces on ps -o cmdline, fixed pkill -9 and the corresponding tests, made "insmod -" work, fixed top -b and tail -NUM, pointed out that ps shouldn't trim numeric fields for display size limits, and added some more explicit "sort" calls to make pipelines so build tempfiles are easier to cache. Rob fixed an insane sed thing the perl 5.22 build was doing. Fixed mount -o to properly pass in leftover string data, and documented how to use toybox to mount nfs (warning: kernel patch to fix some bitrot in the kernel NFS driver's string parsing attached to that message).

George Burgess IV corrected some variable types in traceroute. Base64 now wraps == properly. Fixed two bzcat segfaults reported by John Regehr. Andy Chu found a segfault in "sed -e 'c\'" with no trailing line, and implemented mv -n and cp -n. The cyanogenmod guys pointed out that cp -a shouldn't complain if a non-root user can't chown, and we added the output path to cp -r error messages while we were there (before was just the filename).

Samuel Holland fixed blkid's handling of vfat labels, and fixed a segfault when basename was passed an empty string and an empty suffix. Davis Mosenkovs fixed touch -t seconds parsing. Rob fixed a bunzip bug reported by John Regehr (the bad CRC error message was printing a NUL argument).

Not all of the commands build standalone, but more of them do now; scripts/ can now build a "mv" that isn't actually "cp". The dependencies are more granualr, so "make top; make ps" no longer produces a broken ps that ignores -A (because ps.o wasn't getting rebuilt even though top had the FLAG macros for -A zeroed).


Rob added a warning when building commands out of pending. (The pending directory is full of code that hasn't been properly vetted. Use at your own risk.)

New build targets let you build individual commands by name, ala "make ls cat ps", and you can run the test suite for each standalone command with "make test_ls" and such. "make list" shows all such standalone commands in defconfig, and "make list_pending" shows unfinished commands from toys/pending ("make list list_pending" shows both together). "make clean" now deletes these filenames at the top level, and the corresponding unstripped files live in the directory generated/unstripped.

Nicholas Boichat suggested switching to use $! for process enumeration during parallel builds (which is both more efficient and more portable), and suggested shell builtin replacements for wc/awk/sed so the build loop has fewer forks now.

Lots of work on the test suite, much of it due to Andy Chu. It now consistently prints the name of the command being tested at the start of each test (and the common infrastructure does that, not each individual test), and "make tests" actually runs all the available tests now. Seperated pgrep and pkill tests, split lsattr/chattr, added fstype and base64 tests. The "tests/files" directory now collects files for tests to use, with blkid, bzcat, and utf8 subdirectories: the $FILES variable gives a path to it, so "$FILES/blkid/ext2.bz2" and so on. The testsuite now has test files with 3 different types of "not utf8 output" sequences that require escaping, plus some combining character torture tests, direction reversals, and so on.

Added dependencies on TOYBOX_FORK to various pending commands that need nommu conversion (which should fix the allyesconfig build).

Static builds with selinux should work again.


New bufgetgrgid() and bufgetpwuid() functions cache previous lookup info rather than repeatedly traversing /etc/passwd and /etc/group (which is slow). Added xpipe() to lib to catch pipe creation failure. The HELP_ macros generated by config2help.c now use a capital prefix to avoid collicing with help_exit() and such.

The dirtree infrastructure got a cleanup pass in preparation for adding infinite recursion depth support (needed by rm -r), updated the documentation to describe the new semantics (removing dirtree_start() and adding dirtree_flagread()). Now dirtree_recurse() takes the new dirfd as an argument.

Split out _xexit() from xexit() and let sigatexit() set multiple callbacks.

For years the man pages have said to #include to get major/minor/makedev but now that glibc has vowed to break existing programs and replace it with another nonstandard header not in posix or lsb, we added our own functions to lib/ to do the transform ourselves (based on what the kernel actually expects).


Debian unstable started needing an extra header #include for some reason, and although printf("%.*s", INT_MAX, s) worked fine on Ubuntu 12.04 it didn't on 14.04, so added a workaround for that. Typecast a printf because wchar_t isn't a rigidly defined size. RLIMIT_RTTIME was added to the kernel in 2008 but you can't expect uClibc to have noticed yet, nor did it #define MS_RELATIME (added in 2006), or prlimit (2010)... (Given the improvements in musl and bionic, uClibc support may be dropped in a future release.) Given that the xattr functions were added during linux 2.5, we can #include its header unconditionally.

Renamed basename_r() to something else to avoid conflicting with freebsd's libc, and both scripts/install.h and scripts/config2help.c no longer include toys.h (to make cross-compiling from systems we don't run on easier).

Debian bug 635570 did something unspeakably nonportable, depending on "sed -e 'a\'" (with no next line of the pattern, so an unterminated continuation) to add a newline to the last line of input if and only if that last line of the input didn't have a newline, and to take no other action. This is well into "depending on a bug" territory, but we implemented it because otherwise Debian's install broke. (Of course this behavior is undocumented, non-obvious, and doesn't really make logical sense.)

CONFIG_TOYBOX_NORECURSE now disables the stack measuring logic (which was giving some "security" code fits). Also we typecast pointers to (long) before comparing them to avoid spurious compiler "optimizations" that break the code.

February 2, 2016

"I checked it very thoroughly," said the computer, "and that quite definitely is the answer. I think the problem, to be quite honest with you, is that you've never actually known what the question is." - The Hitchhiker's Guide to the Galaxy.

Toybox 0.7.0 (git commit) is out.

The new commands in defconfig are iotop, top, pgrep, and pkill (most replacing corresponding versions from pending). Added grep -ABC, swapon -d (discard), mkswap -L (label) and UUID support, and find -delete. Izabera added free -h and unshare -f. Josh Gao implemented tail -f. Jose Bollo submitted cp --preserve=context,attr. Kylie McClain added mktemp -u.

In pending there's the start of a vi command, and Sameer Pradhan contributed a new dhcp6. This cycle saw several rounds of route cleanup and a little dhcp cleanup, but neither are complete yet. Lipi Lee did some cleanup to netstat.c and Elliott Hughes removed warnings from traceroute.

Lots of updates to ps: several new -o options, -k (--sort) -O and -M, improved compatibility with Android's historical behavior, and extensive internal code cleanup (including the removal of all the magic constants).


Dreamhost restored the missing 11 months to the mailing list archive, in the process deleting the month after that. Now they've asked if I have mbox files archiving the new gap (between December 20, 2015 to January 21, 2016, and presumably they could also fill in the gap from December 14, 2014 to January 3, 2015 that's been there since the last time they did this), but due to some gmail filtering I've never been able to disable, my copy of those files is spread among 3 different mbox files I'd have to sort/filter/collate. (It's on the todo list.)

Added a code of conduct to the README (we're borrowing twitter's) because somebody made it necessary.


Fixed another sed bug where any ] right after [ was skipped (not just the first one in the range, so [[] didn't terminate). Fixed sort -f and added test cases. Assume 80 columns in "ls -m | cat", ls -L is no longer backwards, and ls of files with no paths no longer uses an uninitialized (zero) dirfd. Several bugfixes to find (Gilad Arnold fixed -perm, Daniel K. Levy fixed "find . -exec echo {}", and while we're there I fixed find --prune, made "find . -execdir echo {} + -execdir ls {} +" work, and ripped out the environment size measuring code that checked for a 128k limit removed back in linux 2.6.22). Elliott Hughes fixed the date command's parsing of 4 digit years and documented the %s escape, fixed hwclock -u, and pointed out that runcon needs to exec to do its job (not recursively call another command_main() in the same process). Tom Marshall reported that blkid was handling ext2 wrong. Mike Moreton corrected cpio extraction's uid and gid values, and added a --no-preserve-owner option. Fixed the SUID permission dropping logic (which was a bit over-zealous, preventing some commands from running at all).

I'm told that debian-testing broke its libc so the nsenter build breaks, but my attempts to install the debian-testing network cd image under qemu keep breaking. Maybe someday they'll fix it enough I can actually reproduce the problem. (Debootstrap under unbuntu builds an ubuntu-flavored chroot in which toybox builds fine.)


Rewrite of the about.html page, tweaks to design.html, and a re-triage of sbase in roadmap.html. Update to to collate multiple span tags with the same id, resulting in a larger status.html page (which was previously ignoring some commands in the roadmap).

Expanded the defconfig/allyesconfig/allnoconfighelp text in "make help" to explain what they're for.


  • Expanded toys.optargs to 64 bits so a command can have more than 32 options.

  • Added NOEXIT() wrapper to turn xwrap() functions into warning versions using the existing longjump(toys.rebound) infrastructure.

  • Renamed dirtree->data to dirfd and stopped storing symlink length into it (this fixed a bug where following symlinks to directories didn't give a valid directory filehandle, noticeable with ls -Z).

  • New TAGGED_ARRAY() infrastructure generates index and bitmask macros for arrays of structures starting with a name string.

  • New lib/linestack.c for utf8 fontmetrics (draw_str() and utf8len() and so on), and for tracking multiple lines of text (vi, less, shell history) that need wordwrapping and scrolling up/down.

  • Upgrades to lib/interestingtimes.c: scan_key() now has a timeout in miliseconds and recognizes more sequences including ANSI window size probes. New utf8 test files in tests/files/utf8 including sequence reversing, stacked combining chars, and all three types of unprintable sequences (low ascii <32 ala ^X, invalid utf8 sequences ala , and invalid unicode code points ala U+1234).

  • More comma handling code in lib.c: comma_args()

  • Added error_msg_raw() to shut up fortify's endless static checking false positives.

  • readfileat() can now realloc() in a loop to read long files ("zcat | insmod" needed it).


We're getting close to having a self-hosting development environment using toybox for the command line. The remaining busybox commands in Aboriginal Linux are:

awk bunzip2 bzcat bzip2 dd diff expr fdisk ftpd ftpget ftpput gunzip gzip less ping route sh sha512sum tar test tr unxz vi wget xzcat zcat

And the remaining non-busybox commands in Aboriginal Linux's build/host directory (from the distcc, genext2fs, e2fsprogs, zlib, and squashfs packagesi) are:

mke2fs fsck.ext2 resize2fs distcc genext2fs unsquashfs distccd mksquashfs tune2fs

Squashfs and distcc are probably out of scope for toybox, but mke2fs, fsck.ext2, resize2fs, genext2fs, and tune2fs should all be added to the above "busybox" replacement list.

Remind me to include this countdown in future releases. Once they've all been replaced, the next goal is building AOSP under itself.

See the full roadmap and status pages for more details.

December 21, 2015

Yes, 11 months have gone missing from the mailing list web archive.

Yesterday evening Dreamhost's mailman server went down (timing out trying to connect). I poked them about it, they blamed DNS, I explained that the hang was _after_ the DNS lookup and entered the dig info into the trouble ticket showing the IPs the DNS queries were returning, they reinstalled the server at that IP from what I assume was their most recent backup, and that's how 11 months of messages vanished out of the archive.

I've continued to poke them about it but I honestly believe that's the best they can do. Last time this sort of thing happened we went back and forth for months, so I added a link to a backup web archive (in the nav bar on the left) that isn't controlled by dreamhost, and thus doesn't gratuitously lose data on a regular basis. (I note the earlier hole in Dreamhost's archive was never fixed either. That was data never getting archived, this is a year's worth of data that was in the archive until yesterday vanishing after the fact.)

If you're wondering why the top level list page has been "temporarily disabled" for multiple years now... you'd have to ask Dreamhost. I know I have. More than a dozen times.

November 3, 2015

"Alright," said Ford. "How would you react if I said that I'm not from Guildford after all, but from a small planet somewhere in the vicinity of Betelgeuse?" Arthur shrugged in a so-so sort of way. "I don't know," he said, taking a pull of beer. "Why - do you think it's the sort of thing you're likely to say?" - The Hitchhiker's Guide to the Galaxy.

Toybox 0.6.1 (git commit) is out.

We have a new ps command with all the -o fields posix wants (although it doesn't accept BSD non-dash option syntax yet), and bunzip2 (not just bzcat but the proper extract-in-place command). Sameer Pradhan added hostid and fsync. Elliott Hughes added flock.

The people waiting for human readable number support (du -hH, ls -h, and so on) can thank Elliott Hughes for implementing it. (Our output doesn't exactly match others' because we our "binary" mode will say 1.0G instead of 1024M, which is a bug in the other one we didn't emulate.)

The other big news is nommu support, tested on the new jcore processor but presumaby working on any nommu system. A few commands don't support nommu yet, but those are disabled by dependencies on TOYBOX_FORK in menuconfig when building for nommu. The roadmap now has a large section analyzing the uClinux project (note that is slowly replacing as the standard repository of all knowledge and wisdom about nommu. The old site contains much that is apocryphal, or at least wildly inaccurate, and the new one is trying to improve on that).

Both "make change" and scripts/ (for building standalone commands without the multiplexer logic) now use the top level .config for toybox global settings such as Linux Security Blanket Module selection, (so make defconfig before change now).

Documentation updates to the code and roadmap pages.


In the pending directory Sameer Pradhan added tftp, and Elliott Hughes sent lsof. Isaac Dunham upgraded mdev, reboot, init, login, and modprobe, and fixed a distro-specific build break in scripts/mkflags.h. Elliott Hughes and Lipi Lee made netstat -p handle command lines longer than 21 characters, and Elliott fixed netstat -e and some build warnings. Yeongdeok Suh fixed a warning in dhcpd. I started cleanup on pgrep/pkill.

Command updates, bugfixes, and infrastructure

The multiplexer's "command not found" error exit is now 127, so now you can't distinguish between a command not being found in the multiplexer and the multiplexer itself not being found by the shell, because people wanted that for some reason.

Elliott Hughes made date reject invalid dates rather than set the clock to something weird (setting the clock 100 years into the future makes most Linux desktops surprisingly unhappy, and ntpdate won't fix it either), fixed several ls -l display issues (user/group field ordering, make user/group/lsmcontext left aligned), did the aforementioned extensive work on human readable number output, fixed ionice's default class, fixed a mv overwrite bug, made df's columns auto-size, added --ppid and -Z to ps, and teamed up with Daniel K. Levy to fix a segfault in find's handling of -newer -group or -user.

Hyejin Kim added stat -c %T support. Colin Cross worked on vmstat fixing a header printing bug and calculating the bi and bo columns in the right units. Isabella Parakiss reported that sed -e "/x/c\" -e "y" added an extra newline and that grep -w '\(x\)\1' didn't work, both now fixed. Alistair Strachan fixed several problems with switch_root. Kylie McClain pointed out env should be able to clear variables via NAME= syntax. Dima Krasner added support for running blkid without a partition (so it shows all partitions). Hyejin Kim sent in a bunch of static analysis bug reports.

Isabella Parakiss reported that sed -e "/x/c\" -e "y" added an extra newline and that grep -w '\(x\)\1' didn't work, both now fixed. Alistair Strachan fixed several problems with switch_root. Kylie McClain pointed out env should be able to clear variables via NAME= syntax. Dima Krasner added support for running blkid without a partition (so it shows all partitions). Hyejin Kim sent in a bunch of static analysis bug reports.

Two large thinko fixes in oneit: -3 was always enabled (which would eventually block if the child never read the exiting PID numbers from its file descriptor #3 until the pipe filled up), and the signal handlers weren't set up right (for requesting semi-graceful halt/poweroff/reboot). Calling install without a mode is now 0755, and install -g 0 no longer clashes with cp --preserve. Better error message for ls -r on unreadable directories, and ls -Z now uses O_PATH (with the /proc/self/fd/%d workaround for kernel stupidity as necessary).

Date now understands @unixtime[.fraction] and uses -D for the set-side format (matching busybox's extension for this). The seq -f string now checks that it's got exactly one %f escape with the correct attributes (and a whole bunch of test cases for it). Fixed a bug in od that screwed up the position indicator on arm and mips. In stat the d/h units moved from %d %D to the default string. And patch can now correctly apply hunks with trailing context to the start of the file.

The prompt argument moved out of yesno() (the caller can print the prompt themselves). Replaced toys.exithelp with help_exit(). Added new XVFORK() macro, and xpopen_both() calls /proc/self/exe when passed a NULL argv (see cpio -p for example usage). Replaced toys.recurse with toys.stacktop so the recurse or re-exec decision is now based on bytes of stack space used. Marked a bunch of command-local functions static.

New additions to lib/ include strlower(), xconnect(), and the aforementioned help_exit(). The testsuite now has some infrastructure tests based on "example" commands such as toys/examples/test_human_readable.c. The login command finally got a long-overdue cleanup (it's one of the commands that predate the "pending" directory but were part of the reason for it). Hexedit had an uninitialized variable (of course gcc didn't spot it, it was too busy warning about "may be used uninitialized but never actually is" variables).

Tweaked makefile so "make CROSS_COMPILE=prefix-" (as well as "CROSS_COMPILE=prefix- make", which still works). Toybox is now installed chmod -w so broken installers (like the bunzip2 package's) that try to overwrite existing binaries won't knock out the whole of toybox. GCC 5.2.0 stopped being able to compile Linux 2.6.12's kconfig, but we added a workaround. You can now build uptime without utmpx.h. Alejandro Joya pointed out that enabling smack required smack on the host as well as target when cross compiling, which is now fixed.

Note: toybox can autodetect nommu support when building with a uClibc toolchain such as the one from Aboriginal Linux, but with musl-libc you'll have to enable CONFIG_TOYBOX_MUSL_NOMMU_IS_BROKEN to work around the fact they provide a non-functional fork() implementation that always returns -ENOSYS, to prevent you from compile-time probing for nommu support when cross-compiling. Unfortunately "preventing you from probing" seems to be an explicit policy with musl, they also don't provide an "#ifdef __MUSL__" because their library is perfect and you're only ever allowed to work around other people's bugs, not theirs. So we have to use menuconfig to manually enable musl-specific bug workarounds.

July 23, 2015

I recreated the 0.6.0 source tarball (new sha1sum 08fb1c23f520c25a15f262a8a95ea5b676a98d54) because I forgot to add --prefix to the git archive command when I updated my release script from mercurial, so the files weren't in an enclosing directory. (Ooops.)

July 19, 2015

The reason why it was published in the form of a micro sub meson electronic component is that if it were printed in normal book form, an interstellar hitchhiker would require several inconveniently large buildings to carry it around in." - The Hitchhiker's Guide to the Galaxy

Toybox 0.6.0 (git commit) is out. (Yes, git. See the previous news entry.)

Sorry for the unusually long gap between releases. Since last release Ye Olde Project Maintainer traveled to japan twice and had two more "once a century" floods at home. (Probably a coincidence.) Still catching up.

CELF/ELC talk and Wikipedia[citation needed] article

I gave another State Of The Toybox talk (video outline), in which I repeat my perennial complaint that Wikipedia[citation needed] still says toybox was relicensed before its hiatus, when relicensing was why the hiatus ended.

Since Wikipedia[citation needed] seems unable to do the most basic research on this point, and has stuck to an incorrect sequence of events for years, I've been gradually escalating my attempts to correct them. Toybox came out of mothballs in November 2011 because it could be relicensed. That's what opened up a new niche busybox wasn't already filling with a 10 year headstart.

The article has plenty of smaller issues*, but given that I gave an entire talk at Ohio LinuxFest in 2013 (outline, audio) on why I switched away from GPL for my projects, that one bugs me.

New stuff this release

There's a new android menu in menuconfig, and rather a lot of Linux Security Module support (Smack for Tizen from Xavier Roche and José Bollo, and SELinux for Android from Elliott Hughes; see the Security Blanket menu under global settings in menuconfig) has trickled in, although there's still more to come.

New commands: Added reset, nproc, ionice, and iorenice. Elliott Hughes contributed xxd, runcon, restorecon, load_policy, getenforce, setenforce, getprop, and setprop. Promoted shred, nsenter, and hwclock.

You can once again build catv now the flag infrastructure's been updated to let it coexist with cat -v. And on a long plane flight I wrote hexedit, an interactive hex editor that implements the start of cursor control infrastructure (for eventual use by less and vi and shell command history and so on).

New options: Added sed -E as a BSD-compatible synonym for -r. Upgraded oneit with -r (restart), -3 (send exiting PID values to child), and signal handling. Added -v option to timeout, -m to mknod, -u to shred, -t to dmesg, and -123 to head and tail. Added implicit "." to grep -r without any files to work on. Hyejin Kim requested prefix support for truncate -s. Greg Hackman added -inum to find. Jan Cybulski added the smack side of ls -Z support. Various patches also added -Z to mkdir, mknod, and mkfifo. Basic cp --preserve support went in, but not yet the xattr/LSM parts.

The toybox command now has a --version option, which uses "git describe" if available.

Build infrastructure: The "make change" target now saves the output of each failed standalone command build in a .bad file, and "make defconfig" is quieter now.

Paul Barker submitted a large patch changing command install paths so "toybox can be installed alongside busybox without confusing update-alternatives". (There's some argument over what the right paths should be, and I'm waiting for people to tell me what else needs fixing because I have no idea. I've been symlinking /bin to /usr/bin since 2002 for historical reasons.)

Docs: The repository link now goes to github, with another link to the commit rss feed.

Elliott Hughes updated the Android section of the roadmap (and he would know). Redid bits of scripts/ to make updating status.html easier, and the README is larger.

More description of option parsing in code.html, which now describes the FLAG_x macros, switching flag macro sets with FOR_newcommand, how configuration zeroes flag macros and using FORCE_FLAGS to suppress the zeroing of options shared between commands. Also added description of ";" to make --longopts take an optional =value part, and more about TOYBOX_DEBUG to check NEWTOY() option strings (otherwise a bad option string makes lib/args.c obviously segfault, but doesn't explain why).

Added a "Why 0BSD?" section to license.html when submitting zero clause bsd to SPDX (according to the pending license spreadsheet, it's been approved for SPDX 2.2).

The old list of commands needing cleanup but not in pending was removed from toys/pending/README and instead the issues were added as TODO comments in the individual commands.

Bugfixes: Fixed mount -a segfaulting without -O (reported by Janus Troelsen), and made it try a "become rw" ioctl() on the block device before falling back to mounting read only (because Android expects that). Fixed printf -- and printf ---. Lots of tweaks to ls -l spacing with different options. Make touch -d and -t actually set time when you don't specify nanoseconds. Fixed a subtle bug where recursive calls (toybox commands that run other toybox commands) weren't resetting all their state. (This manifested as a "no }" error from "find | xargs sed", but could cause other problems.) And David Halls reported another sed bug trying to compile libiconv (which left extra \ at the start of lines in a generated shell script, breaking the build). Output an error message for "cat /mnt".

Kylie McClain reported that mktemp broke when $TMPDIR was set to an empty string (which is not the same as unset), that install/find didn't support numeric uid/gids, and that sort -z affects both input and output. Isabella Parakiss fixed a printf.c bug. David Halls fixed bugs in install -D and find -exec. Samuel Holland fixed unshare -r. Hyejin Kim fixed makedevs with a count of 1, fold -w range checking, an error path in scripts/mkflags.c, added -i to dhcpd, and stopped su from prompting the root user for the new user's password. Jan Cybulski spotted wrong indentation when combining ls -s and -i with -C and -x. José Bollo fixed stat %G. Sameer Pradhan fixed a bug in mkfifo -Z.

Elliott Hughes asked for a default SIGPIPE handler to disable the signal handler bionic's dynamic loader installs (yes really). Still not 100% sure what the correct behavior is there. (Posix is (actively unhelpful, but at least they're taking years to make up their mind. Elliott also sent patches to fix a typo in useradd.test, add missing arguments to error_exit() calls and clean up printf() format strings, fix an off by one error in human_readable(), fix dmesg -c error reporting, fix a segfault in comma_scan where the option was the last item in optlist (triggered by mount -o ro,remount), fix hwclock -w, made ifconfig print lowercase MAC addresses (it was bothering him), and make terminal_size() read the right environment variable (LINES, not ROWS). And he suggested the test suite notice high command exit values (corresponding to segfault or other signals).

People are apparently using toys/pending commands, despite the police tape and flashing lights, so added louder warnings to toys/pending/README. Elliott Hughes fixed various problems with tar, dd, more, and top. Hyejin Kim cleaned up syslogd and dumpleases. Isaac Dunham added hotplug support to mdev. Yeongdeok Suh added RFC-3315 ipv6 support to dhcpd.

I rewrote ps.c from scratch (in pending), but it's not ready for real use yet.

Portability: On the portability front Bernhard Rosenkranzer fixed a problem where the menuconfig code wouldn't compile in C99 mode. (This led to me documenting the craptacular nature of kconfig in a README, and the plan to replace it sometime before 1.0.) Some extra flags to shut up overzealous llvm warnings were added (and have to be probed for because gcc complains about arguments it doesn't recognize even when they switch stuff _off_ using a standard syntax). Don't depend on malloc(0) to return non-null in ls. David Halls fixed some mac/ios portability issues, implying somebody's built at least part of toybox on a mac.

Added basename_r() to lib/lib.c because the posix semantics for basename() are stupid but what the gnu guys did to it was appalling. Turns out bionic already had a basename_r(), but posix still doesn't. Fixed it up in portability.h, but this could break more stuff in future. (Correct fix is to lobby posix to add it, which would probably take about 15 years...)

Infrastructure: The build now checks $LDFLAGS for linker-only flags, and allows the strip command to fail (binflt toolchains provide a strip that doesn't work). Since time.c uses floating point, added TOYBOX_FLOAT dependency in config.

There's a lib/lsm.h defining varous inline functions for linux security modules stuff, if (lsm_enabled()) should turn into a compile-time constant 0 and let code drop out when TOYBOX_LSM_NONE selected, but testing against CFG_TOYBOX_LSM_NONE or derived symbols is still useful becuase when it _is_ enabled the probe turns into a system call you don't want to repeat too much.

Switched a bunch of commands from signal() to xsignal(). Factored out xgetgrnamid() and xgetpwnamid() into xwrap.c. Make time.c depend on TOYBOX_FLOAT (since it always uses float so shouldn't be available on build targets without even software float). Added readfileat() to lib/lib.c.

The dirtree infrastructure now passes in full flags for the old symlink field, and the new DIRTREE_SHUTUP flag disables warnings if a file vanishes out from under you during traverse. New dirtree_start() wrapper to create dirtree root with only two arguments.

The not-curses infrastructure introduced by hexedit mostly moved to lib/interestingtimes.c.

Asterisk: such when Tim contacted me (my blog says a couple days before nov 13, 2011, I.E. 11/11/11 not some specific day 2 months later) to ask if I wanted to work on a new project he was proposing called BentoBox (because I used to do busybox, he'd forgotten toybox existed until I brought it up). And don't ask me what "focuses not on compatibility with its GNU counterparts" means when CP_MORE adds 7 non-posix options and toys/other has 84 commands in neither posix nor LSB. I think they're struggling to explain the difference having dismissed "licensing" as being the reason it started up again after a long hiatus? The reason I don't think GNU is special is there are a half-dozen other independent implementations of the same unix command tools out there (AT&T, BSD, Coherent, Minix, plan 9, busybox, toybox, and several more analyzed in the roadmap, and that's ignoring the implementations written for DOS or in assembly over the years). But I do care what Linux From Scratch expects, and if it's calling mv -v then I impelement mv -v even if posix hasn't got it. And I don't know why "gnu counterparts" would describe this when util-linux isn't a gnu package, nor are info-zip, e2fsprogs, kmod, less, procps, shadow, sysklogd, vim, zlib, sudo, dhcpcd...

April 5, 2015

Since android and tizen and openembedded and gentoo and so on have all been using Georgi Chorbadzhiyski's git mirror rather than the mercurial repository, I bit the bullet and switched the project's repo to git. Georgi's mirror is now pulling from that.

February 25, 2015

"A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools."

- The Hitchhiker's Guide to the Galaxy.

Toybox 0.5.2 (commit 1702) is out.

New promoted commands: sed (finally fixed enough it builds Linux From Scratch), printf (cleaned up and promoted), shred and base64 (the Tizen guys wanted them), getenforce, setenforce, and chcon (android), mix (promoted with fixes from Isaac Dunham), nsenter (from Andy Lutomirski, merged into unshare).

Elliott Hughes submited a bunch of patches to support Android (to both toybox and Bionic libc, which he maintains). On toybox's end this involved a lot of fixups to portability.[ch] and fixes to over a dozen commands, plus several new ones. Other portability fixes included working with buildroot's uclibc fork and building for nommu targets.

The new "make change" target builds each toybox command as a standalone binary. Rather a lot of commands that didn't build by themselves (mv depending on cp and so on) were hit with a large rock until they built standalone. This involved rewriting bits of option parsing, more elaborate dependency generation, making each command have its own config symbol and main() function (even when it's just a wrapper calling another command's main()), and so on. Also, some commands can't be built standalone at a conceptual level: "help" describes other enabled commands and "sh" has a number of bulitin commands (cd, exit, set) that require the multiplexer infrastructure, so "make change" filters them out.

The mailing list's web archive is still screwed up. Dreamhost has been trying to fix it since approximately September. There are two other less broken archives, but neither has quite the same UI as mailman.

Bugfixes and tweaks

Cynt Rynt sent in tests for ifconfig, Robert Thompson taught factor to accept whitespace separated arguments, Hyejin Kim pointed out that some of mktemp's longopts were attached to the wrong short options, Luis Felipe Strano Moraes fixed a wrong free() call in bootchartd in pending. Patches from Ashwini Sharma to make "df /dev/node" work, prevent du from looping endlessly following symlinks, and to make expr.c (in pending) understand == and regex matches. (Speaking of expr, it gets priority groupings wrong but the bug was actually in the posix spec's HTML conversion. They fixed the posix spec upstream for us. Still need to fix the expr code, but it's in pending for a reason...)

Some commands grew new option flags, such as cp --remove-destination and touch -h.

The parallel build has better error reporting now. When toybox needs to re-exec itself to regain suid root permissions and hasn't got the suid bit, it now gives the right error message ("not root" instead of "no such command").

Added a test to "mount" to not mount the same device/directory combination over itself (the OS catches this for block devices, but not for tmpfs). Make blkid distinguish ext3 from ext4. Added catv back into cat (because the Android guys wanted it, and they have historical usage on their side, so...). Handle nanoseconds in touch.

Fixed a segfault when CP_MORE was disabled (the resulting option flag list no longer defined -d but still had it in option groups at the end). Workaround for glibc redefining dirname() and basename() to random non-posix semantics because gnu. (They could have created dirname_r() but didn't want to.)

Fix an ifconfig test that was preventing assigning an ipv4 address to interface aliases. Several cleanup passes on hwclock but not quite promoted out of pending yet.

Fixed a wrong error message in rm (if you had a chmod 000 directory and did rm -r on it without -f, after the prompt it would complain it was a directory, which was not the problem).

The gzip compression code now does "store only" output to stdout, for what that's worth.

Cleanup mountpoint and expand, and remove them from toys/pending/README (a list of commands that predate the toys/pending directory but needed another pass).

Library and infrastructure:

Reworked the option parsing infrastructure so more commands build standalone (via scripts/ or "make change"). The option flag bit values are no longer packed, it leaves spaces where currently disabled flags go, and you can #define FORCE_FLAGS so disabled flags aren't zeroed. This allows multiple commands to more easily share infrastructure, even if your current flag context is for a disabled command (switched off in config), you can force them to stay on and as long as the flags read the same right to left they'll have the same values.

We've started removing use of strncpy() because it's a hugely broken standard C function: the length is the maximum length to _append_, not the size of the destination buffer. It memsets the remaining space it didn't copy ala "memset(dest+strlen(dest), 0, len);" so if you think len is the size of dest you're guaranteed to stomp memory off the end). And if it runs out of space it won't null terminate because reasons. (Meanwhile sprintf("%*s", len, str) is counting wide characters in your current locale, so if you set a locale other than "C" it will also go past your allocated buffer size. Whoever is maintining the C library standards is really bad at strings.) Instead we have xstrncat() which will error_exit() if src+dest+1 doesn't fit in the buffer. (Because randomly truncating input data isn't necessarily an improvement.) And there's always xmprintf().

Similarly, strtol() doesn't return an error indicator on overflow, you have to clear and then check errno. So new xstrtol() that cares about overflow.

The bionic and musl guys agree faccessat(AT_SYMLINK_NOFOLLOW) is not supported, so stop using it.

Fixed toy_exec() to detect when argc is in optargs, so we don't need a separate xexec_optargs().

February 18, 2015

Dreamhost continues to be unable to make mailing list archives work, so here's another list archive with a less awkward interface than gmane.

(Neither gives you the convenient historical monthly views of mailman, but I still have hopes dreamhost will someday figure out what they're doing wrong. They've only been trying since October. Last month they did a hardware upgrade to fix a software problem, and the stale data loads much faster now, so that's something.)

Update (Feb 19): the archive started updating again, by discarding all the pending data. So there are now _two_ giant holes in Dreamhost's web archive, from Dec 15-Jan 3, and then another hole from Jan 16-Feb 18. The relevant messages are in both of the other archives. Here's hoping the chronic archive constipation problem won't happen a sixth time.

December 30, 2014

Due to Dreamhost's ongoing inability to make mailman work reliably, I've added a link to a backup web archive at gmane to the nav bar on the left.

You still subscribe to the list through the first link.

Update (January 27, 2015): they're still working on it.

November 19, 2014

"This time it was right, it would work, and no one would have to get nailed to anything." - The Hitchhiker's Guide to the Galaxy.

Toybox 0.5.1 (commit 1566) is out.

It's an interim release, mostly bugfixes. There are several new commands, but they're all in pending.


Finally implemented sed, which is still in pending because although it's feature complete according to posix, and even passes the parts of Busybox's sed test suite that aren't explicitly testing for gnu bugs we don't want to copy, it's not yet good enough to build Linux From Scratch. (The ./configure stages use very long sed scripts. 20 commits worth of implementation and debugging, just under 1000 lines of code, and there's still more to do. We're definitely up to some of the "fiddly" commands now. Did you know "echo hello | sed p - -" segfaults gnu sed in Ubuntu 12.04? Yeah...)

Talked with the Tizen developers to follow up on their desire to make toybox a part of the base Tizen system, and got a list of commands to add to the roadmap. The tizen todo list is:

wget, sha256*, gzip, gunzip, bunzip2, rsync, zdiff*, less, ar, arch, base64, csplit, dir, fmt, join, nproc, shred, shuf, stdbuf, stty, test, tr, unexpand, users, vdir, diff3, sdiff, dosfsck (fsck.vfat), awk, fdisk

(Most of which was already on the todo list, but it helps prioritize.)

Fixed md5sum and sha1sum on big endian systems (reported by James McMechan). Andy Lutomirski fixed unshare's help text and option parsing, and submitted nsenter (a tool to use setns(2)) to pending. Isaac Dunham implemented acpi -ctV options, and spotted the bug that ls -d was inappropraitely following command line symlinks without -H or -L (it should act like ls -l does), and ls -F handles symlinks wrong too. Lukasz Szpakowski sent in two bugfixes to tail.c. Cynt Rynt spotted an unnecessary assignment in lib/password.c.

Ashwini Sharma's team was as busy as usual, submitting tr, crontab, and ipcrm, and hwclock to pending, more features to the pending ip.c, and a pile of bugfixes (to chgrp, killall, ifconfig, insmod, losetup, comm, cp, id, xwrap, netcat, modprobe, nohup...) mostly found by static analysis. (These fixes are mostly to seldom-used codepaths like the TOYBOX_FREE config option, but test coverage is always appreciated.) Ashwini also suggested upgrading ln -f to leave the original target alone if link creation fails, and reported that mv -f and -i weren't implemented (now fixed).

New config option: TOYBOX_NORECURSE prevents xexec() from making internal function calls (for nommu systems with a finite stack).

The "toybox" multiplexer command no longer adds a trailing space to each line of command names, so things like "./toybox | tr ' \n' '|'" to create a grep pattern snippet are easier to do. (Why you'd want to is your business, but the output is tidier now.)


Isaac Dunham added Android support to portability.h, including compile probes for functions missing from bionic-libc, and annotated the commands that use those functions. We haven't really tested building against bionic, but in theory it's possible now.

Running the test suite now color codes the PASS/SKIP/FAIL notifications if output is to a tty. (And in case you missed it last time, VERBOSE=fail to stop at the first failure is really useful.)

In loopfiles_rw() use O_CLOEXEC instead of O_RDONLY to request the loop function close filehandles for us. (Otherwise the callback function must close each supplied filehandle itself.)

The printf-style escape parsing ("\n" and friends) got factored out into a new unescape() function.

October 2, 2014

"There is an art, it says, or rather, a knack to flying. The knack lies in learning how to throw yourself at the ground and miss... Clearly, it is this second part, the missing, which presents the difficulties." - The Hitchhiker's Guide to the Galaxy.

Toybox 0.5.0 (commit 1512) is out.

New commands

The new commands are find, install, factor, and mount. Promoted commands (cleaned up and moved out of "pending") are lspci, inotifyd, and blockdev.

cp now implements -HL and -F to force delete of pending files, cpio now ignores -m and implements -p, ls -C now has utf8 support (using wcwidth instead of strlen), and umount got a number of upgrades involving looking things up in /proc/mounts. Other minor cleanups happend to cut, touch, free, and id.

In pending: Bradley Controy submitted mix (adjusts OSS sound volume). Ashwini Sharma submitted diff, userdel, blockdev, ipcs, and crond, upgraded fdisk, fsck, and ftpget, and ran a static analyzer on a lot of other code. Partial cleanup was done to useradd, userdel, groupadd, and groupdel.

Build infrastructure

Parallel builds

The build now takes advantage of SMP, autodetecting the number of processors. (Export the environment variable CPUS to pick a specific number.) Other build changes: split out $LDOPTIMIZE because old compilers complain about linker options passed with -c, and the entire "generated" directory now gets deleted by clean (the README that was in there got merged into code.html).

Standalone builds

The standalone build infrastructure (scripts/ got upgraded to build more commands as standalone executables. In the source file selection uses a regex to find the source files with the NEWTOY/OLDTOY macro for the command. It enables each command's sub-options (so CP has CP_MORE), enables I18N and FLOAT support to build full-featured commands, and includes --help text (at least when the command doesn't use another command's help). The OLDTOY() macro now produces (redundant) function prototypes so you can build an OLDTOY without the NEWTOY

It doesn't quite have complete coverage yet, the defconfig entries that aren't building standalone yet are:

chown, egrep, fgrep, fstype, halt, mv, nc, poweroff, unix2dos, whoami

The main reason for standalone build failures is NEWTOY() or OLDTOY() entries that don't have their own config symbol. Another problem is entries that depend on another entry in kconfig, usually because common infrastructure is using one command's flags (which the other commands copy): if that command is disabled, the FLAG macros become 0 so dead code elimination can remove the code. It's possible to untangle this, but a bit awkward. (It boils down to conflicting design goals in the two contexts.)

Standalone builds are used by the test suite when testing individual commands.

Snapshot builds

A new addition to the "generated" directory is generated/ containing a single compiler command line to build toybox in its current configuration. Combined with the generated/*.{h,sh} files from an exisiting build, this may let you build on a new system that hasn't quite got enough OS bits working to run a full configureand make.


Library code: xcreate/xopen now O_CLOEXEC by default to avoid leaking filehandles to child processes. DIRTREE_COMEAGAIN's second callback is now done with the directory filehandle still open (new dir->again variable added to distinguish first from second callback, and requesting DIRTREE_RECURSE now requires passing in the specific macro value, not just a true/false). Use daemon() out of libc instead of hand-rolled daemonize() in various pending commands. string_to_mode() now passes through type bits so you can use it to more easily modify a file's existing mode. Split xpopen() into xpopen_both(), xopen(), and xrun() depending on whether we want to redirect both, one, or neither of stdin/stdout.

Bugfixes: Better error message when TOYBOX_SUID option can't drop priviliges (which happens when you suid something _other_ than root). The old pending version of nbd_client.c wasn't deleted when the command was promoted (and the build would break if both were enabled), toy_exec() sometimes needs to re-exec from $PATH rather than recurse internally (to gain dropped root permissions or limit stack depth), always call setlocale() when I18N is enabled to switch it back _off_ when we run commands that expect sscanf("%n") to return bytes, dirtree() had a memory leak in an error path, patch.c had some bugs in error paths (didn't report problem clearly). Ashwini Sharma spotted an option parsing bug where [-abc] would forget _all_ command line arguments saved in the GLOBALS() block (not just the ones for options being switched off), plus various minor fixes to nbd_client and cpio. Lukasz Szpakowski fixed rm -f on a broken symlink (failed), and killall with no arguments (segfaulted).


A somewhat fiddly fix to rm -rf (which needs to chmod directories to u+rwx to descend into them) which hit a musl bug in faccessat() which the musl maintainer refuses to fix. (He literally wants the man page changed instead, despite other libcs working.) Added an #ifdef __MUSL__ section to portability.h with a workaround, you may need CFLAGS=-D__MUSL__ in your build if your musl build's features.h doesn't #define that. (I may do a different workaround in future, but sometimes you've just got to make it work so you can ship. Also, toybox grep with multiple patterns requires a patch to musl's regex engine, which applies to 1.1.4 but not to the current musl source control.)

More portability.h fixes for uClibc too. (I don't expect that to ever have another release, so locally patching around posix-2008 violations is silly).

Change to username filtering

Posix recommends the username creation logic filter usernames to a small allowed set of characters (which even Red Hat breaks by explicitly allowing "$" at the end), but this prevents UTF-8 usernames. Posix' stated logic is to allow filesystems to create the user's home directory, but Linux filesystems can accept any character but NUL and "/". The only characters we actually _need_ to filter out are ":" (field separator in passwd), newline (line separator in passwd), and "/" (directory separator in filesystem).


Web pages updated: cleanup.html documents more cleanup, code.html documents more code, and about.html now capitalizes "toybox" consistently (it's just a word, capitalize at start of sentence).

The pending/README file now lists commands that needed review/cleanup before the pending directory was added.

Test Suite

Moved out of scripts/test into top level "tests" directory, and the script is now in scripts rather than mixed into the *.test files.

Johan Bergström requested VERBOSE=fail to make tests (telling it to stop at the first failure), and spotted a build bug where using gnu sort on the host broke in non-C locales.

Divya Kothari submitted tests for chmod, link, tar, bzcat, xzcat, zcat, and hostname. (And more, but that's all that's merged so far.)

July 7, 2014

"This planet has - or rather had - a problem, which was this: most of the people living on it were unhappy for pretty much of the time. Many solutions were suggested for this problem, but most of these were largely concerned with the movement of small green pieces of paper, which was odd because on the whole it wasn't the small green pieces of paper that were unhappy." - The Hitchhiker's Guide to the Galaxy.

Toybox 0.4.9 (commit 1385) is out.

New commands added to pending include: lsattr, chattr, inotifyd, rfkill, sulogin, strings, makedevs, killall5, and tar from Ashwini Sharma, arp from Kyungwan Han, sysctl by Bilal Qureshi, partprobe from Bertold Van den Bergh, host from Rich felker, and I did nbd-client and the first 2/3 of mount.

Finished cleanups (commands promoted out of pending): sysctl, rfkill, strings, mkpasswd, makedevs, partprobe, killall5, fallocate, and nbd-client.

(Along the way partial cleanups got made to: last, fold, lspci, ps, bootchartd, init, fsck, telnetd, telnet, vconfig, toysh, iconv, useradd, login, host, openvt, deallocvt, getty, tftpd, and modprobe. But there's still more to do on all of those.)

This time around the static binaries are linked against musl instead of uClibc. (That's why there's no sparc version, musl doesn't support that target yet.)


The help text parser expects lower case "usage:" lines with a blank line after them, so go through and regularize those. Expand the "coding style" section in the docs and move it to design.html. (Not a show stopper for incoming contributions, just an explanation of some of the things I'll do to them during cleanup.) The help text for the "toybox" command now includes the shell script snippet to install symlinks to the toybox binary.

The cleanup page now has descriptions for the full ifconfig cleanup series, among others.

The new toys/examples directory contains hello.c and skeleton.c. The first is a simple hello world program in toybox style, the second is a much more elaborate example program using showing how to use the command line option parsing and how to provide multiple commands in the same C file.


Fix od bug reported by Samuel Holland ("od -v -b" was appending the default output type even though an output type was specified). Ashwini Sharma reported bugs where readfile() was incorrectly freeing its buffer, and where toy_init() was zeroing the wrong data because the field it was using to measure (rebound) had moved (when I moved it back I added a comment why the field needs to be there), fixed a segfault in the dhcp client, and made a 0 length read at the start of password entry count as EOF. Make the "we are not root" test in the init code show the help text. Posix implies that fflush() can return success even when the stream's error bit is set, so call both fflush() and ferror() from xprintf().

Isaac Dunham pointed out that bloatcheck couldn't deal with diff implementations that only implement "unified diff" format, and that some diff implementations can't handle nonseekable input (I.E. reading from a pipe). Bugfix so "help -a" works again. Option parsing on nohup now stops at first nonoption argument. Fix segfault in "which" if PATH wasn't set, which was actually a bug in lib function find_in_path(). Made rm -rf of chmod 000 directories actually remove them.

The build now passes the same $CFLAGS to the library probe as the final build, because arch linux is so broken it provides different sets of libraries for static and dynamic linking.

It turns out sprintf("%.123s", str) is counting characters, not bytes, so globally enabling locale support opens stack smashing vulnerabilities. So there's a new TOYFLAGS_LOCALE you set in toyflags when you want the setup code to setlocale().


Isaac Dunham extended cpio to archive unreadable empty files, and I taught it to set uid/gid and timestamp when extracting archives. Isaac also added tests for cpio, link, and du, added lspci -i, made the pci database parsing skip # comment lines, merged logname and whoami into id.

Daniel Verkamp sped up md5sum about 30% with some loop unrolling, making it actually smaller in the process. I added -b flags to md5sum and sha1sum for "brief" output that's just the hash with no filename. (I'm aware other implementations use that for MSDOS "binary" mode, and don't care.)

When building standalone commands (scripts/ commandname), the build now switches on all the sub-options of the command so we get a standalone version with all the bells and whistles enabled.

Add -ds flags to date and document +FORMAT escapes. Add the shell NOP command ":" as an alias for true (for toysh).

Add uClibc probe for iconv() and fallocate. (The fact it didn't always build against uClibc is why fallocate wasn't enabled in defconfig before.)

The umount command now does an losetup -d on the device by default, so we don't leak loopback devices. Bugfix to losetup so "losetup /dev/loop0 filename" actually works again.

Divya Kothari sent in test suite entries for ls, ln, rm, mv, printf, dd, and renice. Then a second round for lsattr/chattr, mount, chmod, pgrep/pkill, groupadd, groupdel, and useradd. Several of these uncovered bugs, still working to fix them.

There are now free() functions for the predefined llist types and a dlist_terminate() function to break doubly linked lists. The new generic_signal() handler either sets "toys.signal" or writes a byte to toys.signalfd with the signal number if signalfd isn't -1 (which it's initialized to in toy_init).

The option parsing logic can now detect when a double fits in a long and use the more precise type for floating point arguments (the FLOAT macro contains the type used). The human_readable() function now just outputs decimal kilo/mega/gigabytes (so when du -u says 5.0G it means 5.0 billion bytes). The build infrastructure now notices duplicate commands (so if you cp toys/pending/command.c toys/other/command.c and forget to delete the first one, the build break is now more informative).

April 20, 2014

And to this end they built themselves a stupendous supercomputer which was so amazingly intelligent that even before the data banks had been connected up it had started from "I think therefore I am" and got as far as the existence of rice pudding and income tax before anyone managed to turn it off. - The Hitchhiker's Guide to the Galaxy.

Toybox 0.4.8 is based on commit 1262. And about time too.

The big news is that the build no longer needs python to generate help.h, that's now done in C. The help text generation is also collating help text from multiple options, merging command line option blocks and usage: lines. There's even a new help web page.

New commands: Ifconfig, cpio, and su were cleaned up the rest of the way and promoted out of pending. That saga is mostly explained on the cleanup page. Vivek Bhagat's freeramdisk, Isaac Dunham's fsfreeze, and Felix Janda's iconv are also new.

In pending: Ashwini Sharma's team submitted tcpsvd, udpsvd, telnet, telnetd, last, more, groupdel/delgroup, arping, brctl, ftpget, ftpput, printf, reset, and added ipv6 support to traceroute. Kyungwan Han's team submitted modprobe and getty. Vivek Bhagat submitted openvt and deacllocvt. Samuel Holland submitted fold. I wrote a new inflate (zip/zlib/gzip decompression) implementation in compress.c, and still need to do a corresponding deflate (compression-side) and plug them into gzip and zip and so on. (Right now it does zcat.)

Several commands (vmstat, login, du, vconfig, mountpoint, free, chroot, cut, touch, modinfo, expand) predate the "pending" directory, and are thus in other directories but still need cleanup. Of these, vmstat got some work this time (which would be much easier other vmstat implementations documented what their output actually meant).

Upgrades: Ifconfig grew /prefix netmask support (ala Grep now has -zZ to handle null terminated data, cksum grew -H for hex output. Upgraded od so the fields align better when producing multiple output types. Help has -a and -h options (all commands, html output). Bugfix to blkid building for a 32 bit target. The date command can actually set dates now. The O_NOFOLLOW compile time probe didn't work with cross compiling, so it's back to an #ifdef test in portability.h. Nathan McSween sent in a bugfix to od and a portability fix in the common library code. Ashwini Sharma spotted a bug in pidof -o, and added verbose (-v) options to mkdir and ln, and suggested killall should have an -s option and allow -l to take zero arguments. Ashwini Sharma and Felix Janda upgraded tftpd. Fixed dumpleases still using toynet.h after that was removed. Corrected killall return code and error reporting. Isacc Dunham fixed bugs all over the tree, did cleanup on a bunch of pending commands (getty, ftpget, init, openvt, modprobe...), and clarified find's help text. Tom Sparrow ran three different static analyzers on the code, which resulted in a few cleanups. The peek()/poke() functions now use "volatile" to prevent broken compiler "optimizations" to do with aliasing.

Build stuff: Each FOR_xxxx macro now has a complementary CLEANUP_xxxx macro, so you can put multiple commands with different command line options in the same .c file, so they can share infrastructure outside of lib. (This let the bunzip logic move out of lib into bzcat.c.) See XXX for example. i

The headers #included in toys.h are now grouped by standard, and headers not listed in Posix or LSB were moved to portability.h. The old xregcomp.h was folded into lib.h because it's posix (and supporting oddball uClibc configurations isn't as important as it once was).

Regression tested against Ubuntu 8.04 to fix up bit-rot in defconfig build on older systems. (We depend on Posix-2008, but not necessarily the absolute latest build environment.)

In lib: lib/xwrap.c added xgetpwnam(), xchroot(), and lib/lib.c now has names_to_pid(). xsetuid() was replaced with xsetuser() which takes a struct passwd and sets both gid and uid, mkpathat() got factored out into a library command, get_int_value() became atolx_range(), and xmsprintf() is now just xmprintf(). The bunzip2 logic moved from lib into bzcat.c.

Documentation: new help page with the help text for all the defconfig commands, using the new help -ah output. The source code walkthrough now says more about #including header files, and how the generated/* directory works. The design page has some new paragraphs about trading of different kinds of simplicity, and why comments aren't a substitute for good code. The README no longer trails off into obvious unfinished confusion at the end. Each page on the website should now have its own title.

November 18, 2013

"Space," it says, "is big. Really big. You just won't believe how vastly, hugely, mindbogglingly big it is. I mean, you may think it's a long way down the street to the chemist's, but that's just peanuts to space." - The Hitchhiker's Guide to the Galaxy.

Toybox 0.4.7 is based on commit 1122.

New commands: Brad Conroy submitted blkid. Elie De Brauwer submitted reboot, halt, and poweroff. Strake's nl got cleaned up and promoted from pending to posix. In addition, the existing chvt and vconfig got some cleanup.

That said, I haven't nearly kept up with the flood of new commands going into pending: Ashwini Sharma's team submitted dd, dumpleases, traceroute, top, useradd, groupadd, mkpasswd, tftpd, and an fsck wrapper (with no filesystem drivers yet). Isaac Dunham sent in cpio.

Bugfixes: Jeroen van Rijn added a user count to uptime. Elie De Brauwer added -e to watch, removed a memory leak, and fixed a terminal size problem. William Haddon made xargs call its command line once even with blank input (the standard is vague, but builds expect it), and fixed an off by one bug where grep didn't malloc enough space with -E (leading to a segfault). I fixed a glitch in bunzip2 (same one as went into busybox since they're using the code I wrote), in od to fix -t co, -J, and -c options. Add uname -o as a synonym for -s. Build fix to never use $CC without prefixing it with $CROSS_COMPILE (since $HOSTCC could be different). Anca Emanuel spotted a typo in the web page.

The compile-time command line option parsing got rewritten (ported from bash to C), which should speed up builds a bit and allow code controlled by --longopts to drop out properly when disabled in the configuration. Terminal querying got refactored. Patch's -x option is now more informative (a debug thing if you're trying to figure out why a patch didn't apply). The "toynet.h" file got folded into toys.h since musl supports it and micromanging uClibc options isn't very interesting anymore. The test suite now uses scripts/ when testing a single command.

September 17, 2013

"Think of a number," said the computer, "any number." Arthur told the computer the telephone number of King's Cross railway station passenger inquiries, on the grounds that it must have some function, and this might turn out to be it. - The Hitchhiker's Guide to the Galaxy

Toybox 0.4.6 is based on commit 1068.

This release adds several new commands: Felix Janda wrote paste and fallocate, Kyungwan Han submitted eject, Strake contributed grep, Ashwini Sharma added pmap (and a testsuite entry for grep), Lukasz Skalski sent pwdx, Isaac Dunham posted acpi, and I did timeout and umount.

The ls command now has a --color=auto option (suggested by Rich Felker). The multiplexer now has a --help option so you can say "./toybox --help blah" instead of using the built-in "help" command. (Which is a shell built-in. Try it on your command line, it's like man for shell builtins. But a certain other project has conditioned people to expect --help, so...) I forget who heehooman at gmail is but they pointed out unshare needed PID and UID namespace support.


A lot of new commands in toys/pending, to the point the next release should probably just focus on cleanup and review of this backlog. We've got klogd, dhcp, dhcpd, watch, route, and ps from Ashwini Sharma (and an fsck wrapper but no fsck.fstype engines yet), syslogd, pgrep, and pkill from Madhur Verma, netstat by Ranjan Kumar, test by Felix Janda, lspci by Isaac Dunham, nl, su, and renice by strake (I.E. M. Farkas-Dyck), and sysvinit by Kyungwan Han.

Some cleanup work on existing pending commands that aren't ready to promote yet: I did a few more rounds on ifconfig and Isaac Dunham's did several cleanups to xzcat, Felix Janda cleaned up logger and syslogd...

Also some cleanup work on commands that predate the pending directory, but weren't quite polished when they went in, most prominently du, expand, and touch.


The new scripts/ builds a standalone command without the multiplexer, although not all commands can be built that way yet (NEWTOY yes, OLDTOY no) and the space savings aren't anything to write home about. (If a command needs the option parsing logic at all, it needs all of it.) If you're curious, you can do:

make defconfig
mkdir singles
for i in $(./toybox)
  echo $i
  PREFIX=singles/ scripts/ $i || break

(And then wait a long time and watch almost half the builds fail.)

There is now libbuf analogous to toybuf, another global 4k buffer this time for use by lib/ code instead of command code.

The lib directory got split up a bit, lib/pending.c contains functions not yet used by anything outside of toys/pending/*, and lib/xwrap.c contains functions that wrap other functions and handle failures (via error_exit). This leaves lib/lib.c containing actual new functions.

General improvements and bug fixes to argument parsing. The [-abc] exclude logic should now clear arguments slots when disabling options. Bare --longopts should work now and be able to report errors using their name, the new ; option allows optional arguments to longopts only suppliable with = (I.E. --color and --color=auto but not --color auto).

I'm gradually weaning the code off of itoa()/utoa() because sprintf does this already. In this case "simple" probably means "let libc do it for us".

Rewrote for_each_pid_with_name_in() and renamed it to just names_to_pid(). It shouldn't get confused trying to compare absolute and relative paths quite so much anymore.

lib/llist.c grew a new dlist_pop() function for removing a doubly linked list entry while maintaining a circular list; tail and patch are using it now.

The musl guys suggested a new optimization flag (-fno-asynchronous-unwind-tables) that shaves about 10% off the binary size by removing a C++ism that crept into gcc's idea of C. While I don't normally try to micromanage the compiler, "-fstop-being-stupid" is a thing you have to hit gcc with from time to time.


Felix Janda and I did a largeish rewrite of tail to finally make it work right (we think). Still need to implement tail -f someday (the tricky bit is making -f follow multiple files at once). Felix also reported a bug in xpidfile.

Juhani Haverinen pointed out that python 3 doesn't work with, so the detection logic looks for python2 (until I get around to rewriting that in C). Elie De Brauwer then fixed our first attempt at this, and also fixed uname's help string.

Ashwini Sharma pointed out the build was making a FLAG_ macro for " " which broke some configurations. (That's a control character, not a command line option.)

Jacek Bukarewicz pointed out a bug in chdir permission handling, and a way to make env segfault. Both should be fixed now.

The new function xexec_optargs() replaces calls to xexec(toys.optargs) to avoid freeing and reusing optargs during option parsing screwing stuff up (such as netcat's exec mode).

The stat command's %a output was padded with leading zeroes, which didn't match anybody else's behavior and thus made the test suite hiccup between TEST_HOST and testing toybox. (If you go "TEST_HOST=1 scripts/ command" it sanity checks the tests against the host implementation.)

Last release, "mkdir sub/sub && chmod 007 sub/sub && rm -rf sub" didn't delete sub and didn't exit with an error either. Neither was correct, rm should now be fixed.

July 26, 2013

Georgi Chorbadzhiyski maintains a git mirror of the repository on github, automatically updated from the mercurial every 6 hours. The mirror is read only, but you can generate patches against it and post them to the list.

July 2, 2013

"Time is an illusion. Lunchtime doubly so." "Very deep. You should send that in to the Reader's Digest. They've got a page for people like you." - The Hitchhiker's Guide to the Galaxy.

Toybox 0.4.5 is based on commit 941. It adds uuencode and uudecode from Erich Plondke, and enables Luis Morales' "who" by default. Felix Janda and I cleaned up last year's "stat" submission and enabled it. Ivo van Poorten added "groups". Andre Renaud added "lsusb". I implemented "split", "pivot_root", and "mv".

The "help" command is implemented differently now (lib/help.c) and each command can now understand --help (including both "toybox --help" and "toybox --help command" in the multiplexer).

The "pending" directory has several commands (find, xzcat, nbd-client, logger, expr) which work but are not enabled by default pending further cleanup. Ifconfig is enabled, but still in pending because it's only 2/3 cleaned up. (It's an awkward halfway state but I'm not holding up the release for it.)

I'm documenting the cleanups to teach more people to do it, but the writeups aren't caught up yet. The roadmap also got updated a bit with further analysis of other projects, and the README and about pages got updated.

Fixed _another_ "ls -C" segfault when terminal size can't be detected, condensed the ls help text to fit on one page, implented --color, and taught -l to print the major, minor numbers when showing block/char devices. Argument parsing now handles "--" properly (to end option checking), and the infrastructure can now handle bare --longopts that have no corresponding short option (both were implemented before but didn't work). Fixed an old bug in "patch", chmod grew -f, who grew -a. Isaac Dunham fixed "-" vs "_" handling in modinfo, added a "firmware" output field, added -b and -k support, and taught it that the ".ko" extension means to look for the file at the specified path instead of under /lib. Felix Janda moved file permission display code to lib so ls and stat could share it. Ashwini Sharma spotted a bug in xabspath when the last path component exists but we haven't got permissions to open it (ala readlink -f /dev/sda as a normal user).

In the build infrastructure, scripts/ finds leaked global variables. (Leaked means they aren't part of the global union: Other than glibc debris, toybox should define "this", "toy_list", "toybuf", and "toys", and that's it; the rest add memory footprint to every command for the benefit of just one command; use GLOBALS() to stick 'em in the union.) Static linking against libraries other than the host's libc now applies to feature probes for unshare and such. Neuter stupid internationalization support that makes various host "sort" commands put things in an order other than alphabetical (breaking the multiplexer's binary search on command names).

You should now be able to build from a source control snapshot on a build system that hasn't got python: if you disable CONFIG_TOYBOX_HELP. (The release tarballs ship generated/help.h, but it's not in source control. Eventually I should rewrite that python script in C.)

LICENSE TWEAK: After discussion on the mailing list the "2 clause BSD" license got slightly simplified so the first paragraph now says:

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

It used to continue "provided that the above copyright notice and this permission notice appear in all copies", but A) what's the point? B) does "all copies" mean binaries, or just source code, or what? C) lots of projects that consider BSD and GPL compatible have files with both license notices on them (sometimes at opposite ends of the file to make the conflict less obvious) because "all copies must include this function" would violate the GPL but "all copies must include this magic text blob" somehow don't?

I don't want to have to care about this anymore. The tweaked version is more or less public domain with a liability disclaimer, but we're still calling it BSD (sometimes "0 clause BSD") to avoid explaining.

March 21, 2013

Video of my ELC talk "Why is Toybox?" is up on youtube. Related materials include the talk outline and an android self-hosting writeup.

[Updated June 4] The following links jump to specific topics in the video. (Sorry about the ads, it's The Linux Foundation.)

March 14, 2013

"Ford, you're turning into a penguin. Stop it." - The Hitchhiker's Guide to the Galaxy.

Toybox 0.4.4 is based on commit 813, adding the "time" and "readahead" commands, plus some bugfixes.

The "cp" command now implements the -s symlink option, plus bugfixes getting various corner cases right as used in actual package builds. "id -Gn root" should now print root's groups instead of the current user's. Several build fixes so toybox builds under Ubuntu 8.04 again (which is about as old a build environment as you can expect to find posix-2008 features in).

Unfinished commands have generally been moved to "toys/pending". Everything else should "default y" to participate in make defconfig. Several of those pending commands got some basic cleanup so allyesconfig should at least compile (although defconfig is still what's useful).

Significant roadmap updates, checking several other multicall binaries (klibc, sash, sbase, s6...) to see what commands they include.

January 18, 2013

This must be Thursday. I never could get the hang of Thursdays. - The Hitchhiker's Guide to the Galaxy.

Toybox 0.4.3 is based on commit 793. There are now exactly 100 commands in defconfig (of a little over 220 on the todo list).

Elie De Brauwer added the rev command, cleaned up tac, implemented the -s and -f flags for seq, added -v and -i to killall (and fixed killall not to kill itself before finishing its pid list), and added to the test suite. Felix Janda added -m to mkdir, pwd -L and -P, and more test suite entries.

Rob Landley added the losetup command, and fixed the existing ls, cp, and readlink commands. The segfault in ls happened when it couldn't determine the screen size (last release changed the default to -C and a screen size of 0 made column view unhappy), and cp got an extensive rewrite bringing it up to date with the dirtree changes and fixing a number of things it never did right in the first place. The xabspath() code in the library now handles a symlink after ".." properly (and the test suite checks for it).

Infrastructure-wise the code is better about automatically setting the error return code properly. Now error_msg() sets the exit code to 1 if it's still defaulting to 0, and the global exit path does a fflush(NULL) with error bit check rather than trying to be quite so granular about flushing. (That means if we use printf() instead of xprintf() it still exits with the right error code, it just doesn't end the program early on an output error.) Minor bugfix so TOYBOX_DEBUG doesn't always warn about the lack of suid bit when toybox is built with at least one STAYROOT command. Bugfix for the option [grouping] logic (and then further fixes to the error reporting pointed out by Ashwini Sharma). dirtree_handle_callback() now has a prefix like the rest of the dirtree functions. A lot of stuff doing manual path handling was switched to using libc basename() (including, embarassingly, the basename command), which means it now correctly detects "/trailing/slash/" which the previous code didn't.

Also, last release included some accidentally checked in debug code that disabled compiler optimization, so the binary size bloated a bit. It's back to -Os by default now.

December 15, 2012

"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair."

- The Hitchhiker's Guide to the Galaxy.

Toybox 0.4.2 is based on commit 749 and is just a resync. Linux 3.7 came out, meaning it's time to do an Aboriginal Linux release, and that should use a stable version of toybox. So here's a new stable version.

The new commands are cut (from Jason Kyungwan Han), touch (from Choubey Ji), expand (from Jonathan Clairembault, and he fixed a bug in login), and rm (from Rob Landley). Felix Janda added UTF-8 support infrastructure (for non-ascii character sets) with a config option. Elie De Brauwer added tests for cat and sha1sum, and -so options to pidof. The "ls" command defaults to -C (column view) now, and "readlink" now supports -fenq.

Portability work: toybox should now build against the musl C library, and against older glibc versions (circa 2008, much before that and kernel features we depend on start to drop out).

The whole codebase got reindented from "one tab" to "two spaces" per level. The option parsing logic now understands [groups] of commands (when more than one in a group is selected it can switch the others off, or error out, or other things). The error_exit() infrastructure can now longjmp back to an earlier point instead of exiting. Each toys/* directory now has a README, the first line of which is the fancy name menuconfig uses for the directory (so no more hardwired directory list in scripts/

Fixed a filehandle leak in getmountlist(). Pass parent pointer to dirtree_add_node() so it can give error messages with full path. The yesno() function now always reads from stdin and writes to stderr (we can retry tty checking complexity once we've got commands needing it).

The open group broke their website so the old links to POSIX 2008 now need to start with pubs. Some of the links in the tree have been updated, others haven't while I wait to see if their webmaster notices and fixes it.

(I note that the current rm implementation is not technically posix compliant because the standard requires infinite recursion depth and the current implementation uses one filehandle per level. I can add a config option to do it Posix's way, which is more brittle and needs extra security checks, but am waiting for somebody to complain first. The default "ulimit -n" is 1024 filehandles, so drilling down over 1000 nested subdirectories).

November 13, 2012

"Rule Six: The winning team shall be the first team that wins." - The Hitchhiker's Guide to the Galaxy.

Toybox 0.4.1 is based on commit 691.

Elie De Brauwer contributed usleep, Ashwini Kumar contributed du, and Kyungwan Han contributed vconfig. Other new commands include switch_root and md5sum, and the remaining shell wrappers are now proper commands (dos2unix, unix2dos).

The patch command now supports -l, and gethostname is now enabled by default. The df command follows symlinks to get the actual device name. Felix Janda added -m support to wc (for utf8).

On the infrastructure side, the commands have now been grouped into "posix", "lsb", and "other" subdirectories (for things required by Posix-2008, the Linux Standard Base 4.1, and commands in neither). This affects menuconfig and the actual source layout (toys/cp.c is now toys/posix/cp.c, and so on). An android directory is planned (see the updated android roadmap analysis).

The FLAG_ macros for command option parsing and TT alias for the command's global block are now automatically generated, commands should #define FOR_commandname before #including to get the macros for that command.

An upgrade to the build infrastructure now allows commands with _ and - in them, such as switch_root.

Bugfixes: Avery Pennarun spotted a case where ls showed uid twice instead of uid and gid, and that nice was using the wrong range of numbers. The ls command also recursed inappropriately last time (not quite properly converted for the dirtree changes last release), and now it's fixed. Roy Tam pointed out a glitch in sh, and fixed df's percentage calculation to match the POSIX spec. The kernel build didn't like our mktemp and it does now. The wc command wasn't quite posix compliant (trailing spaces break stuff). The ls command recursed inappropriately last time (not quite properly converted for the dirtree changes last release), and now it's fixed. The catv command wasn't displaying byte 255 correctly. Some lib fixes (thinko in xpidfile). Fixed uname -m when running a 32 bit x86 binary on an x86-64 host (it lies and says the system is i686, i586, or i486 depending on what the toolchain that built the binary supported. This makes builds in a 32 bit chroot on a 64 bit kernel break less.) The df command was checking partitions in the wrong order (displaying undermounts instead of overmounts: this used to work but some library code changed out from under it and it wasn't updated to match until now). Felix Janda filled out the test suite some more. The patch file creation logic got tweaked several times to successfully apply more patches. Support for older (pre 2.10) glibc versions was added to portability.h.

Miscelaneous cleanups all around (mknod, sha1sum, logname), including a rewrite of taskset to be less dependent on libc getting the headers right. All the command headers should now point to the current relevant standards document, where applicable.

This news page had old news entries from before the relaunch moved into a separate oldnews page.

I forgot to create static binaries last time, but they're back now.

July 23, 2012

"Ford", Arthur said. "There's an infinite number of monkeys out here who want to talk to us about this script for Hamlet they've worked out." - The Hitchhiker's Guide to the Galaxy.

Toybox 0.4.0 is based on commit 640.

The new status page is calculated from the roadmap info, and should be easier to keep up to date in future.

Andre Renaud contributed od and modinfo. Elie De Brauwer contributed taskset, bugfixes to cmp and tail, and tests for sort and tail. Kyungwan Han contributed passwd. Gaurang Shastri contributed w. Ashwini Sharma spotted a case where dirtree was adding extra slashes to a path.

I rewrote od, cleaned up comm, documented the llist and dirtree infrastructure, added an -r option to date (and fixed a bug where -u wouldn't override /etc/localtime), fixed bugs in chmod +stw, fixed ls to show suid bits properly when the corresponding executable bit wasn't set, and worked around a longstanding glibc bug where static linking prevents stdout from automatically flushing pending output on exit.

June 25, 2012

"For a moment, nothing happened. Then, after a second or so, nothing continued to happen." - The Hitchhiker's Guide to the Galaxy.

Toybox 0.3.1 is based on commit commit 607. It's mostly a bugfix release for ls -l (which was unhappy on targets other than x86-64), plus a new "date" from Andre Renaud and rewritten chgrp/chown which now support the full set of posix flags, plus a little work on the test suite and some more header tweaks towards eventual compatability with the musl libc.

The todo list runneth over, but "release early, release often", so here it is. The roadmap and documentation are a bit behind, and I've got ~40 pending submissions to review. I need to catch up...

June 12, 2012

"For instance, on the planet Earth, man had always assumed that he was more intelligent than dolphins because he had achieved so much - the wheel, New York, wars and so on - whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man - for precisely the same reasons." - The Hitchhiker's Guide to the Galaxy.

It's well past time for toybox 0.3.0, so here it is, based on commit 595, and the statically linked prebuilt binaries should actually be statically linked this time (thanks Ashwini Sharma for spotting that).

It's hard to figure out where to cut a release, because development doesn't stop. "Long before now" is the obviuos answer, of course. The project's maintainer also moved house during this development cycle, which threw things off for a bit (so many boxes). Releases should hopefully be a bit more frequent from here on.

The big things Rob worked on this time were the new dirtree (directory tree traversal) infrastructure, and a complete rewrite of ls using that which should now implement all 26 posix options.

Georgi Chorbadzhiyski added printenv, whoami, mkdir, mkfifo, chmod, chown, chgrp, and uniq. He also added fraction and extension support to sleep (so if you need a quarter-second sleep, it can do that now), and fixed a build bug on slackware.

Daniel Walter contributed a string to mode_t parser (in use by chmod and mkdir -m). Ilya Kuzmich contributed comm. Elie De Brauwer added mountpoint, vmstat, logname, login, and mktemp. Kevin Chase did some portability cleanups. Pere Orga fixed some documentation.

The "tac" and "clear" commands are now normal commands instead of shell wrappers, and the header #includes have been cleaned up a bit to remove deprecated functions and attempt to increase compatability with the bionic and musl C libraries, "tail" should now use lseek() for large files, and "id" got some cleanups and bugfixes.

The new TOYBOX_FLOAT configuration option selects whether or not to include floating point support (for embedded targets where that's problematic).

Several random bugfixes: unshare() might actually build portably now, yes 'n' | cp -i should no longer bypass stdin and prompt via the tty, the SUID support no longer drops permissions going through the toybox multiplexer command, and a bugfix to xargs -0 means it should no longer segfault. (I have a pending bug report about xargs not doing the full posix whitespace handling that -0 obsoleted, but I'll deal with that next release.)

The build infrastructure is now automatically generating FLAG_ macros for the options, but currently with the wrong names. Some more macro glue is necessary, which I haven't quite figured out how to do yet.

A defconfig toybox at the start of the $PATH has successfully built Linux From Scratch (in my Aboriginal Linux project). The commands that 'default n' in the config are often still broken, cleanup is ongoing. (The new dirtree stuff broke several of them that haven't been converted yet, but if I wait until everything works we won't have a release before 1.0, so here's a checkpoint.)

March 3, 2012

"They went unnoticed at Goonhilly, passed over Cape Canaveral without a blip, and Woomera and Jodrell Bank looked straight through them. Which was a pity, because it was exactly the sort of thing they'd been looking for all these years."

- The Hitchhiker's Guide to the Galaxy.

Here's toybox 0.2.1 based on commit 512. This time around, there are statically linked prebuilt binaries for various embedded targets.

It's been a busy few weeks, almost entirely due to new contributors. (I have not quite been keeping up.)

Elie De Brauwer contributed free, uptime, swapon, swapoff, lsmod, mknod, insmod, rmmod, and fixed a bug in basename. Andre Renaud contributed ls, ln, realpath, and hostname. Andres Heck contributed pidof and killall. Daniel Walter wrote kill and extended id. Timothy Elliott contributed tail and tests for cmp. Frank Bergmann sent a warning fix. Bryce Fricke added -i to cp. Nathan McSween pointed out an optimization. Georgi Chorbadzhiyski fixed cross compiling to work more reliably.

(My own contribution this time around was just tightening up other people's code, a build fix to unshare, some random bugfixes, and so on. My only new code this time around was writing a bash replacement for the existing python bloat-o-meter.)

Last time (the 0.2.0 release) included the first pass at an id command from Tim Bird, env and basename from Tryn Mirell, cmp and head from Timothy Elliott, more bugfixes from Nathan McSween and Elie De Brauwer, and Luis Felipe Strano Moraes did a first pass at the who command plus other bugfixes and optimizations.

(For that release I did xargs, cal, truncate, unlink, nohup, tty, wc, link, dirname, unshare, and various infrastructure tweaks, but it took me 3 months and those guys did their stuff in a week or so.)

February 12, 2012

"for though it has many omissions and contains much that is apocryphal, or at least wildly inaccurate, it scores over the older, more pedestrian work in two important respects..."

- The Hitchhiker's Guide to the Galaxy

Here's the first BSD licensed release, toybox-0.2.0, more a synchronization point than anything particularly useful. 47 commands in a reasonably ready-to-use state (what "make defconfig" builds), another ten or so partially finished stubs ("make allyesconfig"), and several patches pending on the mailing list I need to review and merge.

More to come...

November 15, 2011

- Back from the dead, Toybox is now under a 2 clause BSD license, and aiming to become the default command line implementation of Android systems everywhere.

More to come...

Old news from before the relaunch.