--- /sbin/mkinitrd	2003-10-02 21:06:38.000000000 -0300
+++ mkinitrd	2003-11-06 20:24:37.000000000 -0200
@@ -35,10 +35,16 @@
 MODULES=""
 img_vers=""
 builtins=""
+rescan_scsi_for_sbp2=""
 pivot=1
 modulefile=/etc/modules.conf
 rc=0
 
+conf_files=/etc/sysconfig/mkinitrd
+if test ! -f $conf_files; then
+  conf_files=
+fi
+
 if [ `uname -m` = "i386" ]; then
   IMAGESIZE=4000
 else
@@ -84,6 +90,7 @@
     fi
 
     local modName=$1
+    local afterMods=
 
     if [ "$modName" = "off" -o "$modName" = "null" ]; then
 	return
@@ -111,7 +118,9 @@
 	modName="ppa"
     elif [ "$modName" = "sbp2" ]; then
 	findmodule ieee1394
-	findmodule ohci1394
+	# findmodule ohci1394
+	afterMods=ohci1394
+	rescan_scsi_for_sbp2=yes
 	modName="sbp2"
     else
 	moduledep $modName
@@ -156,6 +165,10 @@
     if ! echo $MODULES | grep -q "$fmPath" 2>/dev/null ; then
 	MODULES="$MODULES $fmPath"
     fi
+
+    for mod in $afterMods; do
+	findmodule $mod
+    done
 }
 
 inst() {
@@ -178,6 +191,26 @@
 	    fi		    
 	    ;;
 
+	--no-config-file)
+	    conf_files=
+	    ;;
+
+	--config-file*)
+	    if echo $1 | grep -q '=' ; then
+	    	conf_file=`echo $1 | sed 's/^--config-file=//'`
+	    else
+		conf_file=$2
+		shift
+	    fi		    
+
+	    if test -f $conf_file; then
+		conf_files="$conf_files $conf_file"
+	    else
+		echo $conf_file does not exist >&2
+		exit 1
+	    fi
+	    ;;
+
 	--with-usb)
 	    withusb=yes
 	    ;;
@@ -308,6 +341,10 @@
     echo "WARNING: using $TMPDIR for temporary files" >&2
 fi
 
+for file in $conf_files; do
+    . "$file"
+done
+
 for n in $PREMODS; do
 	findmodule $n
 done
@@ -560,18 +597,29 @@
         echo "Loading module $module$text"
     fi
     echo "echo \"Loading $fullmodule module\"" >> $RCFILE
-    echo "insmod /lib/$fullmodule $options" >> $RCFILE
 
-    # Hack - we need a delay after loading usb-storage to give things
-    #        time to settle down before we start looking a block devices
-    if [ "$module" = "usb-storage" ]; then
+    echo "insmod -k /lib/$fullmodule $options" >> $RCFILE
+
+    case $module in
+    usb-storage)
+	# Hack - we need a delay after loading usb-storage to give things
+	#	 time to settle down before we start looking a block devices
 	echo "sleep 5" >> $RCFILE
-    fi
+	;;
+    esac
 done
 
 echo "echo Mounting /proc filesystem" >> $RCFILE
 echo "mount -t proc /proc /proc" >> $RCFILE
 
+if test -n "$rescan_scsi_for_sbp2"; then
+    cp $verbose /sbin/rescan-scsi-bus $MNTIMAGE/bin/rescan-scsi-bus
+    # We have to rescan the scsi bus
+    echo "echo \"rescanning scsi bus...\"" >> $RCFILE
+    echo "rescan-scsi-bus" >> $RCFILE
+    echo "sleep 2" >> $RCFILE
+fi
+
 if [ -n "$startraid" ]; then
     for dev in $raiddevices; do
 	cp -a /dev/${dev} $MNTIMAGE/dev
