shithub: riscv

Download patch

ref: 8fce6cb18bc8926d8845d528773b74cefb4e2202
parent: bb625cebfce32d82e83107c6ac7468021746c4af
author: cinap_lenrek <[email protected]>
date: Fri Aug 4 10:12:02 EDT 2017

cwfs: -n always overrides postservice() name, no matter if config mode changes service

--- a/sys/src/cmd/cwfs/main.c
+++ b/sys/src/cmd/cwfs/main.c
@@ -132,12 +132,12 @@
 }
 
 static void
-postservice(void)
+postservice(char *name)
 {
 	char buf[3*NAMELEN];
 	int p[2];
 
-	if(service[0] == 0)
+	if(name == nil || *name == 0)
 		panic("no service name");
 
 	/* serve 9p for -s */
@@ -149,7 +149,7 @@
 	/* post 9p service */
 	if(pipe(p) < 0)
 		panic("can't make a pipe");
-	snprint(buf, sizeof(buf), "#s/%s", service);
+	snprint(buf, sizeof(buf), "#s/%s", name);
 	srvfd(buf, 0666, p[0]);
 	close(p[0]);
 	srvchan(p[1], buf);
@@ -157,7 +157,7 @@
 	/* post cmd service */
 	if(pipe(p) < 0)
 		panic("can't make a pipe");
-	snprint(buf, sizeof(buf), "#s/%s.cmd", service);
+	snprint(buf, sizeof(buf), "#s/%s.cmd", name);
 	srvfd(buf, 0660, p[0]);
 	close(p[0]);
 
@@ -250,7 +250,7 @@
 main(int argc, char **argv)
 {
 	int i, nets = 0;
-	char *ann;
+	char *ann, *sname = nil;
 	
 	rfork(RFNOTEG);
 	formatinit();
@@ -269,7 +269,7 @@
 		annstrs[nets++] = ann;
 		break;
 	case 'n':
-		strcpy(service, EARGF(usage()));
+		sname = EARGF(usage());
 		break;
 	case 's':
 		dup(0, -1);
@@ -343,7 +343,7 @@
 	/*
 	 * post filedescriptors to /srv
 	 */
-	postservice();
+	postservice(sname != nil ? sname : service);
 
 	/*
 	 * processes to read the console