From patchwork Thu Sep 11 05:19:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Hecheng X-Patchwork-Id: 4882081 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 996229F32F for ; Thu, 11 Sep 2014 05:23:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D2B3201EF for ; Thu, 11 Sep 2014 05:23:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8EC87201EC for ; Thu, 11 Sep 2014 05:23:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752159AbaIKFW6 (ORCPT ); Thu, 11 Sep 2014 01:22:58 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:32684 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752042AbaIKFW5 (ORCPT ); Thu, 11 Sep 2014 01:22:57 -0400 X-IronPort-AV: E=Sophos;i="5.04,504,1406563200"; d="scan'208";a="35792445" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 11 Sep 2014 13:19:58 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s8B5N3mI015964 for ; Thu, 11 Sep 2014 13:23:03 +0800 Received: from localhost.localdomain (10.167.226.111) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 11 Sep 2014 13:23:02 +0800 From: Gui Hecheng To: CC: Gui Hecheng Subject: [PATCH] btrfs-progs: deal with conflict options for btrfs fi show Date: Thu, 11 Sep 2014 13:19:11 +0800 Message-ID: <1410412751-9277-1-git-send-email-guihc.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.1.4 MIME-Version: 1.0 X-Originating-IP: [10.167.226.111] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For btrfs fi show, -d|--all-devices & -m|--mounted will overwrite each other, so if specified both, let the user know that he should not use them at the same time. Signed-off-by: Gui Hecheng --- cmds-filesystem.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmds-filesystem.c b/cmds-filesystem.c index 69c1ca5..78aeacc 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -526,16 +526,23 @@ static int cmd_show(int argc, char **argv) break; switch (c) { case 'd': - where = BTRFS_SCAN_PROC; + where &= ~BTRFS_SCAN_LBLKID; + where |= BTRFS_SCAN_PROC; break; case 'm': - where = BTRFS_SCAN_MOUNTED; + where &= ~BTRFS_SCAN_LBLKID; + where |= BTRFS_SCAN_MOUNTED; break; default: usage(cmd_show_usage); } } + if ((where & BTRFS_SCAN_PROC) && (where & BTRFS_SCAN_MOUNTED)) { + fprintf(stderr, "don't use -d|--all-devices and -m|--mounted options at the same time\n"); + usage(cmd_show_usage); + } + if (check_argc_max(argc, optind + 1)) usage(cmd_show_usage);