code: mafs

Download patch

ref: f79b530d2184b14082fa130261c8d070c168f06c
parent: eb95bc0eed8488b3c9b8ee210994e0895ce7a379
author: 9ferno <gophone2015@gmail.com>
date: Thu Nov 10 20:03:33 EST 2022

removed network listening as exportfs can be used to do so

--- a/9p.c
+++ b/9p.c
@@ -1101,14 +1101,10 @@
 08:50 < cinap_lenrek> works.
  */
 void
-start9p(char **nets, int stdio)
+start9p(int stdio)
 {
 	int sfd;
 
-	while(nets && *nets){
-		mpsrv.end = nil;	/* disable shutdown */
-		listensrv(&mpsrv, *nets++);
-	}
 	if(stdio){
 		usrv.infd = 0;
 		usrv.outfd = 1;
--- a/TODO
+++ b/TODO
@@ -2,14 +2,15 @@
 profiling
 mafswrite():
 	add user and remove user messages
+	users format has changed as per this http://9p.io/wiki/plan9/Setting_up_Fossil/index.html
 read only mode
 need rlock() when looking up user id, group id, or user attributes
 EXCL files - maintain a list of locks in the tree
-make docs/mafs.ms more interesting?
 Clean up the Iobuf locking description?
 
 not a priority, are they even needed?
 -------------------------------------
+make docs/mafs.ms more interesting?
 Open device file in EXCL mode?
 	not possible. It is set at create time.
 Add readahead?
--- a/all.h
+++ b/all.h
@@ -135,7 +135,7 @@
 void	rootream(void);
 Dentry	*searchdir(u64 dblkno, u64 qpath, u16 uid, char *searchname, u64 searchidx, Iobuf **dbuf, Iobuf **buf);
 void	shutdown(void);
-void	start9p(char **nets, int stdio);
+void	start9p(int stdio);
 void	superream(u64 size, u64 nblocks);
 Tlock*	tlocked(Iobuf*, Dentry*);
 
--- a/mafs.c
+++ b/mafs.c
@@ -27,13 +27,12 @@
 int	allownone;
 static void	usage(void);
 static void	printsizes(void);
-static u64	memsize(void);
 Config config = {0};
 
 static void
 usage(void)
 {
-	fprint(2, "usage: mafs [-Ds] [-r service] [-n service] [-m nmemunits] [-h nbuckets] [-w npendingwrites] [-a announce-string]... file\n");
+	fprint(2, "usage: mafs [-Ds] [-r service] [-n service] [-m nmemunits] [-h nbuckets] [-w npendingwrites] file\n");
 	exits("usage");
 }
 
@@ -40,8 +39,7 @@
 void
 main(int argc, char **argv)
 {
-	static char *nets[8];
-	int doream, stdio, netc;
+	int doream, stdio;
 	char buf[Namelen];
 	int pid, ctl;
 	u64 nmemunits, size;
@@ -59,7 +57,7 @@
 	npendingwrites = 0;
 	nmemunits = 0;
 	sfd = -1;
-	doream = stdio = netc = 0;
+	doream = stdio = 0;
 
 	pid = getpid();
 	snprint(buf, sizeof buf, "/proc/%d/ctl", pid);
@@ -81,13 +79,6 @@
 		snprint(service, Namelen, "%s", EARGF(usage()));
 		break;
 	case 's':	stdio++;    break;
-	case 'a':
-		if(netc >= nelem(nets)-1){
-			fprint(2, "%s: too many networks to announce\n", argv0);
-			exits("too many nets");
-		}
-		nets[netc++] = estrdup9p(EARGF(usage()));
-		break;
 	}ARGEND
 
 	if(argc != 1 || (doream && service[0] == '\0'))
@@ -143,39 +134,12 @@
 	if(service[0] == '\0')
 		snprint(service, Namelen, "%s", config.service);
 
-	start9p(nets, stdio);
+	start9p(stdio);
 	/*
 		we have started another proc to process /srv/service
 		and it is my time to exit
 	 */
 	exits(nil);
-}
-
-static u64
-memsize(void)
-{
-	char *p, buf[128];
-	int fd, n, by2pg, secs;
-
-	by2pg = 4*1024;
-	p = getenv("cputype");
-	if(p && strcmp(p, "68020") == 0)
-		by2pg = 8*1024;
-
-	secs = 4*1024*1024;
-	
-	fd = open("/dev/swap", OREAD);
-	if(fd < 0)
-		return secs;
-	n = read(fd, buf, sizeof(buf)-1);
-	close(fd);
-	if(n <= 0)
-		return secs;
-	buf[n] = 0;
-	p = strchr(buf, '/');
-	if(p)
-		secs = strtoul(p+1, 0, 0)*by2pg;
-	return secs;
 }
 
 /*
--- a/man/mafs.4
+++ b/man/mafs.4
@@ -21,9 +21,6 @@
 ] [
 .B -w
 .I npendingwrites
-] [
-.B -a
-.I announce-string
 ]
 .B file
 .PP
@@ -42,9 +39,6 @@
 ] [
 .B -h
 .I nbuckets
-] [
-.B -a
-.I announce-string
 ]
 .B file
 .SH DESCRIPTION
--- a/mfs.c
+++ b/mfs.c
@@ -26,13 +26,12 @@
 int	allownone;
 static void	usage(void);
 static void	printsizes(void);
-static u64	memsize(void);
 Config config = {0};
 
 static void
 usage(void)
 {
-	fprint(2, "usage: mfs [-Ds] [-r service] [-n service] [-m nmemunits] [-h nbuckets] [-a announce-string]... file\n");
+	fprint(2, "usage: mfs [-Ds] [-r service] [-n service] [-m nmemunits] [-h nbuckets] file\n");
 	exits("usage");
 }
 
@@ -39,8 +38,7 @@
 void
 main(int argc, char **argv)
 {
-	static char *nets[8];
-	int doream, stdio, netc;
+	int doream, stdio;
 	char buf[Namelen];
 	int pid, ctl;
 	u64 nmemunits, size;
@@ -57,7 +55,7 @@
 	nbuckets = 0;
 	nmemunits = 0;
 	sfd = -1;
-	doream = stdio = netc = 0;
+	doream = stdio = 0;
 
 	pid = getpid();
 	snprint(buf, sizeof buf, "/proc/%d/ctl", pid);
@@ -80,13 +78,6 @@
 		snprint(service, Namelen, "%s", EARGF(usage()));
 		break;
 	case 's':	stdio++;    break;
-	case 'a':
-		if(netc >= nelem(nets)-1){
-			fprint(2, "%s: too many networks to announce\n", argv0);
-			exits("too many nets");
-		}
-		nets[netc++] = estrdup9p(EARGF(usage()));
-		break;
 	}ARGEND
 
 	if(argc != 1 || (doream && service[0] == '\0'))
@@ -135,39 +126,12 @@
 	if(service[0] == '\0')
 		snprint(service, Namelen, "%s", config.service);
 
-	start9p(nets, stdio);
+	start9p(stdio);
 	/*
 		we have started another proc to process /srv/service
 		and it is my time to exit
 	 */
 	exits(nil);
-}
-
-static u64
-memsize(void)
-{
-	char *p, buf[128];
-	int fd, n, by2pg, secs;
-
-	by2pg = 4*1024;
-	p = getenv("cputype");
-	if(p && strcmp(p, "68020") == 0)
-		by2pg = 8*1024;
-
-	secs = 4*1024*1024;
-	
-	fd = open("/dev/swap", OREAD);
-	if(fd < 0)
-		return secs;
-	n = read(fd, buf, sizeof(buf)-1);
-	close(fd);
-	if(n <= 0)
-		return secs;
-	buf[n] = 0;
-	p = strchr(buf, '/');
-	if(p)
-		secs = strtoul(p+1, 0, 0)*by2pg;
-	return secs;
 }
 
 /*