12 #define Reqsize (sizeof(Fcall)+Maxfdata)
16 uchar mdata[Maxiosize];
17 char repdata[Maxfdata];
18 uchar statbuf[STATMAX];
26 void (*fcalls[])(void) = {
45 fprint(2, "usage: %s [-v] [-s] [-f devicefile] [srvname]\n", argv0);
50 main(int argc, char **argv)
52 int stdio, srvfd, pipefd[2];
54 rep = malloc(sizeof(Fcall));
55 req = malloc(Reqsize);
56 if(rep == nil || req == nil)
57 panic("out of memory");
83 strcpy(srvfile, "#s/dos");
85 snprint(srvfile, sizeof srvfile, "#s/%s", argv[0]);
94 srvfd = create(srvfile, OWRITE|ORCLOSE, 0600);
97 fprint(srvfd, "%d", pipefd[0]);
99 fprint(2, "%s: serving %s\n", argv0, srvfile);
105 switch(rfork(RFNOWAIT|RFNOTEG|RFFDG|RFPROC|RFNAMEG)){
116 open("#c/cons", OWRITE);
130 fmtinstall('F', fcallfmt);
131 while((n = read9pmsg(0, mdata, sizeof mdata)) != 0){
134 if(convM2S(mdata, n, req) != n)
135 panic("convM2S format error");
138 fprint(2, "dossrv %d:<-%F\n", pid, req);
141 if(!fcalls[req->type])
144 (*fcalls[req->type])();
147 rep->ename = xerrstr(errno);
149 rep->type = req->type + 1;
154 fprint(2, "dossrv %d:->%F\n", pid, rep);
155 n = convS2M(rep, mdata, sizeof mdata);
157 panic("convS2M error on write");
158 if(write(1, mdata, n) != n)
159 panic("mount write");
161 chat("server shut down\n");
167 if (e < 0 || e >= sizeof errmsg/sizeof errmsg[0])
168 return "no such error";
170 errstr(errbuf, sizeof errbuf);
177 eqqid(Qid q1, Qid q2)
179 return q1.path == q2.path && q1.type == q2.type && q1.vers == q2.vers;