From patchwork Tue Aug 2 15:42:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Tulak X-Patchwork-Id: 9258339 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 348F460865 for ; Tue, 2 Aug 2016 15:43:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25F1827FA2 for ; Tue, 2 Aug 2016 15:43:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B11B28570; Tue, 2 Aug 2016 15:43:31 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from oss.sgi.com (oss.sgi.com [192.48.182.195]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9640027FA2 for ; Tue, 2 Aug 2016 15:43:30 +0000 (UTC) Received: from oss.sgi.com (localhost [IPv6:::1]) by oss.sgi.com (Postfix) with ESMTP id 3DFEE7CD3; Tue, 2 Aug 2016 10:42:59 -0500 (CDT) X-Original-To: xfs@oss.sgi.com Delivered-To: xfs@oss.sgi.com Received: from relay.sgi.com (relay1.corp.sgi.com [137.38.102.111]) by oss.sgi.com (Postfix) with ESMTP id 560937CB5 for ; Tue, 2 Aug 2016 10:42:55 -0500 (CDT) Received: from cuda.sgi.com (cuda2.sgi.com [192.48.176.25]) by relay1.corp.sgi.com (Postfix) with ESMTP id 267248F8037 for ; Tue, 2 Aug 2016 08:42:55 -0700 (PDT) X-ASG-Debug-ID: 1470152573-0bf57b369e350270001-NocioJ Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by cuda.sgi.com with ESMTP id x2tvPwBHMky37wY5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 02 Aug 2016 08:42:53 -0700 (PDT) X-Barracuda-Envelope-From: jtulak@redhat.com X-Barracuda-Effective-Source-IP: mx1.redhat.com[209.132.183.28] X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-ASG-Whitelist: Client Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 1BFFE83F47 for ; Tue, 2 Aug 2016 15:42:53 +0000 (UTC) Received: from jtulak.brq.redhat.com (jtulak.brq.redhat.com [10.34.26.85]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u72FgjCt020921; Tue, 2 Aug 2016 11:42:52 -0400 From: Jan Tulak To: xfs@oss.sgi.com Subject: [PATCH 6/8] mkfs: add cross-section conflict checks Date: Tue, 2 Aug 2016 17:42:17 +0200 X-ASG-Orig-Subj: [PATCH 6/8] mkfs: add cross-section conflict checks Message-Id: <1470152539-18759-7-git-send-email-jtulak@redhat.com> In-Reply-To: <1470152539-18759-1-git-send-email-jtulak@redhat.com> References: <1470152539-18759-1-git-send-email-jtulak@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 02 Aug 2016 15:42:53 +0000 (UTC) X-Barracuda-Connect: mx1.redhat.com[209.132.183.28] X-Barracuda-Start-Time: 1470152573 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://192.48.176.25:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 2902 X-Virus-Scanned: by bsmtpd at sgi.com X-Barracuda-BRTS-Status: 1 Cc: Jan Tulak X-BeenThere: xfs@oss.sgi.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com 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 6f3f278..2eca989 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -728,6 +728,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))) @@ -1329,10 +1332,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); } } } @@ -1357,13 +1359,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); } } } @@ -3430,12 +3431,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(