summaryrefslogtreecommitdiff
path: root/cmds-device.c
diff options
context:
space:
mode:
authorOmar Sandoval <osandov@fb.com>2015-06-24 09:09:17 -0700
committerDavid Sterba <dsterba@suse.cz>2015-06-26 16:33:39 +0200
commitf802f572b1cb1d33bab9747e87e6506b284546cf (patch)
treee8763c099809f0eb6129d95be98d8fe9ee033fe1 /cmds-device.c
parent12aba72aed310d6d3215684c44849233df7d79d2 (diff)
btrfs-progs: alias btrfs device delete to btrfs device remove
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 <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'cmds-device.c')
-rw-r--r--cmds-device.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/cmds-device.c b/cmds-device.c
index c588a6e0..0e605002 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -143,20 +143,14 @@ error_out:
return !!ret;
}
-static const char * const cmd_rm_dev_usage[] = {
- "btrfs device delete <device> [<device>...] <path>",
- "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 <device> [<device>...] <path>",
+ "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 <device> [<device>...] <path>",
+ "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)|<device> [<device>...]]",
"Scan devices for a btrfs filesystem",
@@ -590,7 +606,8 @@ static const char device_cmd_group_info[] =
const struct cmd_group device_cmd_group = {
device_cmd_group_usage, device_cmd_group_info, {
{ "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 },