shithub: unionfs

Download patch

ref: 109f580362778585ba53e83133498c7d932c8254
parent: 9c0588335692286e31e946a3665ec7574afe0f44
author: kvik <kvik@a-b.xyz>
date: Mon Feb 17 06:20:12 EST 2020

Talk 9p on stdio with the -i flag

Useful in combination with a network listener, like:

	aux/listen1 -t tcp!*!9 /bin/unionfs -i /union/of /this/and /that

--- a/unionfs.c
+++ b/unionfs.c
@@ -734,9 +734,8 @@
 void
 main(int argc, char *argv[])
 {
-	int c, i;
-	int mflag;
-	char *mtpt, *srv;
+	int c, i, mflag, stdio;
+	char *mtpt, *srvname;
 	Dir *d;
 	Union *u;
 
@@ -743,7 +742,8 @@
 	c = 0;
 	mflag = MREPL|MCREATE;
 	mtpt = "/mnt/union";
-	srv = nil;
+	srvname = nil;
+	stdio = 0;
 	ARGBEGIN{
 	case 'a':
 		mflag |= MAFTER;
@@ -767,8 +767,11 @@
 		mtpt = nil;
 		break;
 	case 's':
-		srv = EARGF(usage());
+		srvname = EARGF(usage());
 		break;
+	case 'i':
+		stdio = 1;
+		break;
 	default:
 		usage();
 	}ARGEND;
@@ -799,7 +802,14 @@
 		unionlist->next->create = 1;
 	
 	initroot();
-	postmountsrv(&fs, srv, mtpt, mflag);
-	
+
+	if(stdio == 0){
+		postmountsrv(&fs, srvname, mtpt, mflag);
+		exits(nil);
+	}
+	fs.nopipe = 1;
+	fs.infd = 0;
+	fs.outfd = 1;
+	srv(&fs);
 	exits(nil);
 }