diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libdiskfs/ext2.c | 13 | ||||
-rw-r--r-- | src/libdiskfs/ext2.h | 12 |
2 files changed, 17 insertions, 8 deletions
diff --git a/src/libdiskfs/ext2.c b/src/libdiskfs/ext2.c index afd95222..b55f1eb3 100644 --- a/src/libdiskfs/ext2.c +++ b/src/libdiskfs/ext2.c @@ -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 @@ -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; } @@ -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 */ } diff --git a/src/libdiskfs/ext2.h b/src/libdiskfs/ext2.h index 6109974d..7ddd400a 100644 --- a/src/libdiskfs/ext2.h +++ b/src/libdiskfs/ext2.h @@ -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 */ }; /* @@ -122,10 +127,6 @@ struct Inode u32int diracl; /* Directory ACL or high size bits */ u32int faddr; /* Fragment address */ }; -enum -{ - InodeSize = 128 -}; /* * Directory entry @@ -153,6 +154,7 @@ struct Ext2 uint inospergroup; uint blockspergroup; uint inosperblock; + uint inosize; uint groupaddr; uint descperblock; uint firstblock; |