text2 fixes - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit e77222a4ecdf427c2eed2eb44251b8841ef81b3c
 (DIR) parent 6802a899956b6c593729c53fe9435dfc89020444
 (HTM) Author: rsc <devnull@localhost>
       Date:   Thu,  4 May 2006 18:02:13 +0000
       
       ext2 fixes
       
       Diffstat:
         M src/libdiskfs/ext2.c                |      17 ++++++++---------
         M src/libdiskfs/venti.c               |      61 +++++++++++++++----------------
       
       2 files changed, 37 insertions(+), 41 deletions(-)
       ---
 (DIR) diff --git a/src/libdiskfs/ext2.c b/src/libdiskfs/ext2.c
       t@@ -6,7 +6,7 @@
        #include <diskfs.h>
        #include "ext2.h"
        
       -#define debug 1
       +#define debug 0
        
        static int ext2sync(Fsys*);
        static void ext2close(Fsys*);
       t@@ -111,8 +111,10 @@ ext2blockread(Fsys *fsys, u64int vbno)
                                fprint(2, "loading group: %r...");
                        return nil;
                }
       -/*        if(debug) */
       -/*                fprint(2, "group %d bitblock=%d...", bno/fs->blockspergroup, g->bitblock); */
       +/*
       +        if(debug)
       +                fprint(2, "group %d bitblock=%d...", bno/fs->blockspergroup, g->bitblock);
       +*/
        
                if((bitb = diskread(fs->disk, fs->blocksize, (u64int)g->bitblock*fs->blocksize)) == nil){
                        if(debug)
       t@@ -138,7 +140,7 @@ static Block*
        ext2datablock(Ext2 *fs, u32int bno, int size)
        {
                USED(size);
       -        return ext2blockread(fs->fsys, bno+fs->firstblock);
       +        return ext2blockread(fs->fsys, bno);
        }
        
        static Block*
       t@@ -605,15 +607,12 @@ ext2readdir(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, u32int count, u64int coo
                                        if(debug) fprint(2, "bad namlen %d reclen %d at offset %d of %d\n", de->namlen, de->reclen, (int)(p-b->data), b->len);
                                        break;
                                }
       -                        if(de->name[de->namlen] != 0){
       -                                if(debug) fprint(2, "bad name %d %.*s\n", de->namlen, de->namlen, de->name);
       -                                continue;
       -                        }
       -                        if(debug) print("%s/%d ", de->name, (int)de->ino);
       +                        if(debug) print("%.*s/%d ", de->namlen, de->name, (int)de->ino);
                                if((uchar*)de - b->data < off)
                                        continue;
                                e.fileid = de->ino;
                                e.name = de->name;
       +                        e.namelen = de->namlen;
                                e.cookie = (u64int)i*fs->blocksize + (p - b->data);
                                if(nfs3entrypack(dp, dep, &ndp, &e) < 0){
                                        done = 1;
 (DIR) diff --git a/src/libdiskfs/venti.c b/src/libdiskfs/venti.c
       t@@ -41,38 +41,7 @@ vtfileindices(VtEntry *e, u32int bn, int *index)
                return i;
        }
        
       -static VtBlock*
       -_vtfileblock(VtCache *c, VtEntry *e, u32int bn)
       -{
       -        VtBlock *b, *bb;
       -        int i, d, index[VtPointerDepth+1], t;
       -
       -        i = vtfileindices(e, bn, index);
       -        if(i < 0)
       -                return nil;
       -        d = (e->type&VtTypeDepthMask);
       -        if(i > d){
       -                werrstr("bad address %d > %d (%x %x)", i, d, e->type, e->flags);
       -                return nil;
       -        }
       -
       -/*fprint(2, "vtread %V\n", e->score); */
       -        b = vtcacheglobal(c, e->score, e->type);
       -        if(b == nil)
       -                return nil;
       -
       -        for(i=d-1; i>=0; i--){
       -                t = VtDataType+i;
       -/*fprint(2, "vtread %V\n", b->data+index[i]*VtScoreSize); */
       -                bb = vtcacheglobal(c, b->data+index[i]*VtScoreSize, t);
       -                vtblockput(b);
       -                if(bb == nil)
       -                        return nil;
       -                b = bb;
       -        }
       -        return b;
       -}
       -
       +VtBlock *_vtfileblock(VtCache*, VtEntry*, u32int);        /* avoid auto-inline by putting later in file */
        static void
        diskventiblockput(Block *b)
        {
       t@@ -109,6 +78,34 @@ nfilereads++;
                return b;
        }
        
       +VtBlock*
       +_vtfileblock(VtCache *c, VtEntry *e, u32int bn)
       +{
       +        VtBlock *b, *bb;
       +        int i, d, index[VtPointerDepth+1], t;
       +        uchar score[VtScoreSize];
       +
       +        i = vtfileindices(e, bn, index);
       +        if(i < 0)
       +                return nil;
       +        d = (e->type&VtTypeDepthMask);
       +        if(i > d){
       +                werrstr("bad address %d > %d (%x %x)", i, d, e->type, e->flags);
       +                return nil;
       +        }
       +
       +/*fprint(2, "vtread %V\n", e->score); */
       +        b = vtcacheglobal(c, e->score, e->type);
       +        for(i=d-1; i>=0 && b; i--){
       +                t = VtDataType+i;
       +/*fprint(2, "vtread %V\n", b->data+index[i]*VtScoreSize); */
       +                memmove(score, b->data+index[i]*VtScoreSize, VtScoreSize);
       +                vtblockput(b);
       +                b = vtcacheglobal(c, score, t);
       +        }
       +        return b;
       +}
       +
        static void
        diskventiclose(Disk *dd)
        {