shithub: riscv

Download patch

ref: eed487167489ee16dd16effe9ebff9a5086ffc70
parent: 2c0490a26ed0565d5e69c88e64c8b185ecab0947
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Mar 11 03:03:15 EDT 2014

exportfs: avoid closing netfd in filter()

netfd is initially zero (stdin), when filter() closes fd0,
fd0 is free to be reused. this causes problems with openmount()
that assumes sfd being >2.

instead, we dup the our pipe end over netfd, and close the pipe.

--- a/sys/src/cmd/exportfs/exportfs.c
+++ b/sys/src/cmd/exportfs/exportfs.c
@@ -927,10 +927,11 @@
 		exec(file, argv);
 		fatal("filter: exec; %r");
 	default:
-		close(fd);
+		dup(p[1], fd);
 		close(p[0]);
+		close(p[1]);
 	}
-	return p[1];	
+	return fd;
 }
 
 static void