char Eisopen[] = "file already open for I/O";
char Excl[] = "exclusive use file already open";
char Ename[] = "illegal name";
-char Eversion[] = "unknown 9P version";
void
usage(void)
break;
default:
close(p[0]); /* don't deadlock if child fails */
- if(mount(p[1], -1, defmnt, MREPL|MCREATE, "") < 0)
+ if(mount(p[1], -1, defmnt, MREPL|MCREATE, "") == -1)
sysfatal("mount failed: %r");
}
exits(0);
else
rhdr.msize = thdr.msize;
messagesize = rhdr.msize;
- if(strncmp(thdr.version, "9P2000", 6) != 0)
- return Eversion;
rhdr.version = "9P2000";
+ if(strncmp(thdr.version, "9P", 2) != 0)
+ rhdr.version = "unknown";
return nil;
}
pid = getpid();
- for(;;){
- /*
- * reading from a pipe or a network device
- * will give an error after a few eof reads.
- * however, we cannot tell the difference
- * between a zero-length read and an interrupt
- * on the processes writing to us,
- * so we wait for the error.
- */
- n = read9pmsg(mfd[0], mdata, messagesize);
+ while((n = read9pmsg(mfd[0], mdata, messagesize)) != 0){
if(n < 0)
- sysfatal("mount read");
- if(n == 0)
- continue;
- if(convM2S(mdata, n, &thdr) == 0)
- continue;
+ sysfatal("mount read: %r");
+ if(convM2S(mdata, n, &thdr) != n)
+ sysfatal("convM2S format error: %r");
if(debug)
fprint(2, "%s %d:<-%F\n", argv0, pid, &thdr);