From b3e0faf6f5c33024bdf7e78eec64ce1bb54c4f97 Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Tue, 6 Mar 2018 23:19:23 -0500 Subject: [PATCH] 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 Signed-off-by: David Sterba --- cmds-filesystem.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cmds-filesystem.c b/cmds-filesystem.c index c4e43f84..afc0452f 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -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,