exportfs: properly reply to chdir() error when we speak 9p

when we got a bad root tree, we should speak the right language
and return a Rerror response instead of crapping ascii into
the 9p conversation.
This commit is contained in:
cinap_lenrek 2016-02-14 04:48:48 +01:00
parent a9b1e990b8
commit 232a064f3a

View file

@ -249,8 +249,15 @@ main(int argc, char **argv)
}
else if(srv != nil) {
if(chdir(srv) < 0) {
ebuf[0] = '\0';
errstr(ebuf, sizeof ebuf);
fprint(0, "chdir(\"%s\"): %s\n", srv, ebuf);
r = getsbuf();
r->work.tag = NOTAG;
r->work.fid = NOFID;
r->work.type = Rerror;
r->work.ename = ebuf;
n = convS2M(&r->work, r->buf, messagesize);
write(0, r->buf, n);
DEBUG(DFD, "chdir(\"%s\"): %s\n", srv, ebuf);
exits(ebuf);
}