Allow NFS and NBD to be built into the kernel
authorDavid Dillow <dave@thedillows.org>
Mon, 1 Jun 2009 23:59:22 +0000 (19:59 -0400)
committerDavid Dillow <dave@thedillows.org>
Mon, 1 Jun 2009 23:59:22 +0000 (19:59 -0400)
Probe for NFS and NBD capability before trying to load their modules
in case they are built into the kernel. Ugly use of flag files, but
avoids the need for grep to be on the image.

modules.d/95nbd/nbdroot
modules.d/95nfs/nfsroot

index 51120c2..1130cca 100755 (executable)
@@ -71,7 +71,17 @@ getarg ro && nbdrw=ro
 getarg rw && nbdrw=rw
 fsopts=${fsopts+$fsopts,}${nbdrw}
 
-modprobe nbd || exit 1
+if [ ! -e /tmp/nbd.present ]; then
+    cat /proc/devices | while read t1 devt; do
+       if [ "$devt" = "nbd" ]; then
+           >/tmp/nfs.present
+           break
+       fi
+    done
+fi
+if [ ! -e /tmp/nbd.present ]; then
+    modprobe nbd || exit 1
+fi
 
 # XXX better way to wait for the device to be made?
 i=0
index 18e1300..2d08b68 100755 (executable)
@@ -46,7 +46,16 @@ getarg rw && nfsrw=rw
 nfsflags=${nfsflags+$nfsflags,}${nfsrw}
 
 # Load the modules so the filesystem type is there
-modprobe nfs || exit 1
+if [ ! -e /tmp/nfs.present ]; then
+    cat /proc/filesystems | while read t1 fst; do
+        case "$fst" in
+           nfs|nfs4) >/tmp/nfs.present; break ;;
+       esac
+    done
+fi
+if [ ! -e /tmp/nfs.present ]; then
+    modprobe nfs || exit 1
+fi
 
 # XXX don't forget to move /var/lib/nfs/rpc_pipefs to new /