[BusyBox] [patch] Make standalone shell more reliable.

Rob Landley rob at landley.net
Sun Apr 10 04:38:21 UTC 2005


On Thursday 07 April 2005 09:10 am, Mike Frysinger wrote:
> On Thursday 07 April 2005 02:58 am, Rob Landley wrote:
> > If we exec /proc/self/exe and only fall back to /bin/busybox if /proc
> > isn't there, then we have a reasonable chance of having the standalone
> > shell work even if busybox isn't installed in /bin on the system in
> > question.
>
> man i *really* miss this functionality :)
> -mike

Me too.

Another advantage of this patch is according to "nm --size-sort 
busybox" (built with debug info), is it shrinks tryexec from 11c bytes to a6 
bytes.  (And it still execs /bin/busybox as a fallback if /proc/self/exe 
isn't available.)

Most of the shrinkage was cutting out strange special case handling for 
running the built in applets via the name "busybox".  It's unnecessary since 
"busybox" is already in the applet name list it goes into the normal exec 
path to handle that name anyway.

What the code I removed actually did is allocate extra memory for the 
parameter list, which can't POSSIBLY matter in the normal case (we're washing 
it through "exec", the memory has to be copied from one process context to 
another) and is probably some weird special case thing for uClinux.

Except that the special case argument handling at the end of applets/busybox.c 
makes the argument list _smaller_.  (A fairly gross hack to make a purely 
cosmetic change to the ps list so the command line look different than what 
was actually run.  But Erik likes it, so it stays...)  So allocating _extra_ 
memory doesn't make a lot of sense...

If anybody considers this a loss of functionality, I'd like to know what it 
actually did.  What system were they running it on where not only exec cares 
about the memory state of the parent's argument list but wants to use more 
memory than the length of the list?  If it needs this extra memory on an 
exec, when is this safe for anybody _else_ to exec it?  Such the exact same 
shell in _non_standalone mode?

Rob



More information about the busybox mailing list