hjfs: network announce/listen support

This commit is contained in:
cinap_lenrek 2013-01-07 02:13:54 +01:00
parent a5b6143c4c
commit 0c85432359
4 changed files with 22 additions and 5 deletions

View file

@ -15,6 +15,9 @@ hjfs \- file server
.B -n .B -n
.I name .I name
] [ ] [
.B -a
.I announce-string
] ... [
-r -r
] [ ] [
.B -S .B -S
@ -46,6 +49,9 @@ Use
.I name .I name
as the name of the service. as the name of the service.
.TP .TP
.BI "-a " announce-string
will announce and listen on the specified network address.
.TP
.B -r .B -r
Ream the file system, erasing all of the old data. Ream the file system, erasing all of the old data.
.TP .TP

View file

@ -135,8 +135,10 @@ static Srv mysrv = {
}; };
void void
start9p(char *service, int stdio) start9p(char *service, char **nets, int stdio)
{ {
while(nets && *nets)
threadlistensrv(&mysrv, *nets++);
if(stdio){ if(stdio){
mysrv.infd = 1; mysrv.infd = 1;
mysrv.outfd = 1; mysrv.outfd = 1;

View file

@ -25,7 +25,7 @@ int chanwstat(Chan *, Dir *);
int permcheck(Fs *, Dentry *, short, int); int permcheck(Fs *, Dentry *, short, int);
char * uid2name(Fs *, short, char *); char * uid2name(Fs *, short, char *);
int name2uid(Fs *, char *, short *); int name2uid(Fs *, char *, short *);
void start9p(char *, int); void start9p(char *, char **, int);
int chanclunk(Chan *); int chanclunk(Chan *);
int chanremove(Chan *); int chanremove(Chan *);
int getblk(Fs *, FLoc *, Buf *, uvlong, uvlong *, int); int getblk(Fs *, FLoc *, Buf *, uvlong, uvlong *, int);

View file

@ -86,7 +86,7 @@ syncproc(void *)
void void
usage(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"); exits("usage");
} }
@ -94,9 +94,11 @@ void
threadmain(int argc, char **argv) threadmain(int argc, char **argv)
{ {
Dev *d; Dev *d;
static char *nets[8];
char *file, *service; char *file, *service;
int doream, flags, stdio, nbuf; int doream, flags, stdio, nbuf, netc;
netc = 0;
doream = 0; doream = 0;
stdio = 0; stdio = 0;
flags = FSNOAUTH; flags = FSNOAUTH;
@ -115,6 +117,13 @@ threadmain(int argc, char **argv)
if(nbuf < 10) if(nbuf < 10)
nbuf = 10; nbuf = 10;
break; 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(); default: usage();
} ARGEND; } ARGEND;
rfork(RFNOTEG); rfork(RFNOTEG);
@ -131,7 +140,7 @@ threadmain(int argc, char **argv)
sysfatal("fsinit: %r"); sysfatal("fsinit: %r");
initcons(service); initcons(service);
proccreate(syncproc, nil, mainstacksize); proccreate(syncproc, nil, mainstacksize);
start9p(service, stdio); start9p(service, nets, stdio);
threadexits(nil); threadexits(nil);
} }