btrfs-progs: device: add replace subcommand as alias to 1st level command

The command group of 'replace' belongs to device and could be seen as
confusing. At minimum we can add an alias so now there's equivalent:

  # btrfs replace start
  # btrfs device replace start

Both commands will exist for backward compatibility, tough we might
revisit which one is the primary one.

Issue: #484
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2022-07-18 19:26:39 +02:00
parent 99ce788a0d
commit cef73a5e98
2 changed files with 21 additions and 0 deletions

View File

@ -74,6 +74,9 @@ remove [options] <device>|<devid> [<device>|<devid>...] <path>
delete <device>|<devid> [<device>|<devid>...] <path>
Alias of remove kept for backward compatibility
replace <command> [options] <path>
Alias of whole command group *btrfs replace* for convenience. See ``btrfs-replace(8)``.
ready <device>
Wait until all devices of a multiple-device filesystem are scanned and
registered within the kernel module. This is to provide a way for automatic

View File

@ -920,6 +920,23 @@ static int cmd_device_usage(const struct cmd_struct *cmd, int argc, char **argv)
}
static DEFINE_SIMPLE_COMMAND(device_usage, "usage");
static const char * const cmd_device_replace_usage[] = {
"btrfs device replace <command> [...]\n"
"\tReplace a device (alias of \"btrfs replace\")",
"Please see \"btrfs replace --help\" for more information.",
NULL
};
static int cmd_device_replace(const struct cmd_struct *unused,
int argc, char **argv)
{
return cmd_execute(&cmd_struct_replace, argc, argv);
}
/* Alias of 1st level command 'replace' as a subcommand of 'device' */
static DEFINE_COMMAND(device_replace, "replace", cmd_device_replace,
cmd_device_replace_usage, NULL, CMD_ALIAS);
static const char device_cmd_group_info[] =
"manage and query devices in the filesystem";
@ -928,6 +945,7 @@ static const struct cmd_group device_cmd_group = {
&cmd_struct_device_add,
&cmd_struct_device_delete,
&cmd_struct_device_remove,
&cmd_struct_device_replace,
&cmd_struct_device_scan,
&cmd_struct_device_ready,
&cmd_struct_device_stats,