blob: 30d4dd4f90048b5d23e62aeb40dc25a0abe60474 [file] [log] [blame]
Rob Landley8f90d3a2012-07-21 23:58:40 -05001<!--#include file="header.html" -->
2<title>Toybox Roadmap</title>
3
4<h2>Goals and use cases</h2>
5
6<p>We have several potential use cases for a new set of command line
7utilities, and are using those to determine which commands to implement
8for Toybox's 1.0 release.</p>
9
10<p>Our current candidate list combines the commands toybox already implements,
11the development environment command list, the toolbox standard commands,
Rob Landley62f00212012-12-06 15:15:30 -060012various vendor configurations of busybox, a selected subset of the POSIX/SUSv4
Rob Landley8f90d3a2012-07-21 23:58:40 -050013standard, a couple of the less-insane bits of LSB, a few outright requests,
14plus additional to-be-determined shell functionality.</p>
15
16<p>See the <a href=status.html>status page</a> for the combined list
17and progress towards implementing it.</p>
18
19<hr />
20<a name="standards">
21<h2>Use case: standards compliance.</h2>
22
Rob Landley571b0702012-11-13 16:13:45 -060023<h3><a name=susv4 /><a href="#susv4">POSIX-2008/SUSv4</a></h3>
Rob Landley8f90d3a2012-07-21 23:58:40 -050024<p>The best standards are the kind that describe reality, rather than
25attempting to impose a new one. (I.E. a good standard should document, not
26legislate.)</p>
27
28<p>The kind of standards which describe existing reality tend to be approved by
29more than one standards body, such ANSI and ISO both approving C. That's why
30the IEEE POSIX committee's 2008 standard, the Single Unix Specification version
314, and the Open Group Base Specification edition 7 are all the same standard
32from three sources.</p>
33
Rob Landley62f00212012-12-06 15:15:30 -060034<p>The <a href="http://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html">"utilities"
Rob Landley8f90d3a2012-07-21 23:58:40 -050035section</a>
36of these standards is devoted to the unix command line, and are the best such
37standard for our purposes. (My earlier work on BusyBox was implemented with
38regard to SUSv3, an earlier version of this standard.)</p>
39
40<h3>Problems with the standard</h3>
41
42<p>Unfortunately, these standards describe a subset of reality, lacking any
43mention of commands such as init, login, or mount required to actually boot a
44system. It provides ipcrm and ipcs, but not ipcmk, so you can use System V IPC
45resources but not create them.</p>
46
47<p>These standards also contain a large number of commands that are
48inappropriate for toybox to implement in its 1.0 release. (Perhaps some of
49these could be reintroduced in later releases, but not now.)</p>
50
51<p>Starting with the full "utilities" list, we first remove generally obsolete
52commands (compess ed ex pr uncompress uccp uustat uux), commands for the
53pre-CVS "SCCS" source control system (admin delta get prs rmdel sact sccs unget
54val what), fortran support (asa fort77), and batch processing support (batch
55qalter qdel qhold qmove qmsg qrerun qrls qselect qsig qstat qsub).</p>
56
57<p>Some commands are for a compiler toolchain (ar c99 cflow ctags cxref gencat
58iconv lex m4 make nm strings strip tsort yacc), which is outside of toybox's
59mandate and should be supplied externally. (Again, some of these may be
60revisited later, but not for toybox 1.0.)</p>
61
62<p>Some commands are part of a command shell, and cannot be implemented as
63separate executables (alias bg cd command fc fg getopts hash jobs kill read
64type ulimit umask unalias wait). These may be revisited as part of a built-in
65toybox shell, but are not exported into $PATH via symlinks. (If you fork a
66child process and have it "cd" then exit, you've accomplished nothing.)</p>
67
68<p>A few other commands are judgement calls, providing command-line
69internationalization support (iconv locale localedef), System V inter-process
70communication (ipcrm ipcs), and cross-tty communication from the minicomputer
71days (talk mesg write). The "pax" utility was supplanted by tar, "mailx" is
72a command line email client, and "lp" submits files for printing to... what
73exactly? (cups?) The standard defines crontab but not crond.</p>
74
75<p>Removing all of that leaves the following commands, which toybox should
76implement:</p>
77
78<blockquote><b>
79<span id=posix>
80at awk basename bc cal cat chgrp chmod chown cksum cmp comm cp
81csplit cut date dd df diff dirname du echo env expand expr false file find
82fold fuser getconf grep head id join kill link ln logger logname ls man
83mkdir mkfifo more mv newgrp nice nl nohup od paste patch pathchk printf ps
84pwd renice rm rmdir sed sh sleep sort split stty tabs tail tee test time
85touch tput tr true tty uname unexpand uniq unlink uudecode uuencode vi wc
86who xargs zcat
87</span>
88</b></blockquote>
89
Rob Landley571b0702012-11-13 16:13:45 -060090<h3><a name=sigh /><a href="#sigh">Linux Standard Base</a></h3>
Rob Landley8f90d3a2012-07-21 23:58:40 -050091
92<p>One attempt to supplement POSIX towards an actual usable system was the
93Linux Standard Base. Unfortunately, the quality of this "standard" is
94fairly low.</p>
95
96<p>POSIX allowed its standards process to be compromised
97by leaving things out, thus allowing IBM mainframes and Windows NT to drive
98a truck through the holes and declare themselves compilant. But it means what
99they DID standardize tends to be respected.</p>
100
101<p>The Linux Standard Base's failure mode is different, they respond to
102pressure by including special-case crap, such as allowing Red Hat to shoehorn
Rob Landley62f00212012-12-06 15:15:30 -0600103RPM on the standard even though all sorts of distros (Debian, Slackware, Arch,
104Gentoo) don't use it and probably never will. This means anything in the LSB is
Rob Landley8f90d3a2012-07-21 23:58:40 -0500105at best a suggestion: arbitrary portions of this standard are widely
106ignored.</p>
107
108<p>The LSB does specify a <a href=http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/cmdbehav.html>list of command line
109utilities</a>:</p>
110
111<blockquote><b>
112ar at awk batch bc chfn chsh col cpio crontab df dmesg du echo egrep
113fgrep file fuser gettext grep groupadd groupdel groupmod groups
114gunzip gzip hostname install install_initd ipcrm ipcs killall lpr ls
115lsb_release m4 md5sum mknod mktemp more mount msgfmt newgrp od passwd
116patch pidof remove_initd renice sed sendmail seq sh shutdown su sync
117tar umount useradd userdel usermod xargs zcat
118</b></blockquote>
119
120<p>Where posix specifies one of those commands, LSB's deltas tend to be
121accomodations for broken tool versions which aren't up to date with the
122standard yet. (See <a href=http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/more.html>more</a> and <a href=http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/xargs.html>xargs</a>
123for examples.)</p>
124
125<p>Since we've already committed to using our own judgement to skip bits of
126POSIX, and LSB's "judgement" in this regard is purely bug workarounds to declare
127various legacy tool implementations "compliant", this means we're mostly
128interested in the set of tools that aren't specified in posix at all.</p>
129
130<p>Of these, gettext and msgfmt are internationalization, install_initd and
131remove_initd aren't present on ubuntu 10.04, lpr is out of scope, and
132lsb_release is a distro issue (it's a nice command, but the output of
133lsb_release -a is the name and version number of the linux distro you're
134running, which toybox doesn't know).</p>
135
136<p>This leaves:</p>
137
138<blockquote><b>
139<span id=lsb>
140chfn chsh dmesg egrep fgrep groupadd groupdel groupmod groups
141gunzip gzip hostname install killall md5sum
142mknod mktemp mount passwd pidof sendmail seq shutdown
143su sync tar umount useradd userdel usermod zcat
144</span>
145</b></blockquote>
146
147<hr />
148<a name="dev_env">
Rob Landley571b0702012-11-13 16:13:45 -0600149<h2><a href="#dev_env">Use case: provide a self-hosting development environment</a></h2>
Rob Landley8f90d3a2012-07-21 23:58:40 -0500150
151<p>The following commands are enough to build the Aboriginal Linux development
152environment, boot it to a shell prompt, and build Linux From Scratch 6.8 under
153it. (Aboriginal Linux currently uses BusyBox for this, thus provides a
154drop-in test environment for toybox. We install both implementations side
155by side, redirecting the symlinks a command at a time until the older
156package is no longer used, and can be removed.)</p>
157
158<p>This use case includes running init scripts and other shell scripts, running
159configure, make, and install in each package, and providing basic command line
160facilities such as a text editor. (It does not include a compiler toolchain or
161C library, those are outside the scope of this project.)</p>
162
163<blockquote><b>
164<span id=development>
165bzcat cat cp dirname echo env patch rmdir sha1sum sleep sort sync
166true uname wc which yes zcat
167awk basename bzip2 chmod chown cmp cut date dd diff
168egrep expr find grep gzip head hostname id install ln ls
169mkdir mktemp mv od readlink rm sed sh tail tar touch tr uniq
170wget whoami xargs chgrp comm gunzip less logname man split
171tee test time bunzip2 chgrp chroot comm cpio dmesg
172dnsdomainname ftpd ftpget ftpput gunzip ifconfig init less
173logname losetup man mdev mount mountpoint nc pgrep pkill
174pwd route split stat switch_root tac umount vi
175</span>
176</b></blockquote>
177
178<p>Note: Aboriginal Linux installs bash 2.05b as #!/bin/sh and its scripts
179require bash extensions not present in shells such as busybox ash.
180This means that toysh needs to supply several bash extensions _and_ work
181when called under the name "bash".</p>
182
183<hr />
Rob Landley571b0702012-11-13 16:13:45 -0600184<h2><a name=android /><a href="#android">Use case: Replacing Android Toolbox</a></h2>
Rob Landley8f90d3a2012-07-21 23:58:40 -0500185
Rob Landleyfdc10c92012-10-16 17:09:30 -0500186<p>Android has a policy against GPL in userspace, so even though BusyBox
187predates Android by many years, they couldn't use it. Instead they grabbed
188an old version of ash and implemented their own command line utility set
189called "toolbox".</p>
Rob Landley8f90d3a2012-07-21 23:58:40 -0500190
Rob Landleyfdc10c92012-10-16 17:09:30 -0500191<p>Toolbox doesn't have its own repository, instead it's part of Android's
192<a href=https://android.googlesource.com/platform/system/core>system/core
193git repository</a> (this analysis looked at commit 51ccef27cab58).</p>
Rob Landley8f90d3a2012-07-21 23:58:40 -0500194
Rob Landleyfdc10c92012-10-16 17:09:30 -0500195<h3>Toolbox commands:</h3>
196
197<p>According to core/toolbox/Android.mk the toolbox directory builds the
198following commands:</p>
Rob Landley8f90d3a2012-07-21 23:58:40 -0500199
200<blockquote><b>
Rob Landleyfdc10c92012-10-16 17:09:30 -0500201ls mount cat ps kill ln insmod rmmod lsmod ifconfig setconsole
202rm mkdir rmdir reboot getevent sendevent date wipe sync umount
203start stop notify cmp dmesg route hd dd df getprop setprop watchprops
204log sleep renice printenv smd chmod chown newfs_msdos netstat ioctl
205mv schedtop top iftop id uptime vmstat nandread ionice touch lsof md5 r
Rob Landley8f90d3a2012-07-21 23:58:40 -0500206</b></blockquote>
207
Rob Landleyfdc10c92012-10-16 17:09:30 -0500208<p>If selinux is enabled, you also get:</p>
209<blockquote><b>
210getenforce setenforce chcon restorecon runcon getsebool setsebool load_policy
211</b></blockquote>
Rob Landley8f90d3a2012-07-21 23:58:40 -0500212
Rob Landleyfdc10c92012-10-16 17:09:30 -0500213<p>The Android.mk file also refers to dynarray.c and toolbox.c as library
214code. This leaves the following apparently unused C files in toolbox/*.c, each
215of which has a command_main() function and seems to implement a standalone
216command:</p>
217
218<blockquote><b>
219alarm exists lsusb readtty rotatefb setkey syren
220</b></blockquote>
221
222<h3>Command shell (ash)</h3>
223
224<p>The core/sh subdirectory contains a fork of ash 1.17, and sucks in
225liblinenoise to provide command line history/editing.</p>
226
227<h3>Other Android core commands</h3>
228
229<p>Other than the toolbox and sh directories, the currently interesting
230subdirectories in the core repository are fs_mgr, gpttool, init,
231logcat, logwrapper, mkbootimg, netcfg, run-as, and sdcard.</p>
232
233<ul>
234<li><b>fs_mgr</b> - subset of mount</li>
235<li><b>gpttool</b> - subset of fdisk</li>
236<li><b>init</b> - Android's PID 1</li>
237<li><b>logcat</b> - read android log format</li>
238<li><b>logwrapper</b> - redirect stdio to android log</li>
239<li><b>mkbootimg</b> - create signed boot image</li>
240<li><b>netcfg</b> - network configuration (sucks in libnetutils)</li>
241<li><b>run-as</b> - subset of sudo</li>
242<li><b>sdcard</b> - FUSE wrapper to squash UID/GID/permissions to what FAT supports.</li>
243</ul>
244
245<p>Almost all of these reinvent an existing wheel with less functionality and a
246different user interface. We may want to provide that interface, but
247implementing the full commands (mount, fdisk, init, ifconfig with dhcp,
248and sudo) come first.</p>
249
250<p>Although logcat/logwrapper also reinvent a wheel, Android did so in the
251kernel and these provide an interface to that.</p>
252
253<p>Also, gpttool and mkbootimg are install tools, and sdcard looks like a
254testing tool. These aren't a priority if android wants to use its own
255bespoke code to install itself.</p>
256
257<h3>Analysis</h3>
258
259<p>For reference, combining everything listed above, we get:</p>
260
261<blockquote><b>
262alarm ash cat chcon chmod chown cmp date dd df dmesg exists fs_mgr getenforce
263getevent getprop getsebool gpttool hd id ifconfig iftop init insmod ioctl
264ionice kill ln load_policy log logcat logwrapper ls lsmod lsof lsusb md5
265mkbootimg mkdir mount mv nandread netcfg netstat newfs_msdos notify printenv
266ps r readtty reboot renice restorecon rm rmdir rmmod rotatefb route run-as
267runcon schedtop sdcard sendevent setconsole setenforce setkey setprop setsebool
268sleep smd start stop sync syren top touch umount uptime vmstat watchprops wipe
269</b></blockquote>
270
271<p>We may eventually implement all of that, but for toybox 1.0 we need to
272focus a bit. For our first pass, let's ignore selinux, strip out the "unlisted"
273commands except lsusb, and grab just logcat and logwrapper from the "core"
274commands (since the rest have some full/standard version providing that
275functionality, which we can implement a shim interface for later).</p>
276
277<p>This means toybox should implement:</p>
Rob Landley8f90d3a2012-07-21 23:58:40 -0500278<blockquote><b>
279<span id=toolbox>
Rob Landleyfdc10c92012-10-16 17:09:30 -0500280cat chmod chown cmp date dd df dmesg getevent getprop hd id ifconfig iftop
281insmod ioctl ionice kill ln log logcat logwrapper ls lsmod lsof lsusb md5 mkdir
282mount mv nandread
283netstat newfs_msdos notify printenv ps r reboot renice rm rmdir rmmod route
284schedtop sendevent setconsole setprop sleep smd start stop sync top touch
285umount uptime vmstat watchprops wipe
Rob Landley8f90d3a2012-07-21 23:58:40 -0500286</span>
Rob Landleyc26ca6e2013-01-31 04:05:56 -0600287</b></blockquote>
Rob Landleyfdc10c92012-10-16 17:09:30 -0500288
289<p>The following Toolbox commands are already covered in previous
290sections of this analysis:</p>
291
292<blockquote><b>
293cat chmod chown cmp date dd df dmesg id ifconfig insmod kill ln ls lsmod
294mkdir mount mv ps renice rm rmdir rmmod route sleep sync top touch umount
295</b></blockquote>
296
297<p>Which leaves the following commands as new from Toolbox:</p>
298
299<blockquote><b>
300getevent getprop hd iftop ioctl ionice log lsof nandread netstat
301newfs_msdos notify printenv r reboot schedtop sendevent setconsole
302setprop smd start stop top uptime vmstat watchprops wipe
Rob Landley8f90d3a2012-07-21 23:58:40 -0500303</b></blockquote>
304
305<hr />
306<h2>Requests:</h2>
307
308<p>The following additional commands have been requested by various users:</p>
309<blockquote><b>
310<span id=request>
311freeramdisk getty halt hexdump hwclock klogd modprobe ping ping6 pivot_root
Rob Landley7a78d922012-12-23 00:37:42 -0600312poweroff rev sfdisk sudo syslogd taskset telnet telnetd tracepath traceroute
313unzip usleep vconfig zip free login modinfo unshare netcat help w
Rob Landley8f90d3a2012-07-21 23:58:40 -0500314</span>
315</b></blockquote>
316
317<!-- #include "footer.html" -->
318