tlib9pclient: add support for 9P2000.u - plan9port - [fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port
Log
Files
Refs
README
LICENSE
---
commit 382ae73f24c4566b2948d72f65ff68dc35857556
parent ac5a97e6b3b136c1ab669ae19a813a81cce673eb
Author: Russ Cox 
Date:   Fri,  4 Jul 2008 02:46:05 -0400

lib9pclient: add support for 9P2000.u

Diffstat:
  M src/lib9pclient/dirread.c           |      13 +++++++------
  M src/lib9pclient/fs.c                |       9 ++++++---
  M src/lib9pclient/fsimpl.h            |       1 +
  M src/lib9pclient/stat.c              |       2 +-
  M src/lib9pclient/wstat.c             |       4 ++--

5 files changed, 17 insertions(+), 12 deletions(-)
---
diff --git a/src/lib9pclient/dirread.c b/src/lib9pclient/dirread.c
t@@ -4,9 +4,10 @@
 #include 
 #include 
 #include <9pclient.h>
+#include "fsimpl.h"
 
 static long
-dirpackage(uchar *buf, long ts, Dir **d)
+dirpackage(uchar *buf, long ts, Dir **d, int dotu)
 {
         char *s;
         long ss, i, n, nn, m;
t@@ -22,7 +23,7 @@ dirpackage(uchar *buf, long ts, Dir **d)
         n = 0;
         for(i = 0; i < ts; i += m){
                 m = BIT16SZ + GBIT16(&buf[i]);
-                if(statcheck(&buf[i], m) < 0)
+                if(statchecku(&buf[i], m, dotu) < 0)
                         break;
                 ss += m;
                 n++;
t@@ -42,7 +43,7 @@ dirpackage(uchar *buf, long ts, Dir **d)
         nn = 0;
         for(i = 0; i < ts; i += m){
                 m = BIT16SZ + GBIT16((uchar*)&buf[i]);
-                if(nn >= n || convM2D(&buf[i], m, *d + nn, s) != m){
+                if(nn >= n || convM2Du(&buf[i], m, *d + nn, s, dotu) != m){
                         free(*d);
                         *d = nil;
                         return -1;
t@@ -65,7 +66,7 @@ fsdirread(CFid *fid, Dir **d)
                 return -1;
         ts = fsread(fid, buf, DIRMAX);
         if(ts >= 0)
-                ts = dirpackage(buf, ts, d);
+                ts = dirpackage(buf, ts, d, fid->fs->dotu);
         free(buf);
         return ts;
 }
t@@ -91,9 +92,9 @@ fsdirreadall(CFid *fid, Dir **d)
                 ts += n;
         }
         if(ts >= 0){
-                ts = dirpackage(buf, ts, d);
+                ts = dirpackage(buf, ts, d, fid->fs->dotu);
                 if(ts < 0)
-                        werrstr("malformed directory contents");
+                        werrstr("malformed directory contents [dotu=%d]", fid->fs->dotu);
         }
         free(buf);
         if(ts == 0 && n < 0)
diff --git a/src/lib9pclient/fs.c b/src/lib9pclient/fs.c
t@@ -49,12 +49,15 @@ fsinit(int fd)
         fs->iosend = ioproc();
         muxinit(&fs->mux);
         
-        strcpy(fs->version, "9P2000");
+        strcpy(fs->version, "9P2000.u");
         if((n = fsversion(fs, 8192, fs->version, sizeof fs->version)) < 0){
                 werrstr("fsversion: %r");
                 _fsunmount(fs);
                 return nil;
         }
+        if(strcmp(fs->version, "9P2000.u") == 0)
+                fs->dotu = 1;
+fprint(2, "speaking %d\n", fs->dotu);
         fs->msize = n;
         return fs;
 }
t@@ -215,7 +218,7 @@ _fsrpc(CFsys *fs, Fcall *tx, Fcall *rx, void **freep)
         tx->tag = 0;
         if(chatty9pclient)
                 fprint(2, "<- %F\n", tx);
-        nn = convS2M(tx, tpkt, n);
+        nn = convS2Mu(tx, tpkt, n, fs->dotu);
         if(nn != n){
                 free(tpkt);
                 werrstr("lib9pclient: sizeS2M convS2M mismatch");
t@@ -229,7 +232,7 @@ _fsrpc(CFsys *fs, Fcall *tx, Fcall *rx, void **freep)
                 return -1;
         }
         n = GBIT32((uchar*)rpkt);
-        nn = convM2S(rpkt, n, rx);
+        nn = convM2Su(rpkt, n, rx, fs->dotu);
         if(nn != n){
                 free(rpkt);
                 werrstr("lib9pclient: convM2S packet size mismatch %d %d", n, nn);
diff --git a/src/lib9pclient/fsimpl.h b/src/lib9pclient/fsimpl.h
t@@ -14,6 +14,7 @@ void *_fsnbqrecv(Queue*);
 struct CFsys
 {
         char version[20];
+        int dotu;
         int msize;
         QLock lk;
         int fd;
diff --git a/src/lib9pclient/stat.c b/src/lib9pclient/stat.c
t@@ -42,7 +42,7 @@ fsdirfstat(CFid *fid)
                 free(freep);
                 return nil;
         }
-        n = convM2D(rx.stat, rx.nstat, d, (char*)&d[1]);
+        n = convM2Du(rx.stat, rx.nstat, d, (char*)&d[1], fs->dotu);
         free(freep);
         if(n != rx.nstat){
                 free(d);
diff --git a/src/lib9pclient/wstat.c b/src/lib9pclient/wstat.c
t@@ -28,11 +28,11 @@ fsdirfwstat(CFid *fid, Dir *d)
         int n, nn;
         Fcall tx, rx;
 
-        n = sizeD2M(d);
+        n = sizeD2Mu(d, fid->fs->dotu);
         a = malloc(n);
         if(a == nil)
                 return -1;
-        nn = convD2M(d, a, n);
+        nn = convD2Mu(d, a, n, fid->fs->dotu);
         if(n != nn){
                 werrstr("convD2M and sizeD2M disagree");
                 free(a);