configurable-bind-mounts.patch
Date: Thu Jan  6 09:57:41 WST 2005
Author: Jeremy Kerr
Title: Add a parameter (K42_NFS_BINDINGS) to specify bindmounts.
Status: Experimental
diff -u -r1.70 fileSystemServices.C
--- os/servers/baseServers/fileSystemServices.C	23 Nov 2004 22:41:52 -0000	1.70
+++ os/servers/baseServers/fileSystemServices.C	6 Jan 2005 01:52:49 -0000
@@ -458,6 +458,44 @@
 }
 #endif // #ifdef EXT2_ENABLED
 
+static void doNFSBindings(struct nfsMountData* nfs)
+{
+    char bindparam[256];
+    SysStatus rc;
+    rc = StubKBootParms::_GetParameterValue("K42_NFS_BINDINGS", bindparam, 256);
+
+    /* FIXME: for now binding with isCoverable == 1 */
+
+    if (_FAILURE(rc) || bindparam[0] == 0) {
+	/* Do the bindings specified in the nfsMountData structure */
+	for (uval i = 0; nfs->bindings[i].from ; ++i) {
+	    MountPointMgrImp::Bind(nfs->bindings[i].from,
+		    nfs->bindings[i].to, 1);
+	}
+
+    } else {
+	/* Use NFS_BINDINGS parameter instead */
+	char *from, *to, *next;
+
+	for (from = bindparam; from && *from; from = next) {
+	    if (!(to = strchr(from, '='))) {
+		tassertWrn(0, "K42_NFS_BINDINGS parameter invalid: '%s'", from);
+		return;
+	    }
+	    *(to++) = '\0'; 
+	    if (strncmp(from, nfs->mntPoint, strlen(nfs->mntPoint))) {
+		continue;
+	    }
+
+	    if ((next = strchr(to, ','))) {
+		*(next++) = '\0';
+	    }
+	    MountPointMgrImp::Bind(from, to, 1);
+	}
+    }
+
+}
+
 void StartNFSServices()
 {
     SysStatus rc;
@@ -512,14 +550,8 @@
 	if (_SUCCESS(rc) && nfs->flags & ROOT_ONLY) {
 	    have_root = 1;
 	}
-	if (nfs->flags & DO_BINDINGS_ROOT_ONLY && root != NFS) {
-	    // skip bindings
-	    continue;
-	}
-	// FIXME: for now bindinbg with isCoverable == 1
-	for (uval i = 0; nfs->bindings[i].from ; ++i) {
-	    MountPointMgrImp::Bind(nfs->bindings[i].from,
-				   nfs->bindings[i].to, 1);
+	if (!(nfs->flags & DO_BINDINGS_ROOT_ONLY && root != NFS)) {
+	    doNFSBindings(nfs);
 	}
     }
 }
