From patchwork Thu Aug 27 13:38:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaolei X-Patchwork-Id: 7084921 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D32E8BEEC1 for ; Thu, 27 Aug 2015 13:40:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E46E62099E for ; Thu, 27 Aug 2015 13:40:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F212B20992 for ; Thu, 27 Aug 2015 13:40:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753972AbbH0NkH (ORCPT ); Thu, 27 Aug 2015 09:40:07 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:12676 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753928AbbH0NkG (ORCPT ); Thu, 27 Aug 2015 09:40:06 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100088047" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 27 Aug 2015 21:43:10 +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 t7RDdtwN017143 for ; Thu, 27 Aug 2015 21:39:55 +0800 Received: from localhost.localdomain (10.167.226.114) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Thu, 27 Aug 2015 21:40:01 +0800 From: Zhao Lei To: CC: Zhao Lei Subject: [PATCH 4/4] btrfs-progs: Use common unit parser for btrfs qgroup command Date: Thu, 27 Aug 2015 21:38:23 +0800 Message-ID: <1f2c153decea79eaa0b4b503020d12532e4e1e66.1440682373.git.zhaolei@cn.fujitsu.com> X-Mailer: git-send-email 1.8.5.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.3 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 Move to use get_unit_mode_from_arg() for btrfs qgroup command, to make "btrfs qgroup show"'s unit argument same with other tools. Signed-off-by: Zhao Lei --- cmds-qgroup.c | 47 ++++------------------------------------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/cmds-qgroup.c b/cmds-qgroup.c index d58df5e..1505c03 100644 --- a/cmds-qgroup.c +++ b/cmds-qgroup.c @@ -275,15 +275,7 @@ static const char * const cmd_qgroup_show_usage[] = { " (including ancestral qgroups)", "-f list all qgroups which impact the given path", " (excluding ancestral qgroups)", - "--raw raw numbers in bytes", - "--human-readable", - " human firendly numbers in given base, 1024 by default", - "--iec use 1024 as a base (KiB, MiB, GiB, TiB)", - "--si use 1000 as a base (kB, MB, GB, TB)", - "--kbytes show sizes in KiB, or kB with --si", - "--mbytes show sizes in MiB, or MB with --si", - "--gbytes show sizes in GiB, or GB with --si", - "--tbytes show sizes in TiB, or TB with --si", + HELPINFO_OUTPUT_UNIT, "--sort=qgroupid,rfer,excl,max_rfer,max_excl", " list qgroups sorted by specified items", " you can use '+' or '-' in front of each item.", @@ -300,27 +292,20 @@ static int cmd_qgroup_show(int argc, char **argv) DIR *dirstream = NULL; u64 qgroupid; int filter_flag = 0; - unsigned unit_mode = UNITS_DEFAULT; + unsigned unit_mode; struct btrfs_qgroup_comparer_set *comparer_set; struct btrfs_qgroup_filter_set *filter_set; filter_set = btrfs_qgroup_alloc_filter_set(); comparer_set = btrfs_qgroup_alloc_comparer_set(); + unit_mode = get_unit_mode_from_arg(&argc, argv); + optind = 1; while (1) { int c; static const struct option long_options[] = { {"sort", required_argument, NULL, 'S'}, - {"raw", no_argument, NULL, GETOPT_VAL_RAW}, - {"kbytes", no_argument, NULL, GETOPT_VAL_KBYTES}, - {"mbytes", no_argument, NULL, GETOPT_VAL_MBYTES}, - {"gbytes", no_argument, NULL, GETOPT_VAL_GBYTES}, - {"tbytes", no_argument, NULL, GETOPT_VAL_TBYTES}, - {"si", no_argument, NULL, GETOPT_VAL_SI}, - {"iec", no_argument, NULL, GETOPT_VAL_IEC}, - { "human-readable", no_argument, NULL, - GETOPT_VAL_HUMAN_READABLE}, { NULL, 0, NULL, 0 } }; @@ -356,30 +341,6 @@ static int cmd_qgroup_show(int argc, char **argv) if (ret) usage(cmd_qgroup_show_usage); break; - case GETOPT_VAL_RAW: - unit_mode = UNITS_RAW; - break; - case GETOPT_VAL_KBYTES: - units_set_base(&unit_mode, UNITS_KBYTES); - break; - case GETOPT_VAL_MBYTES: - units_set_base(&unit_mode, UNITS_MBYTES); - break; - case GETOPT_VAL_GBYTES: - units_set_base(&unit_mode, UNITS_GBYTES); - break; - case GETOPT_VAL_TBYTES: - units_set_base(&unit_mode, UNITS_TBYTES); - break; - case GETOPT_VAL_SI: - units_set_mode(&unit_mode, UNITS_DECIMAL); - break; - case GETOPT_VAL_IEC: - units_set_mode(&unit_mode, UNITS_BINARY); - break; - case GETOPT_VAL_HUMAN_READABLE: - unit_mode = UNITS_HUMAN_BINARY; - break; default: usage(cmd_qgroup_show_usage); }