blob: 25847e9c92a20c6b180bdfe5a72df28512581943 [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,
12various vendor configurations of busybox, a selected subset of the SUSv4
13standard, 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
23<h3>POSIX-2008/SUSv4</h3>
24<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
34<p>The <a href="http://opengroup.org/onlinepubs/9699919799/idx/utilities.html">"utilities"
35section</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
90<h3>Linux Standard Base</h3>
91
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
103RPM on the standard even though all sorts of distros (from Debian to Slackware)
104don't use it and probably never will. This means anything in the LSB is
105at 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">
149<h2>Use case: provide a self-hosting development environment</h2>
150
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 />
184<a name=toolbox>
185<h2>Use case: Replacing Android Toolbox</h2>
186
Rob Landleyfdc10c92012-10-16 17:09:30 -0500187<p>Android has a policy against GPL in userspace, so even though BusyBox
188predates Android by many years, they couldn't use it. Instead they grabbed
189an old version of ash and implemented their own command line utility set
190called "toolbox".</p>
Rob Landley8f90d3a2012-07-21 23:58:40 -0500191
Rob Landleyfdc10c92012-10-16 17:09:30 -0500192<p>Toolbox doesn't have its own repository, instead it's part of Android's
193<a href=https://android.googlesource.com/platform/system/core>system/core
194git repository</a> (this analysis looked at commit 51ccef27cab58).</p>
Rob Landley8f90d3a2012-07-21 23:58:40 -0500195
Rob Landleyfdc10c92012-10-16 17:09:30 -0500196<h3>Toolbox commands:</h3>
197
198<p>According to core/toolbox/Android.mk the toolbox directory builds the
199following commands:</p>
Rob Landley8f90d3a2012-07-21 23:58:40 -0500200
201<blockquote><b>
Rob Landleyfdc10c92012-10-16 17:09:30 -0500202ls mount cat ps kill ln insmod rmmod lsmod ifconfig setconsole
203rm mkdir rmdir reboot getevent sendevent date wipe sync umount
204start stop notify cmp dmesg route hd dd df getprop setprop watchprops
205log sleep renice printenv smd chmod chown newfs_msdos netstat ioctl
206mv schedtop top iftop id uptime vmstat nandread ionice touch lsof md5 r
Rob Landley8f90d3a2012-07-21 23:58:40 -0500207</b></blockquote>
208
Rob Landleyfdc10c92012-10-16 17:09:30 -0500209<p>If selinux is enabled, you also get:</p>
210<blockquote><b>
211getenforce setenforce chcon restorecon runcon getsebool setsebool load_policy
212</b></blockquote>
Rob Landley8f90d3a2012-07-21 23:58:40 -0500213
Rob Landleyfdc10c92012-10-16 17:09:30 -0500214<p>The Android.mk file also refers to dynarray.c and toolbox.c as library
215code. This leaves the following apparently unused C files in toolbox/*.c, each
216of which has a command_main() function and seems to implement a standalone
217command:</p>
218
219<blockquote><b>
220alarm exists lsusb readtty rotatefb setkey syren
221</b></blockquote>
222
223<h3>Command shell (ash)</h3>
224
225<p>The core/sh subdirectory contains a fork of ash 1.17, and sucks in
226liblinenoise to provide command line history/editing.</p>
227
228<h3>Other Android core commands</h3>
229
230<p>Other than the toolbox and sh directories, the currently interesting
231subdirectories in the core repository are fs_mgr, gpttool, init,
232logcat, logwrapper, mkbootimg, netcfg, run-as, and sdcard.</p>
233
234<ul>
235<li><b>fs_mgr</b> - subset of mount</li>
236<li><b>gpttool</b> - subset of fdisk</li>
237<li><b>init</b> - Android's PID 1</li>
238<li><b>logcat</b> - read android log format</li>
239<li><b>logwrapper</b> - redirect stdio to android log</li>
240<li><b>mkbootimg</b> - create signed boot image</li>
241<li><b>netcfg</b> - network configuration (sucks in libnetutils)</li>
242<li><b>run-as</b> - subset of sudo</li>
243<li><b>sdcard</b> - FUSE wrapper to squash UID/GID/permissions to what FAT supports.</li>
244</ul>
245
246<p>Almost all of these reinvent an existing wheel with less functionality and a
247different user interface. We may want to provide that interface, but
248implementing the full commands (mount, fdisk, init, ifconfig with dhcp,
249and sudo) come first.</p>
250
251<p>Although logcat/logwrapper also reinvent a wheel, Android did so in the
252kernel and these provide an interface to that.</p>
253
254<p>Also, gpttool and mkbootimg are install tools, and sdcard looks like a
255testing tool. These aren't a priority if android wants to use its own
256bespoke code to install itself.</p>
257
258<h3>Analysis</h3>
259
260<p>For reference, combining everything listed above, we get:</p>
261
262<blockquote><b>
263alarm ash cat chcon chmod chown cmp date dd df dmesg exists fs_mgr getenforce
264getevent getprop getsebool gpttool hd id ifconfig iftop init insmod ioctl
265ionice kill ln load_policy log logcat logwrapper ls lsmod lsof lsusb md5
266mkbootimg mkdir mount mv nandread netcfg netstat newfs_msdos notify printenv
267ps r readtty reboot renice restorecon rm rmdir rmmod rotatefb route run-as
268runcon schedtop sdcard sendevent setconsole setenforce setkey setprop setsebool
269sleep smd start stop sync syren top touch umount uptime vmstat watchprops wipe
270</b></blockquote>
271
272<p>We may eventually implement all of that, but for toybox 1.0 we need to
273focus a bit. For our first pass, let's ignore selinux, strip out the "unlisted"
274commands except lsusb, and grab just logcat and logwrapper from the "core"
275commands (since the rest have some full/standard version providing that
276functionality, which we can implement a shim interface for later).</p>
277
278<p>This means toybox should implement:</p>
Rob Landley8f90d3a2012-07-21 23:58:40 -0500279<blockquote><b>
280<span id=toolbox>
Rob Landleyfdc10c92012-10-16 17:09:30 -0500281cat chmod chown cmp date dd df dmesg getevent getprop hd id ifconfig iftop
282insmod ioctl ionice kill ln log logcat logwrapper ls lsmod lsof lsusb md5 mkdir
283mount mv nandread
284netstat newfs_msdos notify printenv ps r reboot renice rm rmdir rmmod route
285schedtop sendevent setconsole setprop sleep smd start stop sync top touch
286umount uptime vmstat watchprops wipe
Rob Landley8f90d3a2012-07-21 23:58:40 -0500287</span>
Rob Landleyfdc10c92012-10-16 17:09:30 -0500288<b></blockquote>
289
290<p>The following Toolbox commands are already covered in previous
291sections of this analysis:</p>
292
293<blockquote><b>
294cat chmod chown cmp date dd df dmesg id ifconfig insmod kill ln ls lsmod
295mkdir mount mv ps renice rm rmdir rmmod route sleep sync top touch umount
296</b></blockquote>
297
298<p>Which leaves the following commands as new from Toolbox:</p>
299
300<blockquote><b>
301getevent getprop hd iftop ioctl ionice log lsof nandread netstat
302newfs_msdos notify printenv r reboot schedtop sendevent setconsole
303setprop smd start stop top uptime vmstat watchprops wipe
Rob Landley8f90d3a2012-07-21 23:58:40 -0500304</b></blockquote>
305
306<hr />
307<h2>Requests:</h2>
308
309<p>The following additional commands have been requested by various users:</p>
310<blockquote><b>
311<span id=request>
312freeramdisk getty halt hexdump hwclock klogd modprobe ping ping6 pivot_root
313poweroff sfdisk sudo syslogd taskset telnet telnetd tracepath traceroute unzip
314usleep vconfig zip free login modinfo unshare netcat help
315</span>
316</b></blockquote>
317
318<!-- #include "footer.html" -->
319