delete 9P2000.u

thanks to Erik Quanstrom

R=rsc
http://codereview.appspot.com/3469042
This commit is contained in:
Russ Cox 2010-12-07 13:34:11 -05:00
parent d10a7ed9a8
commit 74dd032175
15 changed files with 64 additions and 337 deletions

View file

@ -204,7 +204,6 @@ struct Srv {
int nopipe;
int srvfd;
int leavefdsopen; /* magic for acme win */
int dotu;
int foreground; /* run in foreground */
int fake;

View file

@ -122,15 +122,6 @@ uint convM2D(uchar*, uint, Dir*, char*);
uint convD2M(Dir*, uchar*, uint);
uint sizeD2M(Dir*);
uint convM2Su(uchar*, uint, Fcall*, int);
uint convS2Mu(Fcall*, uchar*, uint, int);
uint sizeS2Mu(Fcall*, int);
int statchecku(uchar *abuf, uint nbuf, int);
uint convM2Du(uchar*, uint, Dir*, char*, int);
uint convD2Mu(Dir*, uchar*, uint, int);
uint sizeD2Mu(Dir*, int);
int fcallfmt(Fmt*);
int dirfmt(Fmt*);
int dirmodefmt(Fmt*);

View file

@ -75,7 +75,6 @@ struct Conn
Queue *outq;
Queue *inq;
Channel *outqdead;
int dotu;
};
char *xaname;
@ -91,13 +90,12 @@ int msize = 8192;
u32int xafid = NOFID;
int attached;
int versioned;
int dotu;
int noauth;
void *gethash(Hash**, uint);
int puthash(Hash**, uint, void*);
int delhash(Hash**, uint, void*);
Msg *mread9p(Ioproc*, int, int);
Msg *mread9p(Ioproc*, int);
int mwrite9p(Ioproc*, int, uchar*);
uchar *read9ppkt(Ioproc*, int);
int write9ppkt(int, uchar*);
@ -119,7 +117,7 @@ void listenthread(void*);
void outputthread(void*);
void inputthread(void*);
void rewritehdr(Fcall*, uchar*);
void repack(Fcall*, uchar**, int);
void repack(Fcall*, uchar**);
int tlisten(char*, char*);
int taccept(int, char*);
int iolisten(Ioproc*, char*, char*);
@ -130,8 +128,6 @@ void mainproc(void*);
int ignorepipe(void*, char*);
int timefmt(Fmt*);
void dorootstat(void);
int stripudirread(Msg*);
int cvtustat(Fcall*, uchar**, int);
void
usage(void)
@ -237,7 +233,7 @@ mainproc(void *v)
if(!versioned){
f.type = Tversion;
f.version = "9P2000.u";
f.version = "9P2000";
f.msize = msize;
f.tag = NOTAG;
n = convS2M(&f, vbuf, sizeof vbuf);
@ -255,7 +251,6 @@ mainproc(void *v)
if(f.msize < msize)
msize = f.msize;
if(verbose > 1) fprint(2, "%T * -> %F\n", &f);
dotu = strncmp(f.version, "9P2000.u", 8) == 0;
}
threadcreate(inputthread, nil, STACK);
@ -315,13 +310,13 @@ send9pmsg(Msg *m)
{
int n, nn;
n = sizeS2Mu(&m->rx, m->c->dotu);
n = sizeS2M(&m->rx);
m->rpkt = emalloc(n);
nn = convS2Mu(&m->rx, m->rpkt, n, m->c->dotu);
nn = convS2M(&m->rx, m->rpkt, n);
if(nn <= BIT16SZ)
sysfatal("convS2Mu conversion error");
sysfatal("convS2M conversion error");
if(nn != n)
sysfatal("sizeS2Mu and convS2Mu disagree");
sysfatal("sizeS2M and convS2M disagree");
sendq(m->c->outq, m);
}
@ -330,13 +325,13 @@ sendomsg(Msg *m)
{
int n, nn;
n = sizeS2Mu(&m->tx, m->c->dotu);
n = sizeS2M(&m->tx);
m->tpkt = emalloc(n);
nn = convS2Mu(&m->tx, m->tpkt, n, m->c->dotu);
nn = convS2M(&m->tx, m->tpkt, n);
if(nn <= BIT16SZ)
sysfatal("convS2Mu conversion error");
sysfatal("convS2M conversion error");
if(nn != n)
sysfatal("sizeS2Mu and convS2Mu disagree");
sysfatal("sizeS2M and convS2M disagree");
sendq(outq, m);
}
@ -380,7 +375,7 @@ connthread(void *arg)
close(c->fd);
c->fd = fd;
threadcreate(connoutthread, c, STACK);
while((m = mread9p(io, c->fd, c->dotu)) != nil){
while((m = mread9p(io, c->fd)) != nil){
if(verbose > 1) fprint(2, "%T fd#%d -> %F\n", c->fd, &m->tx);
m->c = c;
m->ctag = m->tx.tag;
@ -398,11 +393,6 @@ connthread(void *arg)
if(m->rx.msize > msize)
m->rx.msize = msize;
m->rx.version = "9P2000";
c->dotu = 0;
if(dotu && strncmp(m->tx.version, "9P2000.u", 8) == 0){
m->rx.version = "9P2000.u";
c->dotu = 1;
}
m->rx.type = Rversion;
send9pmsg(m);
continue;
@ -438,7 +428,7 @@ connthread(void *arg)
m->tx.afid = xafid;
m->tx.aname = xaname;
m->tx.uname = getuser(); /* what srv.c used */
repack(&m->tx, &m->tpkt, c->dotu);
repack(&m->tx, &m->tpkt);
}
break;
case Twalk:
@ -476,7 +466,7 @@ connthread(void *arg)
m->afid->ref++;
break;
case Tcreate:
if(dotu && !c->dotu && (m->tx.perm&(DMSYMLINK|DMDEVICE|DMNAMEDPIPE|DMSOCKET))){
if(m->tx.perm&(DMSYMLINK|DMDEVICE|DMNAMEDPIPE|DMSOCKET)){
err(m, "unsupported file type");
continue;
}
@ -503,18 +493,6 @@ connthread(void *arg)
continue;
}
m->fid->ref++;
if(m->tx.type==Twstat && dotu && !c->dotu){
if(cvtustat(&m->tx, &m->tpkt, 1) < 0){
err(m, "cannot convert stat buffer");
continue;
}
}
if(m->tx.type==Tread && m->fid->isdir && dotu && !c->dotu){
if(m->tx.offset = m->fid->coffset)
m->tx.offset = m->fid->offset;
else
m->fid->offset = m->fid->coffset;
}
break;
}
@ -798,7 +776,6 @@ xopenfd(Msg *m)
void
connoutthread(void *arg)
{
char *ename;
int err;
Conn *c;
Msg *m, *om;
@ -844,28 +821,14 @@ connoutthread(void *arg)
fidput(m->newfid);
break;
case Tread:
if(!err && m->fid->isdir && dotu && !m->c->dotu){
m->fid->offset += m->rx.count;
stripudirread(m);
m->fid->coffset += m->rx.count;
}
break;
case Tstat:
if(!err && dotu && !m->c->dotu)
cvtustat(&m->rx, &m->rpkt, 0);
break;
case Topen:
case Tcreate:
m->fid->isdir = (m->rx.qid.type & QTDIR);
break;
}
if(m->rx.type==Rerror && dotu && !c->dotu){
ename = estrdup(m->rx.ename);
m->rx.ename = ename;
repack(&m->rx, &m->rpkt, c->dotu);
free(ename);
m->rx.ename = "XXX";
}
if(delhash(m->c->tag, m->ctag, m) == 0)
msgput(m);
if(verbose > 1) fprint(2, "%T fd#%d <- %F\n", c->fd, &m->rx);
@ -933,7 +896,7 @@ inputthread(void *arg)
free(pkt);
continue;
}
if((nn = convM2Su(pkt, n, &m->rx, dotu)) != n){
if((nn = convM2S(pkt, n, &m->rx)) != n){
fprint(2, "%T bad packet - convM2S %d but %d\n", nn, n);
free(pkt);
msgput(m);
@ -1270,7 +1233,7 @@ read9ppkt(Ioproc *io, int fd)
}
Msg*
mread9p(Ioproc *io, int fd, int dotu)
mread9p(Ioproc *io, int fd)
{
int n, nn;
uchar *pkt;
@ -1282,7 +1245,7 @@ mread9p(Ioproc *io, int fd, int dotu)
m = msgnew(0);
m->tpkt = pkt;
n = GBIT32(pkt);
nn = convM2Su(pkt, n, &m->tx, dotu);
nn = convM2S(pkt, n, &m->tx);
if(nn != n){
fprint(2, "%T read bad packet from %d\n", fd);
return nil;
@ -1327,24 +1290,24 @@ restring(uchar *pkt, int pn, char *s)
}
void
repack(Fcall *f, uchar **ppkt, int dotu)
repack(Fcall *f, uchar **ppkt)
{
uint n, nn;
uchar *pkt;
pkt = *ppkt;
n = GBIT32(pkt);
nn = sizeS2Mu(f, dotu);
nn = sizeS2M(f);
if(nn > n){
free(pkt);
pkt = emalloc(nn);
*ppkt = pkt;
}
n = convS2Mu(f, pkt, nn, dotu);
n = convS2M(f, pkt, nn);
if(n <= BIT16SZ)
sysfatal("convS2M conversion error");
if(n != nn)
sysfatal("convS2Mu and sizeS2Mu disagree");
sysfatal("convS2M and sizeS2M disagree");
}
void
@ -1446,90 +1409,3 @@ timefmt(Fmt *fmt)
mon[tm.mon], tm.mday, tm.hour, tm.min, tm.sec,
(int)(ns%1000000000)/1000000);
}
int
cvtustat(Fcall *f, uchar **fpkt, int tounix)
{
int n;
uchar *buf;
char *str;
Dir dir;
str = emalloc(f->nstat);
n = convM2Du(f->stat, f->nstat, &dir, str, !tounix);
if(n <= BIT16SZ){
free(str);
return -1;
}
n = sizeD2Mu(&dir, tounix);
buf = emalloc(n);
if(convD2Mu(&dir, buf, n, tounix) != n)
sysfatal("convD2Mu conversion error");
f->nstat = n;
f->stat = buf;
repack(f, fpkt, dotu);
free(buf);
f->stat = nil; /* is this okay ??? */
free(str);
return 0;
}
int
stripudirread(Msg* msg)
{
char *str;
int i, m, n, nn;
uchar *buf;
Dir d;
Fcall* rx;
buf = nil;
str = nil;
rx = &msg->rx;
n = 0;
nn = 0;
for(i = 0; i < rx->count; i += m){
m = BIT16SZ + GBIT16(&rx->data[i]);
if(statchecku((uchar*)&rx->data[i], m, 1) < 0)
return -1;
if(nn < m)
nn = m;
n++;
}
str = emalloc(nn);
buf = emalloc(rx->count);
nn = 0;
for(i = 0; i < rx->count; i += m){
m = BIT16SZ + GBIT16(&rx->data[i]);
if(convM2Du((uchar*)&rx->data[i], m, &d, str, 1) != m){
free(buf);
free(str);
return -1;
}
n = convD2M(&d, &buf[nn], rx->count - nn);
if(n <= BIT16SZ){
free(buf);
free(str);
return -1;
}
nn += n;
}
rx->count = nn;
rx->data = (char*)buf;
repack(&msg->rx, &msg->rpkt, 0);
free(str);
free(buf);
rx->data = nil; /* is this okay ??? */
return 0;
}

