| Date: Thu, 20 Aug 2009 11:37:24 -0400
lib9: dotu fixes in convS2M, convM2S
http://codereview.appspot.com/109049
Diffstat:
M include/fcall.h | 2 ++
M src/lib9/convM2S.c | 20 +++++++++++++++++---
M src/lib9/convS2M.c | 20 +++++++++++++++++---
3 files changed, 36 insertions(+), 6 deletions(-)
--- |
| t@@ -44,6 +44,7 @@ struct Fcall
/* 9P2000.u extensions */
int errornum; /* Rerror */
+ int uidnum; /* Tattach, Tauth */
char *extension; /* Tcreate */
} Fcall;
t@@ -73,6 +74,7 @@ struct Fcall
#define NOTAG (ushort)~0U /* Dummy tag */
#define NOFID (u32int)~0U /* Dummy fid */
+#define NOUID (-1) /* Dummy uid */
#define IOHDRSZ 24 /* ample room for Twrite/Rread header (iounit) */
enum |
| t@@ -100,6 +100,13 @@ convM2Su(uchar *ap, uint nap, Fcall *f, int dotu)
p = gstring(p, ep, &f->aname);
if(p == nil)
break;
+ f->uidnum = NOUID;
+ if(dotu){
+ if(p+BIT32SZ > ep)
+ return 0;
+ f->uidnum = GBIT32(p);
+ p += BIT32SZ;
+ }
break;
case Tattach:
t@@ -117,6 +124,13 @@ convM2Su(uchar *ap, uint nap, Fcall *f, int dotu)
p = gstring(p, ep, &f->aname);
if(p == nil)
break;
+ f->uidnum = NOUID;
+ if(dotu){
+ if(p+BIT32SZ > ep)
+ return 0;
+ f->uidnum = GBIT32(p);
+ p += BIT32SZ;
+ }
break;
case Twalk:
t@@ -233,10 +247,10 @@ convM2Su(uchar *ap, uint nap, Fcall *f, int dotu)
p = gstring(p, ep, &f->ename);
f->errornum = 0;
if(dotu){
- if(p+BIT16SZ > ep)
+ if(p+BIT32SZ > ep)
return 0;
- f->errornum = GBIT16(p);
- p += BIT16SZ;
+ f->errornum = GBIT32(p);
+ p += BIT32SZ;
}
break;
|
| t@@ -74,6 +74,8 @@ sizeS2Mu(Fcall *f, int dotu)
n += BIT32SZ;
n += stringsz(f->uname);
n += stringsz(f->aname);
+ if(dotu)
+ n += BIT32SZ;
break;
case Tattach:
t@@ -81,6 +83,8 @@ sizeS2Mu(Fcall *f, int dotu)
n += BIT32SZ;
n += stringsz(f->uname);
n += stringsz(f->aname);
+ if(dotu)
+ n += BIT32SZ;
break;
case Twalk:
t@@ -144,7 +148,7 @@ sizeS2Mu(Fcall *f, int dotu)
case Rerror:
n += stringsz(f->ename);
if(dotu)
- n += BIT16SZ;
+ n += BIT32SZ;
break;
case Rflush:
t@@ -249,6 +253,11 @@ convS2Mu(Fcall *f, uchar *ap, uint nap, int dotu)
p += BIT32SZ;
p = pstring(p, f->uname);
p = pstring(p, f->aname);
+ if(dotu){
+ f->uidnum = NOUID;
+ PBIT32(p, f->uidnum);
+ p += BIT32SZ;
+ }
break;
case Tattach:
t@@ -258,6 +267,11 @@ convS2Mu(Fcall *f, uchar *ap, uint nap, int dotu)
p += BIT32SZ;
p = pstring(p, f->uname);
p = pstring(p, f->aname);
+ if(dotu){
+ f->uidnum = NOUID;
+ PBIT32(p, f->uidnum);
+ p += BIT32SZ;
+ }
break;
case Twalk:
t@@ -344,8 +358,8 @@ convS2Mu(Fcall *f, uchar *ap, uint nap, int dotu)
case Rerror:
p = pstring(p, f->ename);
if(dotu){
- PBIT16(p, f->errornum);
- p += BIT16SZ;
+ PBIT32(p, f->errornum);
+ p += BIT32SZ;
}
break;
|