From patchwork Fri Sep 4 13:24:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaolei X-Patchwork-Id: 7122741 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D8A289F32B for ; Fri, 4 Sep 2015 13:29:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 037302089C for ; Fri, 4 Sep 2015 13:29:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E1AC20840 for ; Fri, 4 Sep 2015 13:29:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759479AbbIDN1B (ORCPT ); Fri, 4 Sep 2015 09:27:01 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:27342 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S933091AbbIDNZ6 (ORCPT ); Fri, 4 Sep 2015 09:25:58 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100347661" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Sep 2015 21:28:59 +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 t84DPlIl030025 for ; Fri, 4 Sep 2015 21:25:47 +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:57 +0800 From: Zhao Lei To: CC: Zhao Lei Subject: [PATCH 2/5] btrfs-progs: Support extra-dev for btrfs rescue Date: Fri, 4 Sep 2015 21:24:16 +0800 Message-ID: <9f20c44c6272eda068105d5ac9ae98c5ee767fcf.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 Make following command support --extra-dev: btrfs rescue chunk-recover btrfs rescue super-recover btrfs rescue zero-log Signed-off-by: Zhao Lei --- cmds-rescue.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/cmds-rescue.c b/cmds-rescue.c index dd7c01e..163d0bb 100644 --- a/cmds-rescue.c +++ b/cmds-rescue.c @@ -37,9 +37,10 @@ const char * const cmd_rescue_chunk_recover_usage[] = { "btrfs rescue chunk-recover [options] ", "Recover the chunk tree by scanning the devices one by one.", "", - "-y Assume an answer of `yes' to all questions", - "-v Verbose mode", - "-h Help", + HELPINFO_EXTRA_DEV, + "-y Assume an answer of `yes' to all questions", + "-v Verbose mode", + "-h Help", NULL }; @@ -47,8 +48,9 @@ const char * const cmd_rescue_super_recover_usage[] = { "btrfs rescue super-recover [options] ", "Recover bad superblocks from good copies", "", - "-y Assume an answer of `yes' to all questions", - "-v Verbose mode", + HELPINFO_EXTRA_DEV, + "-y Assume an answer of `yes' to all questions", + "-v Verbose mode", NULL }; @@ -59,6 +61,9 @@ int cmd_rescue_chunk_recover(int argc, char *argv[]) int yes = 0; int verbose = 0; + if (set_extra_dev_from_arg(&argc, argv)) + usage(cmd_rescue_chunk_recover_usage); + while (1) { int c = getopt(argc, argv, "yvh"); if (c < 0) @@ -119,6 +124,9 @@ int cmd_rescue_super_recover(int argc, char **argv) int yes = 0; char *dname; + if (set_extra_dev_from_arg(&argc, argv)) + usage(cmd_rescue_super_recover_usage); + while (1) { int c = getopt(argc, argv, "vy"); if (c < 0) @@ -153,9 +161,10 @@ int cmd_rescue_super_recover(int argc, char **argv) } const char * const cmd_rescue_zero_log_usage[] = { - "btrfs rescue zero-log ", + "btrfs rescue zero-log [options] ", "Clear the tree log. Usable if it's corrupted and prevents mount.", "", + HELPINFO_EXTRA_DEV, NULL }; @@ -167,6 +176,9 @@ int cmd_rescue_zero_log(int argc, char **argv) char *devname; int ret; + if (set_extra_dev_from_arg(&argc, argv)) + usage(cmd_rescue_zero_log_usage); + if (check_argc_exact(argc, 2)) usage(cmd_rescue_zero_log_usage);