View file

@ -2,13 +2,6 @@
#include <fcall.h>
#include "vac.h"
#ifndef PLAN9PORT
#define convM2Su(a, b, c, d) convM2S(a, b, c)
#define convS2Mu(a, b, c, d) convS2M(a, b, c)
#define convM2Du(a, b, c, d) convM2D(a, b, c)
#define convD2Mu(a, b, c, d) convD2M(a, b, c)
#endif
typedef struct Fid Fid;
enum
@ -50,7 +43,6 @@ Fcall thdr;
VacFs *fs;
VtConn *conn;
int noperm;
int dotu;
char *defmnt;
Fid * newfid(int);
@ -306,10 +298,6 @@ rversion(Fid *unused)
if(strncmp(rhdr.version, "9P2000", 6) != 0)
return vtstrdup("unrecognized 9P version");
thdr.version = "9P2000";
if(strncmp(rhdr.version, "9P2000.u", 8) == 0){
dotu = 1;
thdr.version = "9P2000.u";
}
return nil;
}
@ -719,7 +707,7 @@ vacstat(VacFile *parent, VacDir *vd, uchar *p, int np)
dir.gidnum = atoi(vd->gid);
#endif
ret = convD2Mu(&dir, p, np, dotu);
ret = convD2M(&dir, p, np);
#ifdef PLAN9PORT
free(ext);
#endif
@ -796,7 +784,7 @@ io(void)
n = read9pmsg(mfd[0], mdata, sizeof mdata);
if(n <= 0)
break;
if(convM2Su(mdata, n, &rhdr, dotu) != n)
if(convM2S(mdata, n, &rhdr) != n)
sysfatal("convM2S conversion error");
if(dflag)
@ -820,9 +808,9 @@ io(void)
thdr.tag = rhdr.tag;
if(dflag)
fprint(2, "vacfs:->%F\n", &thdr);
n = convS2Mu(&thdr, mdata, messagesize, dotu);
n = convS2M(&thdr, mdata, messagesize);
if(n <= BIT16SZ)
sysfatal("convS2Mu conversion error");
sysfatal("convS2M conversion error");
if(err)
vtfree(err);

