From patchwork Wed Jun 24 16:09:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 6668991 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 BE5B99F399 for ; Wed, 24 Jun 2015 16:11:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C3F702058C for ; Wed, 24 Jun 2015 16:11:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C31F420595 for ; Wed, 24 Jun 2015 16:11:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753298AbbFXQJz (ORCPT ); Wed, 24 Jun 2015 12:09:55 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:55606 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753240AbbFXQJw (ORCPT ); Wed, 24 Jun 2015 12:09:52 -0400 Received: from pps.filterd (m0004348 [127.0.0.1]) by m0004348.ppops.net (8.14.5/8.14.5) with SMTP id t5OG8lqA010497 for ; Wed, 24 Jun 2015 09:09:52 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=URZ2TwNOj8zu/Hp2DoE+EcWyAxRmTQX4sXikJL9nTwU=; b=kzrVjz5KmuMtIXw6kfSzYvakqLw0pIksiIVwmvNXh33AVLlgG8qXK4ohDxRP84apYKp/ V0BDCi3VoXsBCl3kZOYesczzWwtVeoFF/2dJ6jwv94fgFVWINxec6gW26QlCIpg0u1Ff nAPEhkfHitrPYoVGKAP7KwG0BIs2gZ0zGYY= Received: from mail.thefacebook.com ([199.201.64.23]) by m0004348.ppops.net with ESMTP id 1v7vwk0b4h-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Wed, 24 Jun 2015 09:09:52 -0700 Received: from huxley.localdomain (192.168.54.13) by mail.TheFacebook.com (192.168.16.17) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 24 Jun 2015 09:09:51 -0700 From: Omar Sandoval To: CC: Omar Sandoval Subject: [PATCH 2/2] btrfs-progs: alias btrfs device delete to btrfs device remove Date: Wed, 24 Jun 2015 09:09:17 -0700 Message-ID: <4987361b608f2ff84d7c525afe859e5675fdfe85.1435161735.git.osandov@fb.com> X-Mailer: git-send-email 2.4.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [192.168.54.13] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.14.151, 1.0.33, 0.0.0000 definitions=2015-06-24_06:2015-06-23, 2015-06-24, 1970-01-01 signatures=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.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 There's an awkward asymmetry between btrfs device add and btrfs device delete. Resolve this by aliasing delete to remove. Signed-off-by: Omar Sandoval --- Documentation/btrfs-device.asciidoc | 5 ++++- cmds-device.c | 35 ++++++++++++++++++++++++++--------- commands.h | 1 + help.c | 10 ++++++---- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/Documentation/btrfs-device.asciidoc b/Documentation/btrfs-device.asciidoc index c56cf5ef48fb..2827598a37f5 100644 --- a/Documentation/btrfs-device.asciidoc +++ b/Documentation/btrfs-device.asciidoc @@ -74,9 +74,12 @@ do not perform discard by default -f|--force:::: force overwrite of existing filesystem on the given disk(s) -*delete* [...] :: +*remove* [...] :: Remove device(s) from a filesystem identified by . +*delete* [...] :: +Alias of remove kept for backwards compatability + *ready* :: Check device to see if it has all of it's devices in cache for mounting. diff --git a/cmds-device.c b/cmds-device.c index 1022656988c2..6972156fdf70 100644 --- a/cmds-device.c +++ b/cmds-device.c @@ -144,20 +144,14 @@ error_out: return !!ret; } -static const char * const cmd_rm_dev_usage[] = { - "btrfs device delete [...] ", - "Remove a device from a filesystem", - NULL -}; - -static int cmd_rm_dev(int argc, char **argv) +static int _cmd_rm_dev(int argc, char **argv, const char * const *usagestr) { char *mntpnt; int i, fdmnt, ret=0, e; DIR *dirstream = NULL; if (check_argc_min(argc, 3)) - usage(cmd_rm_dev_usage); + usage(usagestr); mntpnt = argv[argc - 1]; @@ -198,6 +192,28 @@ static int cmd_rm_dev(int argc, char **argv) return !!ret; } +static const char * const cmd_rm_dev_usage[] = { + "btrfs device remove [...] ", + "Remove a device from a filesystem", + NULL +}; + +static int cmd_rm_dev(int argc, char **argv) +{ + return _cmd_rm_dev(argc, argv, cmd_rm_dev_usage); +} + +static const char * const cmd_del_dev_usage[] = { + "btrfs device delete [...] ", + "Remove a device from a filesystem", + NULL +}; + +static int cmd_del_dev(int argc, char **argv) +{ + return _cmd_rm_dev(argc, argv, cmd_del_dev_usage); +} + static const char * const cmd_scan_dev_usage[] = { "btrfs device scan [(-d|--all-devices)| [...]]", "Scan devices for a btrfs filesystem", @@ -586,7 +602,8 @@ out: const struct cmd_group device_cmd_group = { device_cmd_group_usage, NULL, { { "add", cmd_add_dev, cmd_add_dev_usage, NULL, 0 }, - { "delete", cmd_rm_dev, cmd_rm_dev_usage, NULL, 0 }, + { "delete", cmd_del_dev, cmd_del_dev_usage, NULL, CMD_ALIAS }, + { "remove", cmd_rm_dev, cmd_rm_dev_usage, NULL, 0 }, { "scan", cmd_scan_dev, cmd_scan_dev_usage, NULL, 0 }, { "ready", cmd_ready_dev, cmd_ready_dev_usage, NULL, 0 }, { "stats", cmd_dev_stats, cmd_dev_stats_usage, NULL, 0 }, diff --git a/commands.h b/commands.h index 42d31781f1a3..90bbd05a3542 100644 --- a/commands.h +++ b/commands.h @@ -19,6 +19,7 @@ enum { CMD_HIDDEN = (1 << 0), /* should not be in help listings */ + CMD_ALIAS = (1 << 1), /* alias of next command in cmd_group */ }; struct cmd_struct { diff --git a/help.c b/help.c index 34754c16e6fe..6ecf01d57b83 100644 --- a/help.c +++ b/help.c @@ -81,11 +81,13 @@ static int do_usage_one_command(const char * const *usagestr, static int usage_command_internal(const char * const *usagestr, const char *token, int full, int lst, - FILE *outf) + int alias, FILE *outf) { - unsigned int flags = USAGE_SHORT; + unsigned int flags = 0; int ret; + if (!alias) + flags |= USAGE_SHORT; if (full) flags |= USAGE_LONG | USAGE_OPTIONS; if (lst) @@ -110,7 +112,7 @@ static void usage_command_usagestr(const char * const *usagestr, FILE *outf = err ? stderr : stdout; int ret; - ret = usage_command_internal(usagestr, token, full, 0, outf); + ret = usage_command_internal(usagestr, token, full, 0, 0, outf); if (!ret) fputc('\n', outf); } @@ -146,7 +148,7 @@ static void usage_command_group_internal(const struct cmd_group *grp, int full, } usage_command_internal(cmd->usagestr, cmd->token, full, - 1, outf); + 1, cmd->flags & CMD_ALIAS, outf); continue; }