tlibdiskfs: ext2 revision 1 tweaks (Fazlul Shahriar) - 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 d29f5ece8b534180076e2859dcc014b3c36b00cf
 (DIR) parent df1ee4e1af9340a8207535c5009ec289bf1ecda1
 (HTM) Author: Russ Cox <rsc@swtch.com>
       Date:   Sun,  1 Jun 2008 08:47:06 -0400
       
       libdiskfs: ext2 revision 1 tweaks (Fazlul Shahriar)
       
       Diffstat:
         M src/libdiskfs/ext2.c                |      13 ++++++++++---
         M src/libdiskfs/ext2.h                |      12 +++++++-----
       
       2 files changed, 17 insertions(+), 8 deletions(-)
       ---
 (DIR) diff --git a/src/libdiskfs/ext2.c b/src/libdiskfs/ext2.c
       t@@ -275,7 +275,11 @@ ext2sync(Fsys *fsys)
                        / super.blockspergroup;
                fs->inospergroup = super.inospergroup;
                fs->blockspergroup = super.blockspergroup;
       -        fs->inosperblock = fs->blocksize / InodeSize;
       +        if(super.revlevel >= 1)
       +                fs->inosize = super.inosize;
       +        else
       +                fs->inosize = 128;
       +        fs->inosperblock = fs->blocksize / fs->inosize;
                if(fs->blocksize == SBOFF)
                        fs->groupaddr = 2;
                else
       t@@ -336,7 +340,7 @@ handle2ino(Ext2 *fs, Nfs3Handle *h, u32int *pinum, Inode *ino)
                addr = g.inodeaddr + ioff/fs->inosperblock;
                if((b = diskread(fs->disk, fs->blocksize, (u64int)addr*fs->blocksize)) == nil)
                        return Nfs3ErrIo;
       -        parseinode(ino, b->data+InodeSize*(ioff%fs->inosperblock));
       +        parseinode(ino, b->data+fs->inosize*(ioff%fs->inosperblock));
                blockput(b);
                return Nfs3Ok;
        }
       t@@ -875,5 +879,8 @@ parsesuper(Super *s, uchar *p)
                s->revlevel = l32(p+76);
                s->defresuid = l16(p+80);
                s->defresgid = l16(p+82);
       -        /* 940 byte reserved */
       +        s->firstino = l32(p+84);
       +        s->inosize = l32(p+88);
       +        s->blockgroupnr = l16(p+60);
       +        /* 932 byte reserved */
        }
 (DIR) diff --git a/src/libdiskfs/ext2.h b/src/libdiskfs/ext2.h
       t@@ -80,7 +80,12 @@ struct Super
                u32int        revlevel;                /* Revision level */
                u16int        defresuid;                /* Default uid for reserved blocks */
                u16int        defresgid;                /* Default gid for reserved blocks */
       -        u32int        reserved[235];        /* Padding to the end of the block */
       +        
       +        /* the following are only available with revlevel = 1 */
       +        u32int        firstino;                /* First non-reserved inode */
       +        u16int        inosize;                /* size of inode structure */
       +        u16int        blockgroupnr;        /* block group # of this super block */
       +        u32int        reserved[233];        /* Padding to the end of the block */
        };
        
        /*
       t@@ -122,10 +127,6 @@ struct Inode
                u32int        diracl;        /* Directory ACL or high size bits */
                u32int        faddr;                /* Fragment address */
        };
       -enum
       -{
       -        InodeSize = 128
       -};
        
        /*
         * Directory entry
       t@@ -153,6 +154,7 @@ struct Ext2
                uint        inospergroup;
                uint        blockspergroup;
                uint        inosperblock;
       +        uint        inosize;
                uint        groupaddr;
                uint        descperblock;
                uint        firstblock;