* Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
*
* %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
+ * This file may be redistributed under the terms of the GNU Library
+ * General Public License, version 2.
* %End-Header%
*/
unsigned long i, first_meta_bg;
__u32 features;
int groups_per_block, blocks_per_group, io_flags;
- blk_t group_block, blk;
+ blk64_t group_block, blk;
char *dest, *cp;
#ifdef WORDS_BIGENDIAN
struct ext2_group_desc *gdp;
io_flags |= IO_FLAG_RW;
if (flags & EXT2_FLAG_EXCLUSIVE)
io_flags |= IO_FLAG_EXCLUSIVE;
+ if (flags & EXT2_FLAG_DIRECT_IO)
+ io_flags |= IO_FLAG_DIRECT_IO;
retval = manager->open(fs->device_name, io_flags, &fs->io);
if (retval)
goto cleanup;
goto cleanup;
fs->image_io = fs->io;
fs->io->app_data = fs;
- retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &fs->super);
+ retval = ext2fs_get_memalign(SUPERBLOCK_SIZE, 512, &fs->super);
if (retval)
goto cleanup;
if (flags & EXT2_FLAG_IMAGE_FILE) {
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
goto cleanup;
}
+ if (!EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+ EXT4_FEATURE_RO_COMPAT_BIGALLOC) &&
+ (fs->super->s_log_block_size != fs->super->s_log_cluster_size)) {
+ retval = EXT2_ET_CORRUPT_SUPERBLOCK;
+ goto cleanup;
+ }
fs->blocksize = EXT2_BLOCK_SIZE(fs->super);
if (EXT2_INODE_SIZE(fs->super) < EXT2_GOOD_OLD_INODE_SIZE) {
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
goto cleanup;
}
- fs->fragsize = EXT2_FRAG_SIZE(fs->super);
+ fs->cluster_ratio_bits = fs->super->s_log_cluster_size -
+ fs->super->s_log_block_size;
+ if (EXT2_BLOCKS_PER_GROUP(fs->super) !=
+ EXT2_CLUSTERS_PER_GROUP(fs->super) << fs->cluster_ratio_bits) {
+ retval = EXT2_ET_CORRUPT_SUPERBLOCK;
+ goto cleanup;
+ }
fs->inode_blocks_per_group = ((EXT2_INODES_PER_GROUP(fs->super) *
EXT2_INODE_SIZE(fs->super) +
EXT2_BLOCK_SIZE(fs->super) - 1) /
goto cleanup;
#ifdef WORDS_BIGENDIAN
gdp = (struct ext2_group_desc *) dest;
- for (j=0; j < groups_per_block*first_meta_bg; j++)
- ext2fs_swap_group_desc(gdp++);
+ for (j=0; j < groups_per_block*first_meta_bg; j++) {
+ gdp = ext2fs_group_desc(fs, fs->group_desc, j);
+ ext2fs_swap_group_desc2(fs, gdp);
+ }
#endif
dest += fs->blocksize*first_meta_bg;
}
for (i=first_meta_bg ; i < fs->desc_blocks; i++) {
- blk = ext2fs_descriptor_block_loc(fs, group_block, i);
+ blk = ext2fs_descriptor_block_loc2(fs, group_block, i);
retval = io_channel_read_blk64(fs->io, blk, 1, dest);
if (retval)
goto cleanup;
#ifdef WORDS_BIGENDIAN
- gdp = (struct ext2_group_desc *) dest;
- for (j=0; j < groups_per_block; j++)
- ext2fs_swap_group_desc(gdp++);
+ for (j=0; j < groups_per_block; j++) {
+ /* The below happens to work... be careful. */
+ gdp = ext2fs_group_desc(fs, fs->group_desc, j);
+ ext2fs_swap_group_desc2(fs, gdp);
+ }
#endif
dest += fs->blocksize;
}
*/
if (superblock > 1 && EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
- struct ext2_group_desc *gd;
dgrp_t group;
for (group = 0; group < fs->group_desc_count; group++) {