diff --git a/sys/man/4/hjfs b/sys/man/4/hjfs index 56a3b1411..e0eb414da 100644 --- a/sys/man/4/hjfs +++ b/sys/man/4/hjfs @@ -15,6 +15,9 @@ hjfs \- file server .B -n .I name ] [ +.B -a +.I announce-string +] ... [ -r ] [ .B -S @@ -46,6 +49,9 @@ Use .I name as the name of the service. .TP +.BI "-a " announce-string +will announce and listen on the specified network address. +.TP .B -r Ream the file system, erasing all of the old data. .TP diff --git a/sys/src/cmd/hjfs/9p.c b/sys/src/cmd/hjfs/9p.c index 037914904..a980b1f48 100644 --- a/sys/src/cmd/hjfs/9p.c +++ b/sys/src/cmd/hjfs/9p.c @@ -135,8 +135,10 @@ static Srv mysrv = { }; void -start9p(char *service, int stdio) +start9p(char *service, char **nets, int stdio) { + while(nets && *nets) + threadlistensrv(&mysrv, *nets++); if(stdio){ mysrv.infd = 1; mysrv.outfd = 1; diff --git a/sys/src/cmd/hjfs/fns.h b/sys/src/cmd/hjfs/fns.h index c75ff8e9f..24c48dffc 100644 --- a/sys/src/cmd/hjfs/fns.h +++ b/sys/src/cmd/hjfs/fns.h @@ -25,7 +25,7 @@ int chanwstat(Chan *, Dir *); int permcheck(Fs *, Dentry *, short, int); char * uid2name(Fs *, short, char *); int name2uid(Fs *, char *, short *); -void start9p(char *, int); +void start9p(char *, char **, int); int chanclunk(Chan *); int chanremove(Chan *); int getblk(Fs *, FLoc *, Buf *, uvlong, uvlong *, int); diff --git a/sys/src/cmd/hjfs/main.c b/sys/src/cmd/hjfs/main.c index 6a6c4697e..1bb595526 100644 --- a/sys/src/cmd/hjfs/main.c +++ b/sys/src/cmd/hjfs/main.c @@ -86,7 +86,7 @@ syncproc(void *) void usage(void) { - fprint(2, "usage: %s [-rsS] [-m mem] [-n service] -f dev\n", argv0); + fprint(2, "usage: %s [-rsS] [-m mem] [-n service] [-a announce-string]... -f dev\n", argv0); exits("usage"); } @@ -94,9 +94,11 @@ void threadmain(int argc, char **argv) { Dev *d; + static char *nets[8]; char *file, *service; - int doream, flags, stdio, nbuf; + int doream, flags, stdio, nbuf, netc; + netc = 0; doream = 0; stdio = 0; flags = FSNOAUTH; @@ -115,6 +117,13 @@ threadmain(int argc, char **argv) if(nbuf < 10) nbuf = 10; break; + case 'a': + if(netc >= nelem(nets)-1){ + fprint(2, "%s: too many networks to announce\n", argv0); + exits("too many nets"); + } + nets[netc++] = estrdup(EARGF(usage())); + break; default: usage(); } ARGEND; rfork(RFNOTEG); @@ -131,7 +140,7 @@ threadmain(int argc, char **argv) sysfatal("fsinit: %r"); initcons(service); proccreate(syncproc, nil, mainstacksize); - start9p(service, stdio); + start9p(service, nets, stdio); threadexits(nil); }