diff mbox

[1/5] mke2fs: enforce that the cluster size must be less that the block size

Message ID 1358210232-30578-1-git-send-email-tytso@mit.edu
State Accepted, archived
Headers show

Commit Message

Theodore Ts'o Jan. 15, 2013, 12:37 a.m. UTC
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>
Reported-by: Zheng Liu <wenqing.lz@taobao.com>
---
 misc/mke2fs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Theodore Ts'o Jan. 15, 2013, 12:41 a.m. UTC | #1
On Mon, Jan 14, 2013 at 07:37:08PM -0500, Theodore Ts'o wrote:
> +		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 must not be "
> +				  "smaller than the block size.\n"));

This would read better: "the cluster size may not be smaller than the
block size"

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zheng Liu Jan. 15, 2013, 3:22 p.m. UTC | #2
On Mon, Jan 14, 2013 at 07:41:58PM -0500, Theodore Ts'o wrote:
> On Mon, Jan 14, 2013 at 07:37:08PM -0500, Theodore Ts'o wrote:
> > +		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 must not be "
> > +				  "smaller than the block size.\n"));
> 
> This would read better: "the cluster size may not be smaller than the
> block size"
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Regards,
                                                - Zheng
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 4748f4a..75d0e48 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 must 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 "