summaryrefslogtreecommitdiff
path: root/sys/src/cmd/cwfs/9p2.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2022-06-07 22:38:04 +0000
committerOri Bernstein <ori@eigenstate.org>2022-06-07 22:38:04 +0000
commit4eeefed7b0c1c47329213f1da719820ebbbebf18 (patch)
tree5a26470746cd117ac61b2e2d7c090a18a8fb3581 /sys/src/cmd/cwfs/9p2.c
parent13065e16b3c4fba4d9200ed7fec89ee49338f12a (diff)
cwfs: fix iounit negotiation
cwfs had an issue with iounit negotiation as a result of the conversion to 9p2000 -- with the move to variable size messages, the fixed message overhead decreased, but the advertised message size was still adding the old fixed overhead. This meant that if the kernel negotiated the maximum io size, cwfs would negotiate something larger than it supported, and would hang up when an io of that size was made. In addition, the size of messages was stored in a short, which means that negotiating an iounit larger than 16384 bytes would overflow the message count, and cause things to fall over. Finally, whle we're here, we clean up some duplicated and unused constants.
Diffstat (limited to 'sys/src/cmd/cwfs/9p2.c')
-rw-r--r--sys/src/cmd/cwfs/9p2.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/sys/src/cmd/cwfs/9p2.c b/sys/src/cmd/cwfs/9p2.c
index a4d129c97..3745fff76 100644
--- a/sys/src/cmd/cwfs/9p2.c
+++ b/sys/src/cmd/cwfs/9p2.c
@@ -1,7 +1,4 @@
#include "all.h"
-#include <fcall.h>
-
-enum { MSIZE = MAXDAT+MAXMSG };
static int
mkmode9p1(ulong mode9p2)
@@ -155,10 +152,10 @@ version(Chan* chan, Fcall* f, Fcall* r)
if(chan->protocol != nil || f->msize < 256)
return Eversion;
- if(f->msize < MSIZE)
+ if(f->msize < MAXDAT+IOHDRSZ)
r->msize = f->msize;
else
- r->msize = MSIZE;
+ r->msize = MAXDAT+IOHDRSZ;
/*
* Should check the '.' stuff here.
@@ -1825,7 +1822,7 @@ serve9p2(Msgbuf* mb)
* replies.
*/
if(convM2S(mb->data, mb->count, &f) != mb->count){
- fprint(2, "didn't like %d byte message\n", mb->count);
+ fprint(2, "didn't like %ld byte message\n", mb->count);
return 0;
}
type = f.type;
@@ -1921,7 +1918,7 @@ serve9p2(Msgbuf* mb)
*/
if(chan->msize == 0){
r.ename = "Tversion not seen";
- n = convS2M(&r, rmb->data, MAXMSG);
+ n = convS2M(&r, rmb->data, SMALLBUF);
} else {
snprint(ename, sizeof(ename), "9p2: convS2M: type %d",
type);