From 5dcc3266d46ee3846bd8707c7b99bd312fe2276b Mon Sep 17 00:00:00 2001
From: "Yury V. Zaytsev" <yury@shurup.com>
Date: Wed, 8 Jun 2011 11:12:54 +0200
Subject: [PATCH] mke2fs: check that auto-detected blocksize <= sys_page_size
Block size can be specified manually via the -b option or deduced
automatically. Unfortunately, the check that it is still smaller than
the system page size is only performed right after the command line
options were parsed.
Therefore, if buggy or inappropriately installed/configured hardware
hints that larger block sizes have to be used, mkfs will silently create
a file system which can not be mounted on the system in question.
By moving the check beyond the last assignment to blocksize it is now
ensured, that mkfs will issue a warning even if inappropriate blocksize
was auto-detected.
The new behavior can be easily tested, by exporting the following
variables before running mkfs:
export MKE2FS_DEVICE_SECTSIZE=8912
export MKE2FS_DEVICE_PHYS_SECTSIZE=8912
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
---
misc/mke2fs.c | 24 +++++++++++++-----------
1 files changed, 13 insertions(+), 11 deletions(-)
@@ -1526,17 +1526,6 @@ static void PRS(int argc, char *argv[])
ext2fs_close(jfs);
}
- if (blocksize > sys_page_size) {
- if (!force) {
- com_err(program_name, 0,
- _("%d-byte blocks too big for system (max %d)"),
- blocksize, sys_page_size);
- proceed_question();
- }
- fprintf(stderr, _("Warning: %d-byte blocks too big for system "
- "(max %d), forced to continue\n"),
- blocksize, sys_page_size);
- }
if (optind < argc) {
fs_param.s_blocks_count = parse_num_blocks(argv[optind++],
fs_param.s_log_block_size);
@@ -1811,6 +1800,19 @@ got_size:
blocksize = EXT2_BLOCK_SIZE(&fs_param);
+ /* This check should happen beyond the last assignment to blocksize */
+ if (blocksize > sys_page_size) {
+ if (!force) {
+ com_err(program_name, 0,
+ _("%d-byte blocks too big for system (max %d)"),
+ blocksize, sys_page_size);
+ proceed_question();
+ }
+ fprintf(stderr, _("Warning: %d-byte blocks too big for system "
+ "(max %d), forced to continue\n"),
+ blocksize, sys_page_size);
+ }
+
lazy_itable_init = 0;
if (access("/sys/fs/ext4/features/lazy_itable_init", R_OK) == 0)
lazy_itable_init = 1;
--
1.7.5.4