libdiskfs: ext2 revision 1 tweaks (Fazlul Shahriar)

This commit is contained in:
Russ Cox 2008-06-01 08:47:06 -04:00
parent df1ee4e1af
commit d29f5ece8b
2 changed files with 17 additions and 8 deletions

View file

@ -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 */
}

View file

@ -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;