[Ext2resize-cvs] ext2resize/src ext2.c, 1.34, 1.35 ext2.h, 1.28, 1.29 ext2online.c, 1.28, 1.29
Status: Inactive
Brought to you by:
adilger
From: Petter R. <pe...@us...> - 2006-06-11 08:30:16
|
Update of /cvsroot/ext2resize/ext2resize/src In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv11467/src Modified Files: ext2.c ext2.h ext2online.c Log Message: More big-endian fixes. Change is based on patch from Fedora. Part of the Fedora patch was already commited. This is the rest of it. Index: ext2online.c =================================================================== RCS file: /cvsroot/ext2resize/ext2resize/src/ext2online.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** ext2online.c 11 Jun 2006 08:19:04 -0000 1.28 --- ext2online.c 11 Jun 2006 08:30:07 -0000 1.29 *************** *** 239,246 **** unsigned int group; int last = 0; ! ! if (dindir_buf[gdb_num % apb] != pri_blk) { fprintf(stderr, "found %d not %d at %d[%d]\n", ! dindir_buf[gdb_num % apb], pri_blk, fs->resize.i_block[EXT2_DIND_BLOCK], gdb_num % apb); --- 239,248 ---- unsigned int group; int last = 0; ! blk_t dblk; ! ! dblk = le32_to_cpu(dindir_buf[gdb_num % apb]); ! if (dblk != pri_blk) { fprintf(stderr, "found %d not %d at %d[%d]\n", ! dblk, pri_blk, fs->resize.i_block[EXT2_DIND_BLOCK], gdb_num % apb); *************** *** 254,258 **** fs->numgroups) { __u32 *pri_buf = (__u32 *)(pri_bh->data); ! blk_t bku_blk; bku_blk = pri_blk + group * fs->sb.s_blocks_per_group; --- 256,260 ---- fs->numgroups) { __u32 *pri_buf = (__u32 *)(pri_bh->data); ! blk_t bku_blk, pblk; bku_blk = pri_blk + group * fs->sb.s_blocks_per_group; *************** *** 261,267 **** printf("checking for group block %d in Bond\n", bku_blk); ! if (pri_buf[last] != bku_blk) { fprintf(stderr, "found %d not %d at %d[%d]\n", ! pri_buf[last], bku_blk, pri_blk, last); ext2_brelse(pri_bh, 0); ret = 0; --- 263,270 ---- printf("checking for group block %d in Bond\n", bku_blk); ! pblk = le32_to_cpu(pri_buf[last]); ! if (pblk != bku_blk) { fprintf(stderr, "found %d not %d at %d[%d]\n", ! pblk, bku_blk, pri_blk, last); ext2_brelse(pri_bh, 0); ret = 0; *************** *** 341,344 **** --- 344,348 ---- gdp = (struct ext2_group_desc *)bh->data + (group % (fs->blocksize/sizeof(struct ext2_group_desc))); + ext2fs_swab_group_desc(fs, gdp); gdp->bg_block_bitmap = start + new_bb; Index: ext2.c =================================================================== RCS file: /cvsroot/ext2resize/ext2resize/src/ext2.c,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** ext2.c 10 Jun 2006 07:45:55 -0000 1.34 --- ext2.c 11 Jun 2006 08:30:07 -0000 1.35 *************** *** 36,39 **** --- 36,42 ---- unsigned char _bitmap[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; + static void ext2_swab_inode(struct ext2_fs *fs, + struct ext2_inode *t, struct ext2_inode *f, + int hostorder); void ext2_print_version(FILE *outfile, char *progname) *************** *** 259,262 **** --- 262,266 ---- memcpy(inode, bh->data + off, sizeof(struct ext2_inode)); ext2_brelse(bh, 0); + ext2_swab_inode(fs, inode, inode, 0); } *************** *** 842,845 **** --- 846,861 ---- } + void ext2fs_swab_group_desc(struct ext2_fs *fs, struct ext2_group_desc *gdp) + { + if(fs->flags & FL_SWAB_BYTES) { + gdp->bg_block_bitmap = ext2fs_swab32(gdp->bg_block_bitmap); + gdp->bg_inode_bitmap = ext2fs_swab32(gdp->bg_inode_bitmap); + gdp->bg_inode_table = ext2fs_swab32(gdp->bg_inode_table); + gdp->bg_free_blocks_count = ext2fs_swab16(gdp->bg_free_blocks_count); + gdp->bg_free_inodes_count = ext2fs_swab16(gdp->bg_free_inodes_count); + gdp->bg_used_dirs_count = ext2fs_swab16(gdp->bg_used_dirs_count); + } + } + static void ext2_swab_gds(struct ext2_fs *fs) { *************** *** 847,856 **** unsigned int group; for(group = 0; group < fs->gdblocks; group++) { ! fs->gd[group].bg_block_bitmap = ext2fs_swab32(fs->gd[group].bg_block_bitmap); ! fs->gd[group].bg_inode_bitmap = ext2fs_swab32(fs->gd[group].bg_inode_bitmap); ! fs->gd[group].bg_inode_table = ext2fs_swab32(fs->gd[group].bg_inode_table); ! fs->gd[group].bg_free_blocks_count = ext2fs_swab16(fs->gd[group].bg_free_blocks_count); ! fs->gd[group].bg_free_inodes_count = ext2fs_swab16(fs->gd[group].bg_free_inodes_count); ! fs->gd[group].bg_used_dirs_count = ext2fs_swab16(fs->gd[group].bg_used_dirs_count); } } --- 863,957 ---- unsigned int group; for(group = 0; group < fs->gdblocks; group++) { ! ext2fs_swab_group_desc(fs, &(fs->gd[group])); ! } ! } ! } ! ! static __inline__ blk_t ext2fs_inode_data_blocks(struct ext2_fs *fs, ! struct ext2_inode *inode) ! { ! return inode->i_blocks - ! (inode->i_file_acl ? fs->blocksize >> 9 : 0); ! } ! ! /* from <linux/stat.h>, copied here to avoid using a kernel header */ ! #define LINUX_S_IFMT 00170000 ! #define LINUX_S_IFLNK 00120000 ! #define LINUX_S_ISLNK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFLNK) ! ! static void ext2_swab_inode(struct ext2_fs *fs, ! struct ext2_inode *t, struct ext2_inode *f, ! int hostorder) ! { ! if(fs->flags & FL_SWAB_BYTES) { ! unsigned i; ! int islnk = 0; ! ! if (hostorder && LINUX_S_ISLNK(f->i_mode)) ! islnk = 1; ! t->i_mode = ext2fs_swab16(f->i_mode); ! if (!hostorder && LINUX_S_ISLNK(t->i_mode)) ! islnk = 1; ! t->i_uid = ext2fs_swab16(f->i_uid); ! t->i_size = ext2fs_swab32(f->i_size); ! t->i_atime = ext2fs_swab32(f->i_atime); ! t->i_ctime = ext2fs_swab32(f->i_ctime); ! t->i_mtime = ext2fs_swab32(f->i_mtime); ! t->i_dtime = ext2fs_swab32(f->i_dtime); ! t->i_gid = ext2fs_swab16(f->i_gid); ! t->i_links_count = ext2fs_swab16(f->i_links_count); ! t->i_blocks = ext2fs_swab32(f->i_blocks); ! t->i_flags = ext2fs_swab32(f->i_flags); ! t->i_file_acl = ext2fs_swab32(f->i_file_acl); ! t->i_dir_acl = ext2fs_swab32(f->i_dir_acl); ! if (!islnk || ext2fs_inode_data_blocks(fs, t)) { ! for (i = 0; i < EXT2_N_BLOCKS; i++) ! t->i_block[i] = ext2fs_swab32(f->i_block[i]); ! } else if (t != f) { ! for (i = 0; i < EXT2_N_BLOCKS; i++) ! t->i_block[i] = f->i_block[i]; ! } ! t->i_generation = ext2fs_swab32(f->i_generation); ! t->i_faddr = ext2fs_swab32(f->i_faddr); ! ! switch (fs->sb.s_creator_os) { ! case EXT2_OS_LINUX: ! t->osd1.linux1.l_i_reserved1 = ! ext2fs_swab32(f->osd1.linux1.l_i_reserved1); ! t->osd2.linux2.l_i_frag = f->osd2.linux2.l_i_frag; ! t->osd2.linux2.l_i_fsize = f->osd2.linux2.l_i_fsize; ! t->osd2.linux2.i_pad1 = ext2fs_swab16(f->osd2.linux2.i_pad1); ! t->osd2.linux2.l_i_uid_high = ! ext2fs_swab16 (f->osd2.linux2.l_i_uid_high); ! t->osd2.linux2.l_i_gid_high = ! ext2fs_swab16 (f->osd2.linux2.l_i_gid_high); ! t->osd2.linux2.l_i_reserved2 = ! ext2fs_swab32(f->osd2.linux2.l_i_reserved2); ! break; ! case EXT2_OS_HURD: ! t->osd1.hurd1.h_i_translator = ! ext2fs_swab32 (f->osd1.hurd1.h_i_translator); ! t->osd2.hurd2.h_i_frag = f->osd2.hurd2.h_i_frag; ! t->osd2.hurd2.h_i_fsize = f->osd2.hurd2.h_i_fsize; ! t->osd2.hurd2.h_i_mode_high = ! ext2fs_swab16 (f->osd2.hurd2.h_i_mode_high); ! t->osd2.hurd2.h_i_uid_high = ! ext2fs_swab16 (f->osd2.hurd2.h_i_uid_high); ! t->osd2.hurd2.h_i_gid_high = ! ext2fs_swab16 (f->osd2.hurd2.h_i_gid_high); ! t->osd2.hurd2.h_i_author = ! ext2fs_swab32 (f->osd2.hurd2.h_i_author); ! break; ! case EXT2_OS_MASIX: ! t->osd1.masix1.m_i_reserved1 = ! ext2fs_swab32(f->osd1.masix1.m_i_reserved1); ! t->osd2.masix2.m_i_frag = f->osd2.masix2.m_i_frag; ! t->osd2.masix2.m_i_fsize = f->osd2.masix2.m_i_fsize; ! t->osd2.masix2.m_pad1 = ext2fs_swab16(f->osd2.masix2.m_pad1); ! t->osd2.masix2.m_i_reserved2[0] = ! ext2fs_swab32(f->osd2.masix2.m_i_reserved2[0]); ! t->osd2.masix2.m_i_reserved2[1] = ! ext2fs_swab32(f->osd2.masix2.m_i_reserved2[1]); ! break; } } Index: ext2.h =================================================================== RCS file: /cvsroot/ext2resize/ext2resize/src/ext2.h,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** ext2.h 10 Jun 2006 07:45:55 -0000 1.28 --- ext2.h 11 Jun 2006 08:30:07 -0000 1.29 *************** *** 240,243 **** --- 240,246 ---- int ext2_resize_fs(struct ext2_fs *fs); + /* fs byte-swap */ + void ext2fs_swab_group_desc(struct ext2_fs *fs, struct ext2_group_desc *gdp); + /* unix I/O */ loff_t ext2_llseek(unsigned int fd, loff_t offset, unsigned int whence); |