tlib9: dotu fixes in convS2M, convM2S - plan9port - [fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port
Log
Files
Refs
README
LICENSE
---
commit 8ff457f56db9f94f4baf68f53d87e791584d1dfe
parent e7c5e5ed94e02e969d45d8ab74876cac53694195
Author: Tim Newsham 
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(-)
---
diff --git a/include/fcall.h b/include/fcall.h
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
diff --git a/src/lib9/convM2S.c b/src/lib9/convM2S.c
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;
 
diff --git a/src/lib9/convS2M.c b/src/lib9/convS2M.c
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;