git: 9front

Download patch

ref: 77c85a32ae9f12e25e1d845f2443e02bc4403b11
parent: 869a1853874347189af0f5dadba20fde02f35592
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Jun 4 13:45:08 EDT 2014

webfs: explicitely unmount old /mnt/web (thanks BurnZeZ)

webfs forks the namespace to isolate itself from its mount
point which has the side effect that it captures the mount
of previous instances of webfs mounted on /mnt/web.

explicitely unmount the mountpoint in our namespace copy
to drop the reference.

--- a/sys/src/cmd/webfs/fs.c
+++ b/sys/src/cmd/webfs/fs.c
@@ -76,6 +76,8 @@
 			nil,
 };
 
+static char *mtpt;
+static char *service;
 static long time0;
 static char *user;
 static char *agent;
@@ -741,8 +743,17 @@
 	}
 }
 
+static void
+fsstart(Srv*)
+{
+	/* drop reference to old webfs mount */
+	if(mtpt != nil)
+		unmount(nil, mtpt);
+}
+
 Srv fs = 
 {
+	.start=fsstart,
 	.attach=fsattach,
 	.stat=fsstat,
 	.walk1=fswalk1,
@@ -757,7 +768,7 @@
 void
 usage(void)
 {
-	fprint(2, "usage: %s [-D] [-A useragent] [-T timeout] [-m mtpt] [-s srv]\n", argv0);
+	fprint(2, "usage: %s [-D] [-A useragent] [-T timeout] [-m mtpt] [-s service]\n", argv0);
 	exits("usage");
 }
 
@@ -764,7 +775,7 @@
 void
 main(int argc, char *argv[])
 {
-	char *srv, *mtpt, *s;
+	char *s;
 
 	quotefmtinstall();
 	fmtinstall('U', Ufmt);
@@ -771,12 +782,10 @@
 	fmtinstall('H', Hfmt);
 	fmtinstall('E', Efmt);
 
-	srv = nil;
 	mtpt = "/mnt/web";
 	user = getuser();
 	time0 = time(0);
 	timeout = 10000;
-	agent = nil;
 
 	ARGBEGIN {
 	case 'D':
@@ -794,7 +803,7 @@
 		mtpt = EARGF(usage());
 		break;
 	case 's':
-		srv = EARGF(usage());
+		service = EARGF(usage());
 		break;
 	case 'd':
 		debug++;
@@ -814,6 +823,6 @@
 		free(s);
 	}
 
-	postmountsrv(&fs, srv, mtpt, MREPL);
+	postmountsrv(&fs, service, mtpt, MREPL);
 	exits(0);
 }
--