[arch-general] [PATCH] rc.sysinit: only call modprobe once

Dave Reisner d at falconindy.com
Sun Sep 19 22:10:17 EDT 2010


On Mon, Sep 20, 2010 at 11:57:06AM +1000, Allan McRae wrote:
> On 20/09/10 11:54, Dave Reisner wrote:
> >Use modprobe -a and a bash PE to filter the MODULES array.
> >
> >Signed-off-by: Dave Reisner<d at falconindy.com>
> >---
> >  rc.sysinit |   12 ++++--------
> >  1 files changed, 4 insertions(+), 8 deletions(-)
> >
> >diff --git a/rc.sysinit b/rc.sysinit
> >index 09d5e97..4b6e1e7 100755
> >--- a/rc.sysinit
> >+++ b/rc.sysinit
> >@@ -92,14 +92,10 @@ if /bin/pidof -o %PPID /sbin/udevd>/dev/null; then
> >  fi
> >
> >  # Load modules from the MODULES array defined in rc.conf
> >-if [[ $load_modules != off&&  -f /proc/modules ]]; then
> >-    stat_busy "Loading Modules"
> >-    for mod in "${MODULES[@]}"; do
> >-	if [[ $mod = ${mod#!} ]]; then
> >-	    /sbin/modprobe $mod
> >-	fi
> >-    done
> >-    stat_done
> >+if [[ $load_modules != off&&  -f /proc/modules ]]&&  (( ${#MODULES[@]}>  0 )); then
> >+	stat_busy "Loading Modules"
> >+		/sbin/modprobe -a "${MODULES[@]/#\!*/}"
> >+	stat_done
> >  fi
> >
> >  # Wait for udev uevents
> 
> Does this still work in the "null" case where there is only modules
> specified with "!" in the front?
> 
> Allan
> 

Excellent observation -- it would not. Counting the size of the array
with the PE in place isn't possible (or desirable), either. Perhaps a
more graceful solution is to reassign the output of the PE to a new
array and operate based on that. Certainly still beats calling modprobe
for every element in the array, imo.

d


More information about the arch-general mailing list