From patchwork Wed Mar 15 16:00:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Tulak X-Patchwork-Id: 9626047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B051E604CC for ; Wed, 15 Mar 2017 16:02:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3F9F28452 for ; Wed, 15 Mar 2017 16:02:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98FCC285FF; Wed, 15 Mar 2017 16:02:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3ED0028452 for ; Wed, 15 Mar 2017 16:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754121AbdCOQCM (ORCPT ); Wed, 15 Mar 2017 12:02:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35716 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754124AbdCOQAv (ORCPT ); Wed, 15 Mar 2017 12:00:51 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 53F60C057FA6 for ; Wed, 15 Mar 2017 16:00:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 53F60C057FA6 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jtulak@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 53F60C057FA6 Received: from honza-mbp.redhat.com (ovpn-204-198.brq.redhat.com [10.40.204.198]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2FG0b8T031509; Wed, 15 Mar 2017 12:00:48 -0400 From: Jan Tulak To: linux-xfs@vger.kernel.org Cc: Jan Tulak Subject: [PATCH 09/22] mkfs: change conflict checks to utilize the new conflict structure Date: Wed, 15 Mar 2017 17:00:04 +0100 Message-Id: <20170315160017.27805-10-jtulak@redhat.com> In-Reply-To: <20170315160017.27805-1-jtulak@redhat.com> References: <20170315160017.27805-1-jtulak@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 15 Mar 2017 16:00:49 +0000 (UTC) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Bring the conflicts detection up to date with conflicts declaration. Signed-off-by: Jan Tulak --- v2: A call rename was fixed from check_subopt to check_subopt_conflicts --- mkfs/xfs_mkfs.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index c100fef9..c3ab9221 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -1372,7 +1372,7 @@ illegal_option( * Check for conflicts and option respecification. */ static void -check_opt( +check_subopt_conflicts( struct opt_params *opt, int index, bool str_seen) @@ -1424,7 +1424,7 @@ check_opt( * Check for conflict values between options. */ static void -check_opt_value( +check_subopt_value( struct opt_params *opt, int index, long long value) @@ -1450,6 +1450,32 @@ check_opt_value( } } +/** + * Go through entire opt_params table and check every option for valid values + * and for conflicts. + */ +static void +check_opt( + struct opt_params *opts, + int opti) +{ + int index; + struct opt_params *opt = &opts[opti]; + for (index = 0; index < MAX_SUBOPTS; index++) { + struct subopt_param *sp = &opt->subopt_params[index]; + check_subopt_conflicts(opt, index, false); + check_subopt_value(opt, index, sp->value); + } +} +static void +check_all_opts(struct opt_params *opts) +{ + int opti; + for (opti = 0; opti < MAX_OPTS; opti++) { + check_opt(opts, opti); + } +} + static long long getnum( const char *str, @@ -1459,7 +1485,6 @@ getnum( struct subopt_param *sp = &opts->subopt_params[index]; long long c; - check_opt(opts, index, false); /* empty strings might just return a default value */ if (!str || *str == '\0') { if (sp->defaultval == SUBOPT_NEEDS_VAL) @@ -1493,8 +1518,6 @@ getnum( illegal_option(str, opts, index, NULL); } - check_opt_value(opts, index, c); - /* Validity check the result. */ if (c < sp->minval) illegal_option(str, opts, index, _("value is too small")); @@ -1517,7 +1540,7 @@ getstr( struct opt_params *opts, int index) { - check_opt(opts, index, true); + check_subopt_conflicts(opts, index, true); /* empty strings for string options are not valid */ if (!str || *str == '\0') @@ -2213,6 +2236,8 @@ main( } else dfile = xi.dname; + check_all_opts(opts); + /* * Blocksize and sectorsize first, other things depend on them * For RAID4/5/6 we want to align sector size and block size,