shithub: riscv

Download patch

ref: 1ebcdca4ba208953fc8035c001b980eb7b51228b
parent: cd15849bf2359dbd7868dcfd4f85c7da6d46f396
author: cinap_lenrek <[email protected]>
date: Wed Dec 21 20:56:19 EST 2016

libauth: don't attempt to mount when opening mount srv file fails in nsop()

making newnsdebug error messages more usefull...

--- a/sys/src/libauth/newns.c
+++ b/sys/src/libauth/newns.c
@@ -152,7 +152,7 @@
 	cdroot = 0;
 	flags = 0;
 	argv0 = 0;
-	if (newnsdebug){
+	if(newnsdebug){
 		for (i = 0; i < argc; i++)
 			fprint(2, "%s ", argv[i]);
 		fprint(2, "\n");
@@ -181,9 +181,9 @@
 			return 0;
 		cdroot |= nsfile(fn, b, rpc);
 		Bterm(b);
-	}else if(strcmp(argv0, "clear") == 0 && argc == 0)
+	}else if(strcmp(argv0, "clear") == 0 && argc == 0){
 		rfork(RFCNAMEG);
-	else if(strcmp(argv0, "bind") == 0 && argc == 2){
+	}else if(strcmp(argv0, "bind") == 0 && argc == 2){
 		if(bind(argv[0], argv[1], flags) < 0 && newnsdebug)
 			fprint(2, "%s: bind: %s %s: %r\n", fn, argv[0], argv[1]);
 	}else if(strcmp(argv0, "unmount") == 0){
@@ -193,6 +193,11 @@
 			unmount(argv[0], argv[1]);
 	}else if(strcmp(argv0, "mount") == 0){
 		fd = open(argv[0], ORDWR);
+		if(fd < 0){
+			if(newnsdebug)
+				fprint(2, "%s: mount: %s: %r\n", fn, argv[0]);
+			return 0;
+		}
 		if(argc == 2){
 			if(famount(fd, rpc, argv[1], flags, "") < 0 && newnsdebug)
 				fprint(2, "%s: mount: %s %s: %r\n", fn, argv[0], argv[1]);