diff --git a/sys/man/4/plumber b/sys/man/4/plumber index fbaebe419..f02a6acd4 100644 --- a/sys/man/4/plumber +++ b/sys/man/4/plumber @@ -6,6 +6,9 @@ plumber \- file system for interprocess messaging [ .B -p .I plumbing +] [ +.B -s +.I srvname ] .SH DESCRIPTION The @@ -31,11 +34,17 @@ and and a set of output .I ports for dispatching messages to applications. +.PP The service is also published as a .IR srv (4) -file, named in -.BR $plumbsrv , +file, +.IR srvname , for mounting elsewhere. +By default, its name is a dot-separated concatenation +of the program's name and a process id. +A different one can be specified via the +.B -s +option. .PP Programs use .B write diff --git a/sys/src/cmd/plumb/fsys.c b/sys/src/cmd/plumb/fsys.c index 378543139..db3ff6b54 100644 --- a/sys/src/cmd/plumb/fsys.c +++ b/sys/src/cmd/plumb/fsys.c @@ -218,9 +218,10 @@ startfsys(void) clock = getclock(); if(cexecpipe(&mntfd, &srvfd) < 0) error("can't create pipe: %r"); - sprint(srvfile, "/srv/plumb.%s.%d", user, getpid()); - if(putenv("plumbsrv", srvfile) < 0) - error("can't write $plumbsrv: %r"); + if(srvname == nil) + snprint(srvfile, sizeof(srvfile), "/srv/plumb.%s.%d", user, getpid()); + else + snprint(srvfile, sizeof(srvfile), "/srv/%s", srvname); fd = create(srvfile, OWRITE|OCEXEC|ORCLOSE, 0600); if(fd < 0) error("can't create /srv file: %r"); diff --git a/sys/src/cmd/plumb/plumber.c b/sys/src/cmd/plumb/plumber.c index 21cb27cd6..e5f3ddbc0 100644 --- a/sys/src/cmd/plumb/plumber.c +++ b/sys/src/cmd/plumb/plumber.c @@ -15,6 +15,7 @@ Ruleset **rules; int printerrors=1; jmp_buf parsejmp; char *lasterror; +char *srvname; void makeports(Ruleset *rules[]) @@ -37,6 +38,13 @@ mainproc(void *v) sendp(c, nil); } +void +usage(void) +{ + fprint(2, "usage: %s [-p plumbfile] [-s srvname]\n", argv0); + exits("usage"); +} + void threadmain(int argc, char *argv[]) { @@ -48,7 +56,13 @@ threadmain(int argc, char *argv[]) ARGBEGIN{ case 'p': - plumbfile = ARGF(); + plumbfile = EARGF(usage()); + break; + case 's': + srvname = EARGF(usage()); + break; + default: + usage(); break; }ARGEND diff --git a/sys/src/cmd/plumb/plumber.h b/sys/src/cmd/plumb/plumber.h index 2d395ca3e..d257d245a 100644 --- a/sys/src/cmd/plumb/plumber.h +++ b/sys/src/cmd/plumb/plumber.h @@ -92,3 +92,4 @@ jmp_buf parsejmp; char *lasterror; char **ports; int nports; +char *srvname;