replacing system(3) call with internal applet call
Isaac Dunham
ibid.ag at gmail.com
Sun Oct 12 00:29:40 UTC 2014
On Sat, Oct 11, 2014 at 03:58:46PM -0400, René Rhéaume wrote:
> Hello,
> I recently switched to mdev to try to improve the startup time of my
> computer. However, much of the execution is taken by modprobe. I then
> looked the mdev source file and saw the system() function call, which
> means spawning two processes: a shell and the wanted command. I have
> several questions:
>
> 1. Can I save a process spawn by prefixing /bin/busybox to commands in
> mdev.conf? Example @modprobe $MODALIAS becomes @/bin/busybox modprobe
> $MODALIAS
No.
system() is always called; the result of that will be calling:
/bin/sh -c busybox ...
However, if you have ash as /bin/sh, and you have
PREFER_APPLETS/STANDALONE_SHELL enabled, you can save the process spawn
that sh would have.
> 2. Same question for helper scripts by replacing #!/bin/sh with #!
> /bin/busybox ash
If you have PREFER_APPLETS/STANDALONE_SHELL enabled, yes.
> 3. What is the applet call macro or function name?
BB_EXECVP() stands in for execvp().
There is no exact replacement for system(), as far as I know;
but it should be possible to write one.
> 4. Would the applet call effectively save two processes as I think?
If you mean two pids, no.
But it will save time.
Busybox will exec itself as a second process; howevver, this will save
the file search/load time, and possibly some more time due to relocation.
> 5. Is it possible to invoke modprobe (either the busybox or the kmod
> one) in parallel with something like xargs?
If you disabled "small modutils", you can use
generate list of aliases | xargs modprobe -a
But mdev will never spawn anything with more than one modalias as an
argument, since spawning only happens when mdev is acting as a hotplugger.
At system startup, I'd use something like this to autoload modules:
grep -h MODALIAS /sys/bus/*/devices/*/uevent 2>/dev/null | \
cut -d= -f2 | xargs modprobe -abq
Hope this helps,
Isaac Dunham
More information about the busybox
mailing list