From patchwork Thu Jun 18 22:07:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 6641211 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 DCEE1C0020 for ; Thu, 18 Jun 2015 22:08:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0064120897 for ; Thu, 18 Jun 2015 22:08:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02C5720896 for ; Thu, 18 Jun 2015 22:08:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752147AbbFRWHU (ORCPT ); Thu, 18 Jun 2015 18:07:20 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:35992 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751526AbbFRWHS (ORCPT ); Thu, 18 Jun 2015 18:07:18 -0400 Received: from pps.filterd (m0004003 [127.0.0.1]) by mx0b-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id t5IM4XG1023397 for ; Thu, 18 Jun 2015 15:07:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=KCHdAJ+w9+uCy/JOORcHPXNNgrov30PoG9lVhgIdrEQ=; b=NrJ6U0FNLQ+s/KauSuP90LIOjBBgkorGFBJIpHWzPN6zN5iINieVXaYerDnkv4BwYIbH feDHwTlcJ5DiDXrz+kawT9+P/iAatIzAxhKwrEt8DC7ZKu8QbBNjigd3lo+2/lL40jUV To+5efBBJQPhbjuopTOBOxeLNoQxDTQaZkc= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 1v43sa0ptr-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Thu, 18 Jun 2015 15:07:17 -0700 Received: from huxley.thefacebook.com (192.168.52.123) by mail.thefacebook.com (192.168.16.12) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 18 Jun 2015 15:07:15 -0700 From: Omar Sandoval To: CC: Omar Sandoval Subject: [PATCH] btrfs-progs: alias btrfs device delete to btrfs device remove Date: Thu, 18 Jun 2015 15:07:09 -0700 Message-ID: <83c7d294299d9b66238f7369b1171c24d35b9294.1434508872.git.osandov@fb.com> X-Mailer: git-send-email 2.4.4 MIME-Version: 1.0 X-Originating-IP: [192.168.52.123] 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-18_05:2015-06-18, 2015-06-18, 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=-7.1 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 | 33 +++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 7 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..0e1ea94a0e41 100644 --- a/cmds-device.c +++ b/cmds-device.c @@ -145,20 +145,17 @@ error_out: } static const char * const cmd_rm_dev_usage[] = { - "btrfs device delete [...] ", + "btrfs device remove [...] ", "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) { char *mntpnt; int i, fdmnt, ret=0, e; DIR *dirstream = NULL; - if (check_argc_min(argc, 3)) - usage(cmd_rm_dev_usage); - mntpnt = argv[argc - 1]; fdmnt = open_file_or_dir(mntpnt, &dirstream); @@ -198,6 +195,29 @@ static int cmd_rm_dev(int argc, char **argv) return !!ret; } +static int cmd_rm_dev(int argc, char **argv) +{ + if (check_argc_min(argc, 3)) + usage(cmd_rm_dev_usage); + + return _cmd_rm_dev(argc, argv); +} + + +static const char * const cmd_del_dev_usage[] = { + "btrfs device delete [...] ", + "Remove a device from a filesystem (alias of remove)", + NULL +}; + +static int cmd_del_dev(int argc, char **argv) +{ + if (check_argc_min(argc, 3)) + usage(cmd_del_dev_usage); + + return _cmd_rm_dev(argc, argv); +} + static const char * const cmd_scan_dev_usage[] = { "btrfs device scan [(-d|--all-devices)| [...]]", "Scan devices for a btrfs filesystem", @@ -586,12 +606,13 @@ 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 }, + { "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 }, { "usage", cmd_device_usage, cmd_device_usage_usage, NULL, 0 }, + { "delete", cmd_del_dev, cmd_del_dev_usage, NULL, 0 }, NULL_CMD_STRUCT } };