From 232a064f3a9afcd9a5c1de45f1558e4522c511bd Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 14 Feb 2016 04:48:48 +0100 Subject: [PATCH] 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. --- sys/src/cmd/exportfs/exportfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/src/cmd/exportfs/exportfs.c b/sys/src/cmd/exportfs/exportfs.c index 8190f64b3..a01081847 100644 --- a/sys/src/cmd/exportfs/exportfs.c +++ b/sys/src/cmd/exportfs/exportfs.c @@ -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); }