hlfw.ca

task

Download patch

ref: ed65b824f57d31d65ef332dce29b1255759d7542
parent: 3030d9721443e68a7bc126deea0d542455fd473b
author: Michael Misch <michaelmisch1985@gmail.com>
date: Sat Aug 24 14:38:26 PDT 2024

"Update

--- a/proj.c
+++ b/proj.c
@@ -1,10 +1,12 @@
 #include <u.h>
 #include <libc.h>
 #include <auth.h>
+#include <plumb.h>
+
 static void
 usage(void)
 {
-	fprint(2, "usage: %s [-i] [-n nsdir] [-w wdir] [-s srvfile] project\n", argv0);
+	fprint(2, "usage: %s [-p] [-i] [-n nsdir] [-w wdir] [-s srvfile] project\n", argv0);
 	exits("usage");
 }
 
@@ -11,10 +13,11 @@
 void
 main(int argc, char **argv)
 {
+	Plumbmsg *pm;
 	char *ename, *arglist[16], **argp;
-	char *user, *home, *wdir, *sfile;
-	int n, fd, stdin, pipefd[2];
-	char buf[64], nsdir[64];
+	char *user, *home, *wdir, *sfile, *plumb, *path;
+	int n, nb, fd, stdin, pfd, pipefd[2];
+	char buf[64], nsdir[64], pbuf[512];
 
 	argp = arglist;
 	home = nil;
@@ -22,11 +25,15 @@
 	wdir = "/mnt/work";
 	sfile = "/srv/work";
 	stdin = 0;
+	plumb = nil;
 	
 	*argp++ = "exportfs";
 	ARGBEGIN{
 	default:
 		usage();
+	case 'p':
+		plumb = EARGF(usage());
+		break;
 	case 'i':
 		stdin = 1;
 		break;
@@ -56,10 +63,15 @@
 
 	if(stdin){
 		n = snprint(buf, sizeof buf, "%s/namespace.", nsdir);
-		n += read(0, buf+n, sizeof buf - n);
-		buf[n-1] = 0;
-	} else
+		nb = read(0, buf+n, sizeof buf - n);
+		buf[n + nb - 1] = 0;
+		path = buf+n;
+print(path);
+
+	} else {
+		path = argv[0];
 		snprint(buf, sizeof buf, "%s/namespace.%s", nsdir, argv[0]);
+	}
 	if(addns(user, buf) < 0){
 		fprint(2, "can't addns: %r\n");
 		exits("addns");
@@ -76,6 +88,16 @@
 		fprint(2, "can't create /srv/work: %r\n");
 		exits("create");
 	}
+	if(plumb){
+		// Messy, blegh.
+		snprint(pbuf, sizeof(pbuf), "plumb\n%s\n%s\ntext\ntitle=Project message=%s\n3\nnan", plumb, getenv("home"), path);
+		pm = plumbunpack(pbuf, strlen(pbuf));
+		pfd = plumbopen("send", OWRITE);
+		plumbsend(pfd, pm);
+		close(pfd);
+		//plumbfree(pm);
+	}
+
 	fprint(fd, "%d", pipefd[1]);
 	close(pipefd[1]);