View file

@ -3,7 +3,7 @@
#include <fcall.h>
uint
sizeD2Mu(Dir *d, int dotu)
sizeD2M(Dir *d)
{
char *sv[5];
int i, ns, nstr, fixlen;
@ -15,11 +15,6 @@ sizeD2Mu(Dir *d, int dotu)
fixlen = STATFIXLEN;
nstr = 4;
if(dotu){
fixlen = STATFIXLENU;
sv[4] = d->ext;
nstr = 5;
}
ns = 0;
for(i = 0; i < nstr; i++)
@ -30,13 +25,7 @@ sizeD2Mu(Dir *d, int dotu)
}
uint
sizeD2M(Dir *d)
{
return sizeD2Mu(d, 0);
}
uint
convD2Mu(Dir *d, uchar *buf, uint nbuf, int dotu)
convD2M(Dir *d, uchar *buf, uint nbuf)
{
uchar *p, *ebuf;
char *sv[5];
@ -55,11 +44,6 @@ convD2Mu(Dir *d, uchar *buf, uint nbuf, int dotu)
fixlen = STATFIXLEN;
nstr = 4;
if(dotu){
fixlen = STATFIXLENU;
sv[4] = d->ext;
nstr = 5;
}
ns = 0;
for(i = 0; i < nstr; i++){
@ -110,23 +94,8 @@ convD2Mu(Dir *d, uchar *buf, uint nbuf, int dotu)
p += ns;
}
if(dotu){
PBIT32(p, d->uidnum);
p += BIT32SZ;
PBIT32(p, d->gidnum);
p += BIT32SZ;
PBIT32(p, d->muidnum);
p += BIT32SZ;
}
if(ss != p - buf)
return 0;
return p - buf;
}
uint
convD2M(Dir *d, uchar *buf, uint nbuf)
{
return convD2Mu(d, buf, nbuf, 0);
}

