How toolbox symlinks work On my Android emulator, the /system/bin folder contains several symlinks that point to the toolbox binary:

# ls -l /system/bin
ls -l /system/bin
[SNIP]
lrwxr-xr-x root     shell             2012-08-23 07:01 ls -&gt; toolbox
lrwxr-xr-x root     shell             2012-08-23 07:01 lsmod -&gt; toolbox
lrwxr-xr-x root     shell             2012-08-23 07:01 lsof -&gt; toolbox
[SNIP]
-rwxr-xr-x root     shell      181002 2012-08-23 07:01 toolbox
[SNIP]
#


My understanding is that 'toolbox' is a binary that is able to do everything that ls, lsmod, lsof etc... can do, and that calling 'ls -l' ends up calling 'toolbox ls -l'.

But what I don't understand is how this works: if 'ls' is indeed a symlink to 'toolbox', then 'ls -l' would become 'toolbox -l', which of course doesn't work.

What am I missing ? (or said differently: what makes 'ls -l' become 'toolbox ls -l' ?)
What you're missing is: The application (in your case toolbox) can evaluate how it was called. To make an easy Linux-example: Say you have a script called myscript, and call it with the parameters para1 para2 (i.e. myscript para1 para2), and the script has a line:

echo $0 $1 $1


It would output exactly what you called it: myscript para1 para2. Now make a symlink: ln -s myscript mylink, call mylink para1 para2, and guess what it will "echo": the command line you called. So parsing the command line, based on the symlink your toolbox was called by, it can determine which functionality you were pointing at.