- Obtain inode sizes and location of the first inode based on the contents
of superblock rather than using hardcoded values. This fixes ext2fs on filesystems with inode sized other than 128. Submitted by: Alex Lyashkov <Alexey.Lyashkov@Sun.COM> (based on) MFC after: 2 weeks
This commit is contained in:
parent
4c67374c75
commit
291156ecf1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=187395
@ -150,8 +150,8 @@
|
||||
#else /* !notyet */
|
||||
#define EXT2_INODES_PER_BLOCK(s) ((s)->s_inodes_per_block)
|
||||
/* Should be sizeof(struct ext2_inode): */
|
||||
#define EXT2_INODE_SIZE 128
|
||||
#define EXT2_FIRST_INO 11
|
||||
#define EXT2_INODE_SIZE(s) ((s)->s_inode_size)
|
||||
#define EXT2_FIRST_INO(s) ((s)->s_first_inode)
|
||||
#endif /* notyet */
|
||||
|
||||
/*
|
||||
|
@ -63,6 +63,8 @@ struct ext2_sb_info {
|
||||
unsigned long s_db_per_group; /* Number of descriptor blocks per group */
|
||||
unsigned long s_desc_per_block; /* Number of group descriptors per block */
|
||||
unsigned long s_groups_count; /* Number of groups in the fs */
|
||||
unsigned long s_first_inode; /* First inode on fs */
|
||||
unsigned int s_inode_size; /* Size for inode with extra data */
|
||||
struct buffer_head * s_sbh; /* Buffer containing the super block */
|
||||
struct ext2_super_block * s_es; /* Pointer to the super block in the buffer */
|
||||
struct buffer_head ** s_group_desc;
|
||||
|
@ -91,7 +91,7 @@ ext2_update(vp, waitfor)
|
||||
return (error);
|
||||
}
|
||||
ext2_i2ei(ip, (struct ext2_inode *)((char *)bp->b_data +
|
||||
EXT2_INODE_SIZE * ino_to_fsbo(fs, ip->i_number)));
|
||||
EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ip->i_number)));
|
||||
if (waitfor && (vp->v_mount->mnt_kern_flag & MNTK_ASYNC) == 0)
|
||||
return (bwrite(bp));
|
||||
else {
|
||||
|
@ -225,7 +225,7 @@ void ext2_free_inode (struct inode * inode)
|
||||
|
||||
sb = inode->i_e2fs;
|
||||
lock_super (DEVVP(inode));
|
||||
if (inode->i_number < EXT2_FIRST_INO ||
|
||||
if (inode->i_number < EXT2_FIRST_INO(sb) ||
|
||||
inode->i_number > sb->s_es->s_inodes_count) {
|
||||
printf ("free_inode reserved inode or nonexistent inode");
|
||||
unlock_super (DEVVP(inode));
|
||||
@ -435,7 +435,7 @@ ino_t ext2_new_inode (const struct inode * dir, int mode)
|
||||
goto repeat;
|
||||
}
|
||||
j += i * EXT2_INODES_PER_GROUP(sb) + 1;
|
||||
if (j < EXT2_FIRST_INO || j > es->s_inodes_count) {
|
||||
if (j < EXT2_FIRST_INO(sb) || j > es->s_inodes_count) {
|
||||
printf ( "ext2_new_inode:"
|
||||
"reserved inode or inode > inodes count - "
|
||||
"block_group = %d,inode=%d", i, j);
|
||||
|
@ -424,7 +424,11 @@ static int compute_sb_data(devvp, es, fs)
|
||||
V(s_frags_per_group)
|
||||
fs->s_inodes_per_group = es->s_inodes_per_group;
|
||||
V(s_inodes_per_group)
|
||||
fs->s_inodes_per_block = fs->s_blocksize / EXT2_INODE_SIZE;
|
||||
fs->s_inode_size = es->s_inode_size;
|
||||
V(s_inode_size)
|
||||
fs->s_first_inode = es->s_first_ino;
|
||||
V(s_first_inode);
|
||||
fs->s_inodes_per_block = fs->s_blocksize / EXT2_INODE_SIZE(fs);
|
||||
V(s_inodes_per_block)
|
||||
fs->s_itb_per_group = fs->s_inodes_per_group /fs->s_inodes_per_block;
|
||||
V(s_itb_per_group)
|
||||
@ -578,7 +582,7 @@ ext2_reload(struct mount *mp, struct thread *td)
|
||||
return (error);
|
||||
}
|
||||
ext2_ei2i((struct ext2_inode *) ((char *)bp->b_data +
|
||||
EXT2_INODE_SIZE * ino_to_fsbo(fs, ip->i_number)), ip);
|
||||
EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ip->i_number)), ip);
|
||||
brelse(bp);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
vrele(vp);
|
||||
@ -1012,7 +1016,7 @@ printf("ext2_vget(%d) dbn= %d ", ino, fsbtodb(fs, ino_to_fsba(fs, ino)));
|
||||
return (error);
|
||||
}
|
||||
/* convert ext2 inode to dinode */
|
||||
ext2_ei2i((struct ext2_inode *) ((char *)bp->b_data + EXT2_INODE_SIZE *
|
||||
ext2_ei2i((struct ext2_inode *) ((char *)bp->b_data + EXT2_INODE_SIZE(fs) *
|
||||
ino_to_fsbo(fs, ino)), ip);
|
||||
ip->i_block_group = ino_to_cg(fs, ino);
|
||||
ip->i_next_alloc_block = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user