Add support for creating and checking 8192-byte blocksize filesystems.
We complain if you try to create such a filesystem on a system with 4096
byte PAGE_SIZE.

Add checks for valid inode size for undocumented -I option.

diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 6a52024..9d04114 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -266,19 +266,17 @@
 	mtrace_print("Pass 1");
 #endif
 
-#define EXT2_BPP(bits) (1UL << ((bits) - 2))
+#define EXT2_BPP(bits) (1ULL << ((bits) - 2))
 
-	for (i=0; i < 4; i++) {
-		max_sizes = EXT2_NDIR_BLOCKS + EXT2_BPP(10+i);
-		max_sizes = max_sizes + EXT2_BPP(10+i) * EXT2_BPP(10+i);
-		max_sizes = (max_sizes +
-			     (__u64) EXT2_BPP(10+i) * EXT2_BPP(10+i) *
-			     EXT2_BPP(10+i));
-		max_sizes = (max_sizes * (1UL << (10+i))) - 1;
-		max_sect_limit = 512ULL * ((1LL << 32) - (1 << (i+1)));
+	for (i = EXT2_MIN_BLOCK_LOG_SIZE; i <= EXT2_MAX_BLOCK_LOG_SIZE; i++) {
+		max_sizes = EXT2_NDIR_BLOCKS + EXT2_BPP(i);
+		max_sizes = max_sizes + EXT2_BPP(i) * EXT2_BPP(i);
+		max_sizes = max_sizes + EXT2_BPP(i) * EXT2_BPP(i) * EXT2_BPP(i);
+		max_sizes = (max_sizes * (1UL << i)) - 1;
+		max_sect_limit = 512ULL * ((1LL << 32) - (1 << i));
 		if (max_sizes > max_sect_limit)
 			max_sizes = max_sect_limit;
-		ext2_max_sizes[i] = max_sizes;
+		ext2_max_sizes[i - 10] = max_sizes;
 	}
 #undef EXT2_BPP
 
@@ -451,11 +449,6 @@
 		} else if (ino == EXT2_JOURNAL_INO) {
 			ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino);
 			if (fs->super->s_journal_inum == EXT2_JOURNAL_INO) {
-				/*
-				 * XXX arguably this check should be
-				 * in journal.c, before we decide it's
-				 * safe to run the journal...
-				 */
 				if (!LINUX_S_ISREG(inode.i_mode) &&
 				    fix_problem(ctx, PR_1_JOURNAL_BAD_MODE,
 						&pctx)) {
diff --git a/e2fsck/super.c b/e2fsck/super.c
index df78469..e57fd8b 100644
--- a/e2fsck/super.c
+++ b/e2fsck/super.c
@@ -334,11 +334,10 @@
 			  MIN_CHECK, 1, 0);
 	check_super_value(ctx, "first_data_block", sb->s_first_data_block,
 			  MAX_CHECK, 0, sb->s_blocks_count);
-	check_super_value(ctx, "log_frag_size", sb->s_log_frag_size,
-			  MAX_CHECK, 0, 2);
 	check_super_value(ctx, "log_block_size", sb->s_log_block_size,
-			  MIN_CHECK | MAX_CHECK, sb->s_log_frag_size,
-			  2);
+			  MIN_CHECK | MAX_CHECK, 0, EXT2_MAX_BLOCK_LOG_SIZE);
+	check_super_value(ctx, "log_frag_size", sb->s_log_frag_size,
+			  MIN_CHECK | MAX_CHECK, 0, sb->s_log_block_size);
 	check_super_value(ctx, "frags_per_group", sb->s_frags_per_group,
 			  MIN_CHECK | MAX_CHECK, sb->s_blocks_per_group,
 			  8 * EXT2_BLOCK_SIZE(sb));
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index e424ac7..e231888 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -51,8 +51,6 @@
 static int replace_bad_blocks = 0;
 static char *bad_blocks_file = 0;
 
-static int possible_block_sizes[] = { 1024, 2048, 4096, 8192, 0};
-
 static int root_filesystem = 0;
 static int read_only_root = 0;
 
@@ -663,7 +661,6 @@
 {
 	errcode_t	retval = 0;
 	int		exit_value = FSCK_OK;
-	int		i;
 	ext2_filsys	fs = 0;
 	io_manager	io_ptr;
 	struct ext2_super_block *sb;
@@ -742,10 +739,11 @@
 				     ctx->superblock, ctx->blocksize,
 				     io_ptr, &fs);
 	} else if (ctx->superblock) {
-		for (i=0; possible_block_sizes[i]; i++) {
+		int blocksize;
+		for (blocksize = EXT2_MIN_BLOCK_SIZE;
+		     blocksize <= EXT2_MAX_BLOCK_SIZE; blocksize *= 2) {
 			retval = ext2fs_open(ctx->filesystem_name, flags,
-					     ctx->superblock,
-					     possible_block_sizes[i],
+					     ctx->superblock, blocksize,
 					     io_ptr, &fs);
 			if (!retval)
 				break;
diff --git a/e2fsck/util.c b/e2fsck/util.c
index 227e41d..19d4685 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -359,7 +359,8 @@
 		goto cleanup;
 	sb = (struct ext2_super_block *) buf;
 
-	for (blocksize=1024; blocksize <= 8192 ; blocksize = blocksize*2) {
+	for (blocksize = EXT2_MIN_BLOCK_SIZE;
+	     blocksize <= EXT2_MAX_BLOCK_SIZE ; blocksize *= 2) {
 		superblock = blocksize*8;
 		if (blocksize == 1024)
 			superblock++;