From patchwork Fri Sep 4 13:24:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaolei X-Patchwork-Id: 7122721 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 B0965BEEC1 for ; Fri, 4 Sep 2015 13:28:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D65C62089D for ; Fri, 4 Sep 2015 13:28:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08A4F20841 for ; Fri, 4 Sep 2015 13:28:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759223AbbIDN07 (ORCPT ); Fri, 4 Sep 2015 09:26:59 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:33156 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S933100AbbIDN0B (ORCPT ); Fri, 4 Sep 2015 09:26:01 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100347668" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Sep 2015 21:29:00 +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 t84DPmSc030032 for ; Fri, 4 Sep 2015 21:25:48 +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; Fri, 4 Sep 2015 21:25:58 +0800 From: Zhao Lei To: CC: Zhao Lei Subject: [PATCH 4/5] btrfs-progs: add help command to btrfs rescue zero-log Date: Fri, 4 Sep 2015 21:24:18 +0800 Message-ID: <7902fde708c717f3cc963240a9b02f0f6aa6d542.1441357933.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=-6.9 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 To make it unified with other two rescue command, which support --help option. Signed-off-by: Zhao Lei --- cmds-rescue.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cmds-rescue.c b/cmds-rescue.c index a709e1b..3ed63f6 100644 --- a/cmds-rescue.c +++ b/cmds-rescue.c @@ -165,6 +165,7 @@ const char * const cmd_rescue_zero_log_usage[] = { "Clear the tree log. Usable if it's corrupted and prevents mount.", "", HELPINFO_EXTRA_DEV, + "-h Help", NULL }; @@ -179,10 +180,22 @@ int cmd_rescue_zero_log(int argc, char **argv) if (set_extra_dev_from_arg(&argc, argv)) usage(cmd_rescue_zero_log_usage); - if (check_argc_exact(argc, 2)) + while (1) { + int c = getopt(argc, argv, "h"); + + if (c < 0) + break; + switch (c) { + case 'h': + default: + usage(cmd_rescue_zero_log_usage); + } + } + + if (check_argc_exact(argc - optind, 1)) usage(cmd_rescue_zero_log_usage); - devname = argv[1]; + devname = argv[optind]; ret = check_mounted(devname); if (ret < 0) { fprintf(stderr, "Could not check mount status: %s\n", strerror(-ret));