9pserve: add -c option

This commit is contained in:
Russ Cox 2008-06-11 06:40:54 -07:00
parent e082105c33
commit ef6606c7a7
2 changed files with 20 additions and 2 deletions

View file

@ -12,6 +12,10 @@
.I afid .I afid
] ]
[ [
.B -c
.I addr
]
[
.B -M .B -M
.I msize .I msize
] ]
@ -73,6 +77,11 @@ used to implement
.B -a .B -a
option option
.TP .TP
.B -c
multiplex clients onto a single connection to
.IR addr ,
instead of standard input and output
.TP
.B -M .B -M
do not initialize the connection with a do not initialize the connection with a
.B Tversion .B Tversion

View file

@ -136,7 +136,7 @@ int cvtustat(Fcall*, uchar**, int);
void void
usage(void) usage(void)
{ {
fprint(2, "usage: 9pserve [-lnv] [-A aname afid] [-M msize] address\n"); fprint(2, "usage: 9pserve [-lnv] [-A aname afid] [-c addr] [-M msize] address\n");
fprint(2, "\treads/writes 9P messages on stdin/stdout\n"); fprint(2, "\treads/writes 9P messages on stdin/stdout\n");
threadexitsall("usage"); threadexitsall("usage");
} }
@ -146,7 +146,7 @@ extern int _threaddebuglevel;
void void
threadmain(int argc, char **argv) threadmain(int argc, char **argv)
{ {
char *file, *x; char *file, *x, *addr;
int fd; int fd;
x = getenv("verbose9pserve"); x = getenv("verbose9pserve");
@ -166,6 +166,15 @@ threadmain(int argc, char **argv)
versioned = 1; versioned = 1;
msize = atoi(EARGF(usage())); msize = atoi(EARGF(usage()));
break; break;
case 'c':
addr = netmkaddr(EARGF(usage()), "net", "9fs");
if((fd = dial(addr, nil, nil, nil)) < 0)
sysfatal("dial %s: %r", addr);
dup(fd, 0);
dup(fd, 1);
if(fd > 1)
close(fd);
break;
case 'n': case 'n':
noauth = 1; noauth = 1;
break; break;