From patchwork Tue Jan 15 00:37:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 211961 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id EC5272C0099 for ; Tue, 15 Jan 2013 11:37:22 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756771Ab3AOAhV (ORCPT ); Mon, 14 Jan 2013 19:37:21 -0500 Received: from li9-11.members.linode.com ([67.18.176.11]:43389 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756764Ab3AOAhT (ORCPT ); Mon, 14 Jan 2013 19:37:19 -0500 Received: from root (helo=closure.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.80) (envelope-from ) id 1TuuWf-0008CO-Gp; Tue, 15 Jan 2013 00:37:13 +0000 Received: by closure.thunk.org (Postfix, from userid 15806) id 311382E9870; Mon, 14 Jan 2013 19:37:12 -0500 (EST) From: Theodore Ts'o To: Ext4 Developers List Cc: gnehzuil.liu@gmail.com, Theodore Ts'o Subject: [PATCH 1/5] mke2fs: enforce that the cluster size must be less that the block size Date: Mon, 14 Jan 2013 19:37:08 -0500 Message-Id: <1358210232-30578-1-git-send-email-tytso@mit.edu> X-Mailer: git-send-email 1.7.12.rc0.22.gcdd159b In-Reply-To: <20130114211014.GA22642@thunk.org> References: <20130114211014.GA22642@thunk.org> X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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" Reported-by: Zheng Liu Reviewed-by: Zheng Liu --- misc/mke2fs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 "