btrfs-progs: filesystem balance: split out special handling

In preparation to use cmd_struct as the command entry point, we need
to split out the 'filesystem balance' handling to not call cmd_balance
directly.  The reason is that the flags that indicate a command is
hidden are a part of cmd_struct and so we can use a cmd_struct as a
direct alias in another command group and ALSO have it be hidden
without declaring another cmd_struct.

This change has no immediate impact since cmd_balance will still
use its usage information directly from cmds-balance.c.  It will
take effect once we start passing cmd_structs around for usage
information.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Jeff Mahoney 2018-03-06 23:19:23 -05:00 committed by David Sterba
parent a1bb77db63
commit b3e0faf6f5

View File

@ -1203,6 +1203,18 @@ static int cmd_filesystem_label(int argc, char **argv)
}
}
static const char * const cmd_filesystem_balance_usage[] = {
"btrfs filesystem balance [args...] (alias of \"btrfs balance\")",
"Please see \"btrfs balance --help\" for more information.",
NULL
};
/* Compatible old "btrfs filesystem balance" command */
static int cmd_filesystem_balance(int argc, char **argv)
{
return cmd_balance(argc, argv);
}
static const char filesystem_cmd_group_info[] =
"overall filesystem tasks and information";
@ -1216,8 +1228,9 @@ const struct cmd_group filesystem_cmd_group = {
0 },
{ "defragment", cmd_filesystem_defrag,
cmd_filesystem_defrag_usage, NULL, 0 },
{ "balance", cmd_balance, NULL, &balance_cmd_group,
CMD_HIDDEN },
{ "balance", cmd_filesystem_balance,
cmd_filesystem_balance_usage, &balance_cmd_group,
CMD_HIDDEN },
{ "resize", cmd_filesystem_resize, cmd_filesystem_resize_usage,
NULL, 0 },
{ "label", cmd_filesystem_label, cmd_filesystem_label_usage,