From patchwork Wed Mar 15 16:00:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Tulak X-Patchwork-Id: 9626049 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 0A58660522 for ; Wed, 15 Mar 2017 16:02:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1E1228452 for ; Wed, 15 Mar 2017 16:02:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E69D2285FF; 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 917F0285ED for ; Wed, 15 Mar 2017 16:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754122AbdCOQCN (ORCPT ); Wed, 15 Mar 2017 12:02:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34466 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754118AbdCOQAv (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 1D2CA7E9C0 for ; Wed, 15 Mar 2017 16:00:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1D2CA7E9C0 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jtulak@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1D2CA7E9C0 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 v2FG0b8Q031509; Wed, 15 Mar 2017 12:00:45 -0400 From: Jan Tulak To: linux-xfs@vger.kernel.org Cc: Jan Tulak Subject: [PATCH 06/22] mkfs: add cross-section conflict checks Date: Wed, 15 Mar 2017 17:00:01 +0100 Message-Id: <20170315160017.27805-7-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.26]); Wed, 15 Mar 2017 16:00:46 +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 Checks are modified to work with cross-section conflicts (data, metada, log, ...). Signed-off-by: Jan Tulak --- mkfs/xfs_mkfs.c | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 7e0a4159..0877c196 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -744,6 +744,9 @@ struct opt_params { }, }; +static void conflict_struct(struct opt_params *opt, struct subopt_param *subopt, + struct subopt_conflict *conflict); + #define TERABYTES(count, blog) ((__uint64_t)(count) << (40 - (blog))) #define GIGABYTES(count, blog) ((__uint64_t)(count) << (30 - (blog))) #define MEGABYTES(count, blog) ((__uint64_t)(count) << (20 - (blog))) @@ -1351,10 +1354,9 @@ check_opt( break; if (conflict_opt.test_values) break; - if (opt->subopt_params[conflict_opt.subopt].seen || - opt->subopt_params[conflict_opt.subopt].str_seen) { - conflict(opt->name, (char **)opt->subopts, - conflict_opt.subopt, index); + if (opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].seen || + opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].str_seen) { + conflict_struct(opt, sp, &conflict_opt); } } } @@ -1379,13 +1381,12 @@ check_opt_value( break; if (!conflict_opt.test_values) break; - if ((opt->subopt_params[conflict_opt.subopt].seen || - opt->subopt_params[conflict_opt.subopt].str_seen) && - opt->subopt_params[conflict_opt.subopt].value + if ((opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].seen || + opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].str_seen) && + opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].value == conflict_opt.invalid_value && value == conflict_opt.at_value) { - conflict(opt->name, (char **)opt->subopts, - conflict_opt.subopt, index); + conflict_struct(opt, sp, &conflict_opt); } } } @@ -3586,12 +3587,36 @@ conflict( char *tab[], int oldidx, int newidx) + { fprintf(stderr, _("Cannot specify both -%c %s and -%c %s\n"), opt, tab[oldidx], opt, tab[newidx]); usage(); } +static void +conflict_struct( + struct opt_params *opt, + struct subopt_param *subopt, + struct subopt_conflict *conflict) +{ + if(conflict->message) { + fprintf(stderr, _("Cannot specify both -%c %s and -%c %s: %s\n"), + opt->name, + opt->subopts[subopt->index], + opts[conflict->opt].name, + opts[conflict->opt].subopts[conflict->subopt], + _(conflict->message)); + } else { + fprintf(stderr, _("Cannot specify both -%c %s and -%c %s\n"), + opt->name, + opt->subopts[subopt->index], + opts[conflict->opt].name, + opts[conflict->opt].subopts[conflict->subopt]); + } + usage(); +} + static void illegal(