pass on correct offset for directory reads. bug reported http://9fans.net/archive/2009/08/322 and confirmed http://9fans.net/archive/2009/08/330 Reference: /n/sources/patch/applied/dirseekoffset Date: Mon Aug 10 20:31:46 CES 2009 Signed-off-by: quanstro@quanstro.net --- /sys/src/9/port/sysfile.c Mon Aug 10 20:30:07 2009 +++ /sys/src/9/port/sysfile.c Mon Aug 10 20:30:05 2009 @@ -628,7 +628,6 @@ static long read(ulong *arg, vlong *offp) { - int dir; long n, nn, nnn; uchar *p; Chan *c; @@ -669,19 +668,19 @@ unionrewind(c); } - dir = c->qid.type&QTDIR; - if(dir && mountrockread(c, p, n, &nn)){ - /* do nothing: mountrockread filled buffer */ - }else{ - if(dir && c->umh) + if(c->qid.type & QTDIR){ + if(mountrockread(c, p, n, &nn)){ + /* do nothing: mountrockread filled buffer */ + }else if(c->umh) nn = unionread(c, p, n); - else - nn = devtab[c->type]->read(c, p, n, off); - } - if(dir) + else{ + if(off != c->offset) + error(Edirseek); + nn = devtab[c->type]->read(c, p, n, c->devoffset); + } nnn = mountfix(c, p, nn, n); - else - nnn = nn; + }else + nnn = nn = devtab[c->type]->read(c, p, n, off); lock(c); c->devoffset += nn; --- /sys/src/9/port/error.h Mon Aug 10 20:30:14 2009 +++ /sys/src/9/port/error.h Mon Aug 10 20:30:12 2009 @@ -50,3 +50,4 @@ extern char Enegoff[]; /* negative i/o offset */ extern char Ecmdargs[]; /* wrong #args in control message */ extern char Ebadip[]; /* bad ip address syntax */ +extern char Edirseek[]; /* seek in directory */