View file

@ -3,7 +3,7 @@
#include <fcall.h>
int
statchecku(uchar *buf, uint nbuf, int dotu)
statcheck(uchar *buf, uint nbuf)
{
uchar *ebuf;
int i, nstr;
@ -16,33 +16,22 @@ statchecku(uchar *buf, uint nbuf, int dotu)
buf += STATFIXLEN - 4 * BIT16SZ;
nstr = 4;
if(dotu)
nstr = 5;
for(i = 0; i < nstr; i++){
if(buf + BIT16SZ > ebuf)
return -1;
buf += BIT16SZ + GBIT16(buf);
}
if(dotu)
buf += 3*BIT32SZ;
if(buf != ebuf)
return -1;
return 0;
}
int
statcheck(uchar *buf, uint nbuf)
{
return statchecku(buf, nbuf, 0);
}
static char nullstring[] = "";
uint
convM2Du(uchar *buf, uint nbuf, Dir *d, char *strs, int dotu)
convM2D(uchar *buf, uint nbuf, Dir *d, char *strs)
{
uchar *p, *ebuf;
char *sv[5];
@ -75,8 +64,6 @@ convM2Du(uchar *buf, uint nbuf, Dir *d, char *strs, int dotu)
p += BIT64SZ;
nstr = 4;
if(dotu)
nstr = 5;
for(i = 0; i < nstr; i++){
if(p + BIT16SZ > ebuf)
return 0;
@ -93,25 +80,12 @@ convM2Du(uchar *buf, uint nbuf, Dir *d, char *strs, int dotu)
p += ns;
}
if(dotu){
if(p + BIT32SZ*3 > ebuf)
return 0;
d->uidnum = GBIT32(p);
p += BIT32SZ;
d->gidnum = GBIT32(p);
p += BIT32SZ;
d->muidnum = GBIT32(p);
p += BIT32SZ;
}
if(strs){
d->name = sv[0];
d->uid = sv[1];
d->gid = sv[2];
d->muid = sv[3];
d->ext = nullstring;
if(dotu)
d->ext = sv[4];
}else{
d->name = nullstring;
d->uid = nullstring;
@ -122,9 +96,3 @@ convM2Du(uchar *buf, uint nbuf, Dir *d, char *strs, int dotu)
return p - buf;
}
uint
convM2D(uchar *buf, uint nbuf, Dir *d, char *strs)
{
return convM2Du(buf, nbuf, d, strs, 0);
}

View file

@ -48,7 +48,7 @@ gqid(uchar *p, uchar *ep, Qid *q)
* to test at end of routine.
*/
uint
convM2Su(uchar *ap, uint nap, Fcall *f, int dotu)
convM2S(uchar *ap, uint nap, Fcall *f)
{
uchar *p, *ep;
uint i, size;
@ -101,12 +101,6 @@ convM2Su(uchar *ap, uint nap, Fcall *f, int dotu)
if(p == nil)
break;
f->uidnum = NOUID;
if(dotu){
if(p+BIT32SZ > ep)
return 0;
f->uidnum = GBIT32(p);
p += BIT32SZ;
}
break;
case Tattach:
@ -125,12 +119,6 @@ convM2Su(uchar *ap, uint nap, Fcall *f, int dotu)
if(p == nil)
break;
f->uidnum = NOUID;
if(dotu){
if(p+BIT32SZ > ep)
return 0;
f->uidnum = GBIT32(p);
p += BIT32SZ;
}
break;
case Twalk:
@ -175,8 +163,6 @@ convM2Su(uchar *ap, uint nap, Fcall *f, int dotu)
p += BIT32SZ;
f->mode = GBIT8(p);
p += BIT8SZ;
if(dotu)
p = gstring(p, ep, &f->extension);
break;
case Tread:
@ -246,12 +232,6 @@ convM2Su(uchar *ap, uint nap, Fcall *f, int dotu)
case Rerror:
p = gstring(p, ep, &f->ename);
f->errornum = 0;
if(dotu){
if(p+BIT32SZ > ep)
return 0;
f->errornum = GBIT32(p);
p += BIT32SZ;
}
break;
case Rflush:
@ -344,9 +324,3 @@ convM2Su(uchar *ap, uint nap, Fcall *f, int dotu)
return size;
return 0;
}
uint
convM2S(uchar *ap, uint nap, Fcall *f)
{
return convM2Su(ap, nap, f, 0);
}

View file

@ -46,7 +46,7 @@ stringsz(char *s)
}
uint
sizeS2Mu(Fcall *f, int dotu)
sizeS2M(Fcall *f)
{
uint n;
int i;
@ -74,8 +74,6 @@ sizeS2Mu(Fcall *f, int dotu)
n += BIT32SZ;
n += stringsz(f->uname);
n += stringsz(f->aname);
if(dotu)
n += BIT32SZ;
break;
case Tattach:
@ -83,8 +81,6 @@ sizeS2Mu(Fcall *f, int dotu)
n += BIT32SZ;
n += stringsz(f->uname);
n += stringsz(f->aname);
if(dotu)
n += BIT32SZ;
break;
case Twalk:
@ -106,8 +102,6 @@ sizeS2Mu(Fcall *f, int dotu)
n += stringsz(f->name);
n += BIT32SZ;
n += BIT8SZ;
if(dotu)
n += stringsz(f->extension);
break;
case Tread:
@ -147,8 +141,6 @@ sizeS2Mu(Fcall *f, int dotu)
case Rerror:
n += stringsz(f->ename);
if(dotu)
n += BIT32SZ;
break;
case Rflush:
@ -206,18 +198,12 @@ sizeS2Mu(Fcall *f, int dotu)
}
uint
sizeS2M(Fcall *f)
{
return sizeS2Mu(f, 0);
}
uint
convS2Mu(Fcall *f, uchar *ap, uint nap, int dotu)
convS2M(Fcall *f, uchar *ap, uint nap)
{
uchar *p;
uint i, size;
size = sizeS2Mu(f, dotu);
size = sizeS2M(f);
if(size == 0)
return 0;
if(size > nap)
@ -253,11 +239,6 @@ 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:
@ -267,11 +248,6 @@ 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:
@ -303,8 +279,6 @@ convS2Mu(Fcall *f, uchar *ap, uint nap, int dotu)
p += BIT32SZ;
PBIT8(p, f->mode);
p += BIT8SZ;
if(dotu)
p = pstring(p, f->extension);
break;
case Tread:
@ -357,10 +331,6 @@ convS2Mu(Fcall *f, uchar *ap, uint nap, int dotu)
case Rerror:
p = pstring(p, f->ename);
if(dotu){
PBIT32(p, f->errornum);
p += BIT32SZ;
}
break;
case Rflush:
@ -427,9 +397,3 @@ convS2Mu(Fcall *f, uchar *ap, uint nap, int dotu)
return 0;
return size;
}
uint
convS2M(Fcall *f, uchar *ap, uint nap)
{
return convS2Mu(f, ap, nap, 0);
}

