Author: stas Date: Sun Jan 18 14:04:56 2009 New Revision: 187395 URL: http://svn.freebsd.org/changeset/base/187395
Log: - 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.lyash...@sun.com> (based on) MFC after: 2 weeks Modified: head/sys/gnu/fs/ext2fs/ext2_fs.h head/sys/gnu/fs/ext2fs/ext2_fs_sb.h head/sys/gnu/fs/ext2fs/ext2_inode.c head/sys/gnu/fs/ext2fs/ext2_linux_ialloc.c head/sys/gnu/fs/ext2fs/ext2_vfsops.c Modified: head/sys/gnu/fs/ext2fs/ext2_fs.h ============================================================================== --- head/sys/gnu/fs/ext2fs/ext2_fs.h Sun Jan 18 13:04:38 2009 (r187394) +++ head/sys/gnu/fs/ext2fs/ext2_fs.h Sun Jan 18 14:04:56 2009 (r187395) @@ -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 */ /* Modified: head/sys/gnu/fs/ext2fs/ext2_fs_sb.h ============================================================================== --- head/sys/gnu/fs/ext2fs/ext2_fs_sb.h Sun Jan 18 13:04:38 2009 (r187394) +++ head/sys/gnu/fs/ext2fs/ext2_fs_sb.h Sun Jan 18 14:04:56 2009 (r187395) @@ -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; Modified: head/sys/gnu/fs/ext2fs/ext2_inode.c ============================================================================== --- head/sys/gnu/fs/ext2fs/ext2_inode.c Sun Jan 18 13:04:38 2009 (r187394) +++ head/sys/gnu/fs/ext2fs/ext2_inode.c Sun Jan 18 14:04:56 2009 (r187395) @@ -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 { Modified: head/sys/gnu/fs/ext2fs/ext2_linux_ialloc.c ============================================================================== --- head/sys/gnu/fs/ext2fs/ext2_linux_ialloc.c Sun Jan 18 13:04:38 2009 (r187394) +++ head/sys/gnu/fs/ext2fs/ext2_linux_ialloc.c Sun Jan 18 14:04:56 2009 (r187395) @@ -225,7 +225,7 @@ void ext2_free_inode (struct inode * ino 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 @@ repeat: 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); Modified: head/sys/gnu/fs/ext2fs/ext2_vfsops.c ============================================================================== --- head/sys/gnu/fs/ext2fs/ext2_vfsops.c Sun Jan 18 13:04:38 2009 (r187394) +++ head/sys/gnu/fs/ext2fs/ext2_vfsops.c Sun Jan 18 14:04:56 2009 (r187395) @@ -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 @@ loop: 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, fs 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; _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"