This patch converts blk_t type to __u64 when compiling code with
"_EXT4FS_" option.
Force the 64-bit feature when the filesystem is greater than 2**32 blocks.
Changes from the previous version:
- ask for confirmation before creating the ext4 filesystem
lib/ext2fs/ext2_fs.h | 3 ++-
lib/ext2fs/ext2fs.h | 15 +++++++++++----
misc/mke2fs.c | 14 +++++++++++++-
3 files changed, 26 insertions(+), 6 deletions(-)
Index: e2fsprogs-1.39-tyt3-v7/misc/mke2fs.c
===================================================================
--- e2fsprogs-1.39-tyt3-v7.orig/misc/mke2fs.c 2007-06-21 13:16:34.000000000 +0200
+++ e2fsprogs-1.39-tyt3-v7/misc/mke2fs.c 2007-06-21 13:16:47.000000000 +0200
@@ -1273,6 +1273,17 @@ static void PRS(int argc, char *argv[])
));
exit(1);
}
+ if (dev_size > ((unsigned) 1 << 31) &&
+ desc_size < EXT2_MIN_DESC_SIZE_64BIT) {
+ fprintf(stderr, _("\nWarning: "
+ "Filesystem greater than 2**32 blocks.\n"
+ "Force 64-bit incompatible feature ?\n\n"));
+ proceed_question();
+ fs_param.s_feature_incompat |=
+ EXT4_FEATURE_INCOMPAT_64BIT;
+ fs_param.s_desc_size =
+ EXT2_MIN_DESC_SIZE_64BIT;
+ }
EXT2_BLOCKS_COUNT_SET(&fs_param, dev_size);
if (sys_page_size > EXT2_BLOCK_SIZE(&fs_param))
fs_param.s_blocks_count &= ~((sys_page_size /
@@ -1445,7 +1456,8 @@ static void PRS(int argc, char *argv[])
fs_param.s_desc_size = EXT2_MIN_DESC_SIZE_64BIT;
}
- if (!force && EXT2_BLOCKS_COUNT(&fs_param) >= ((unsigned) 1 << 31)) {
+ if (!force && (fs_param.s_desc_size < EXT2_MIN_DESC_SIZE_64BIT)
+ && EXT2_BLOCKS_COUNT(&fs_param) >= ((unsigned) 1 << 31)) {
com_err(program_name, 0,
_("Filesystem too large. No more than 2**31-1 blocks\n"
"\t (8TB using a blocksize of 4k) are currently supported."));
Index: e2fsprogs-1.39-tyt3-v7/lib/ext2fs/ext2fs.h
===================================================================
--- e2fsprogs-1.39-tyt3-v7.orig/lib/ext2fs/ext2fs.h 2007-06-21 13:16:45.000000000 +0200
+++ e2fsprogs-1.39-tyt3-v7/lib/ext2fs/ext2fs.h 2007-06-21 13:16:47.000000000 +0200
@@ -73,7 +73,12 @@ extern "C" {
#endif /* EXT2_FLAT_INCLUDES */
typedef __u32 ext2_ino_t;
+#ifdef _EXT4FS_
+#define _EXT2_64BIT_BLK_T 1
+typedef __u64 blk_t;
+#else
typedef __u32 blk_t;
+#endif
typedef __u64 blk64_t;
typedef __u32 dgrp_t;
typedef __u32 ext2_off_t;
@@ -491,13 +496,15 @@ struct ext2fs_extent {
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
EXT2_FEATURE_INCOMPAT_META_BG|\
EXT3_FEATURE_INCOMPAT_RECOVER|\
- EXT3_FEATURE_INCOMPAT_EXTENTS)
+ EXT3_FEATURE_INCOMPAT_EXTENTS|\
+ EXT4_FEATURE_INCOMPAT_64BIT)
#else
#define EXT2_LIB_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE|\
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
EXT2_FEATURE_INCOMPAT_META_BG|\
EXT3_FEATURE_INCOMPAT_RECOVER|\
- EXT3_FEATURE_INCOMPAT_EXTENTS)
+ EXT3_FEATURE_INCOMPAT_EXTENTS|\
+ EXT4_FEATURE_INCOMPAT_64BIT)
#endif
#define EXT2_LIB_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
EXT2_FEATURE_RO_COMPAT_LARGE_FILE)
@@ -1263,7 +1270,7 @@ _INLINE_ int ext2fs_group_of_ino(ext2_fi
_INLINE_ blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group)
{
return fs->super->s_first_data_block +
- (group * fs->super->s_blocks_per_group);
+ (group * (blk_t) EXT2_BLOCKS_PER_GROUP(fs->super));
}
/*
@@ -1274,7 +1281,7 @@ _INLINE_ blk_t ext2fs_group_last_block(e
return (group == fs->group_desc_count - 1 ?
EXT2_BLOCKS_COUNT(fs->super) - 1 :
ext2fs_group_first_block(fs, group) +
- (fs->super->s_blocks_per_group - 1));
+ (EXT2_BLOCKS_PER_GROUP(fs->super) - 1));
}
_INLINE_ blk_t ext2fs_inode_data_blocks(ext2_filsys fs,
Index: e2fsprogs-1.39-tyt3-v7/lib/ext2fs/ext2_fs.h
===================================================================
--- e2fsprogs-1.39-tyt3-v7.orig/lib/ext2fs/ext2_fs.h 2007-06-21 13:15:40.000000000 +0200
+++ e2fsprogs-1.39-tyt3-v7/lib/ext2fs/ext2_fs.h 2007-06-21 13:16:47.000000000 +0200
@@ -678,7 +678,8 @@ struct ext2_super_block {
#define EXT2_FEATURE_COMPAT_SUPP 0
-#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE)
+#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
+ EXT4_FEATURE_INCOMPAT_64BIT)
#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
EXT2_FEATURE_RO_COMPAT_BTREE_DIR)