View file

@ -24,7 +24,7 @@ dirread9p(Req *r, Dirgen *gen, void *aux)
memset(&d, 0, sizeof d);
if((*gen)(start, &d, aux) < 0)
break;
rv = convD2Mu(&d, p, ep-p, r->srv->dotu);
rv = convD2M(&d, p, ep-p);
free(d.name);
free(d.muid);
free(d.uid);

View file

@ -67,7 +67,7 @@ getreq(Srv *s)
memmove(buf, s->rbuf, n);
qunlock(&s->rlock);
if(convM2Su(buf, n, &f, s->dotu) != n){
if(convM2S(buf, n, &f) != n){
free(buf);
return nil;
}
@ -166,22 +166,16 @@ sversion(Srv *srv, Req *r)
{
USED(srv);
if(strncmp(r->ifcall.version, "9P", 2) != 0){
if(strncmp(r->ifcall.version, "9P2000", 6) != 0){
r->ofcall.version = "unknown";
respond(r, nil);
return;
}
if(strncmp(r->ifcall.version, "9P2000.u", 8) == 0){
r->ofcall.version = "9P2000.u";
srv->dotu = 1;
}else{
r->ofcall.version = "9P2000";
srv->dotu = 0;
}
r->ofcall.msize = r->ifcall.msize;
respond(r, nil);
}
static void
rversion(Req *r, char *error)
{
@ -205,6 +199,7 @@ sauth(Srv *srv, Req *r)
respond(r, e);
}
}
static void
rauth(Req *r, char *error)
{
@ -237,6 +232,7 @@ sattach(Srv *srv, Req *r)
respond(r, nil);
return;
}
static void
rattach(Req *r, char *error)
{
@ -255,6 +251,7 @@ sflush(Srv *srv, Req *r)
else
respond(r, nil);
}
static int
rflush(Req *r, char *error)
{
@ -422,6 +419,7 @@ sopen(Srv *srv, Req *r)
else
respond(r, nil);
}
static void
ropen(Req *r, char *error)
{
@ -454,6 +452,7 @@ screate(Srv *srv, Req *r)
else
respond(r, Enocreate);
}
static void
rcreate(Req *r, char *error)
{
@ -501,6 +500,7 @@ sread(Srv *srv, Req *r)
else
respond(r, "no srv->read");
}
static void
rread(Req *r, char *error)
{
@ -630,8 +630,8 @@ rstat(Req *r, char *error)
if(error)
return;
if(convD2Mu(&r->d, tmp, BIT16SZ, r->srv->dotu) != BIT16SZ){
r->error = "convD2Mu(_,_,BIT16SZ,_) did not return BIT16SZ";
if(convD2M(&r->d, tmp, BIT16SZ) != BIT16SZ){
r->error = "convD2M(_,_,BIT16SZ) did not return BIT16SZ";
return;
}
n = GBIT16(tmp)+BIT16SZ;
@ -640,10 +640,10 @@ rstat(Req *r, char *error)
r->error = "out of memory";
return;
}
r->ofcall.nstat = convD2Mu(&r->d, statbuf, n, r->srv->dotu);
r->ofcall.nstat = convD2M(&r->d, statbuf, n);
r->ofcall.stat = statbuf; /* freed in closereq */
if(r->ofcall.nstat <= BIT16SZ){
r->error = "convD2Mu fails";
r->error = "convD2M fails";
free(statbuf);
return;
}
@ -660,7 +660,7 @@ swstat(Srv *srv, Req *r)
respond(r, Enowstat);
return;
}
if(convM2Du(r->ifcall.stat, r->ifcall.nstat, &r->d, (char*)r->ifcall.stat, srv->dotu) != r->ifcall.nstat){
if(convM2D(r->ifcall.stat, r->ifcall.nstat, &r->d, (char*)r->ifcall.stat) != r->ifcall.nstat){
respond(r, Ebaddir);
return;
}
@ -686,6 +686,7 @@ swstat(Srv *srv, Req *r)
}
srv->wstat(r);
}
static void
rwstat(Req *r, char *msg)
{
@ -801,7 +802,7 @@ if(chatty9p)
fprint(2, "-%d-> %F\n", srv->outfd, &r->ofcall);
qlock(&srv->wlock);
n = convS2Mu(&r->ofcall, srv->wbuf, srv->msize, srv->dotu);
n = convS2M(&r->ofcall, srv->wbuf, srv->msize);
if(n <= 0){
fprint(2, "n = %d %F\n", n, &r->ofcall);
abort();

View file

@ -7,7 +7,7 @@
#include "fsimpl.h"
static long
dirpackage(uchar *buf, long ts, Dir **d, int dotu)
dirpackage(uchar *buf, long ts, Dir **d)
{
char *s;
long ss, i, n, nn, m;
@ -23,7 +23,7 @@ dirpackage(uchar *buf, long ts, Dir **d, int dotu)
n = 0;
for(i = 0; i < ts; i += m){
m = BIT16SZ + GBIT16(&buf[i]);
if(statchecku(&buf[i], m, dotu) < 0)
if(statcheck(&buf[i], m) < 0)
break;
ss += m;
n++;
@ -43,7 +43,7 @@ dirpackage(uchar *buf, long ts, Dir **d, int dotu)
nn = 0;
for(i = 0; i < ts; i += m){
m = BIT16SZ + GBIT16((uchar*)&buf[i]);
if(nn >= n || convM2Du(&buf[i], m, *d + nn, s, dotu) != m){
if(nn >= n || convM2D(&buf[i], m, *d + nn, s) != m){
free(*d);
*d = nil;
return -1;
@ -66,7 +66,7 @@ fsdirread(CFid *fid, Dir **d)
return -1;
ts = fsread(fid, buf, DIRMAX);
if(ts >= 0)
ts = dirpackage(buf, ts, d, fid->fs->dotu);
ts = dirpackage(buf, ts, d);
free(buf);
return ts;
}
@ -92,9 +92,9 @@ fsdirreadall(CFid *fid, Dir **d)
ts += n;
}
if(ts >= 0){
ts = dirpackage(buf, ts, d, fid->fs->dotu);
ts = dirpackage(buf, ts, d);
if(ts < 0)
werrstr("malformed directory contents [dotu=%d]", fid->fs->dotu);
werrstr("malformed directory contents");
}
free(buf);
if(ts == 0 && n < 0)

View file

@ -49,14 +49,12 @@ fsinit(int fd)
fs->iosend = ioproc();
muxinit(&fs->mux);
strcpy(fs->version, "9P2000.u");
strcpy(fs->version, "9P2000");
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;
fs->msize = n;
return fs;
}
@ -208,7 +206,7 @@ _fsrpc(CFsys *fs, Fcall *tx, Fcall *rx, void **freep)
int n, nn;
void *tpkt, *rpkt;
n = sizeS2Mu(tx, fs->dotu);
n = sizeS2M(tx);
tpkt = malloc(n);
if(freep)
*freep = nil;
@ -217,7 +215,7 @@ _fsrpc(CFsys *fs, Fcall *tx, Fcall *rx, void **freep)
tx->tag = 0;
if(chatty9pclient)
fprint(2, "<- %F\n", tx);
nn = convS2Mu(tx, tpkt, n, fs->dotu);
nn = convS2M(tx, tpkt, n);
if(nn != n){
free(tpkt);
werrstr("lib9pclient: sizeS2M convS2M mismatch");
@ -231,7 +229,7 @@ _fsrpc(CFsys *fs, Fcall *tx, Fcall *rx, void **freep)
return -1;
}
n = GBIT32((uchar*)rpkt);
nn = convM2Su(rpkt, n, rx, fs->dotu);
nn = convM2S(rpkt, n, rx);
if(nn != n){
free(rpkt);
werrstr("lib9pclient: convM2S packet size mismatch %d %d", n, nn);

View file

@ -14,7 +14,6 @@ void *_fsnbqrecv(Queue*);
struct CFsys
{
char version[20];
int dotu;
int msize;
QLock lk;
int fd;

View file

@ -42,7 +42,7 @@ fsdirfstat(CFid *fid)
free(freep);
return nil;
}
n = convM2Du(rx.stat, rx.nstat, d, (char*)&d[1], fs->dotu);
n = convM2D(rx.stat, rx.nstat, d, (char*)&d[1]);
free(freep);
if(n != rx.nstat){
free(d);

View file

@ -28,11 +28,11 @@ fsdirfwstat(CFid *fid, Dir *d)
int n, nn;
Fcall tx, rx;
n = sizeD2Mu(d, fid->fs->dotu);
n = sizeD2M(d);
a = malloc(n);
if(a == nil)
return -1;
nn = convD2Mu(d, a, n, fid->fs->dotu);
nn = convD2M(d, a, n);
if(n != nn){
werrstr("convD2M and sizeD2M disagree");
free(a);