aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2013-01-14 17:28:00 -0500
committerTheodore Ts'o <tytso@mit.edu>2013-01-15 14:03:53 -0500
commit4b20ea2691b3408340036d16e62867d5c52078e3 (patch)
treef03a479d36eb1cba32662ef88398c7a7a465d772
parent9cf69bb825c2995352502f48ea64d1be1d263995 (diff)
downloade2fsprogs-4b20ea2691b3408340036d16e62867d5c52078e3.tar.gz
e2fsprogs-4b20ea2691b3408340036d16e62867d5c52078e3.tar.xz
e2fsprogs-4b20ea2691b3408340036d16e62867d5c52078e3.zip
mke2fs: enforce that the cluster size must be greater that the block size
In addition, do not allow a cluster size of 1024, since that will be interpreted by ext2fs_initialize() as requesting the default cluster size. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Reviewed-by: Zheng Liu <wenqing.lz@taobao.com> Reported-by: Zheng Liu <wenqing.lz@taobao.com>
-rw-r--r--misc/mke2fs.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 4748f4ab..98c2035f 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1346,7 +1346,7 @@ profile_error:
break;
case 'C':
cluster_size = strtoul(optarg, &tmp, 0);
- if (cluster_size < EXT2_MIN_CLUSTER_SIZE ||
+ if (cluster_size <= EXT2_MIN_CLUSTER_SIZE ||
cluster_size > EXT2_MAX_CLUSTER_SIZE || *tmp) {
com_err(program_name, 0,
_("invalid cluster size - %s"),
@@ -1847,6 +1847,13 @@ profile_error:
blocksize*16);
fs_param.s_log_cluster_size =
int_log2(cluster_size >> EXT2_MIN_CLUSTER_LOG_SIZE);
+ if (fs_param.s_log_cluster_size &&
+ fs_param.s_log_cluster_size < fs_param.s_log_block_size) {
+ com_err(program_name, 0,
+ _("The cluster size may not be "
+ "smaller than the block size.\n"));
+ exit(1);
+ }
} else if (cluster_size) {
com_err(program_name, 0,
_("specifying a cluster size requires the "