From f7fb93f1ac7d2e4d92ed1f15fb5b92d346c146d8 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 24 Oct 2023 21:31:18 +0200 Subject: [PATCH] btrfs-progs: remove old syntax of 'balance /path' There was a support for a short syntax of 'btrfs balance' that accepted a path where normally would be the mandatory subcommand. This was a heuristic and nowadays everybody should be using the 'btrfs balance action' syntax. The warning was in place for a year, it's time to remove the short syntax completely. Issue: #517 Signed-off-by: David Sterba --- cmds/balance.c | 36 +------------------ .../002-balance-full-no-filters/test.sh | 2 -- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/cmds/balance.c b/cmds/balance.c index 2c703a59..65c7da0b 100644 --- a/cmds/balance.c +++ b/cmds/balance.c @@ -36,7 +36,6 @@ static const char * const balance_cmd_group_usage[] = { "btrfs balance [options] ", - "btrfs balance (deprecated, use 'btrfs balance start')", NULL }; @@ -862,37 +861,4 @@ static const struct cmd_group balance_cmd_group = { } }; -static int cmd_balance(const struct cmd_struct *cmd, int argc, char **argv) -{ - bool old_syntax = true; - - /* - * Exclude all valid subcommands from being potentially confused as path - * for the obsolete syntax: btrfs balance - */ - if (argc == 2) { - for (int i = 0; balance_cmd_group.commands[i] != NULL; i++) { - if (strcmp(argv[1], balance_cmd_group.commands[i]->token) == 0) { - old_syntax = false; - break; - } - } - } else { - old_syntax = false; - } - - if (old_syntax) { - struct btrfs_ioctl_balance_args args; - - warning("deprecated syntax, please use 'btrfs balance start'"); - memset(&args, 0, sizeof(args)); - args.flags |= BTRFS_BALANCE_TYPE_MASK; - - /* No enqueueing supported for the obsolete syntax */ - return do_balance(argv[1], &args, 0, false); - } - - return handle_command_group(cmd, argc, argv); -} - -DEFINE_COMMAND(balance, "balance", cmd_balance, NULL, &balance_cmd_group, 0); +DEFINE_GROUP_COMMAND_TOKEN(balance); diff --git a/tests/cli-tests/002-balance-full-no-filters/test.sh b/tests/cli-tests/002-balance-full-no-filters/test.sh index 8295d344..37ae7ea9 100755 --- a/tests/cli-tests/002-balance-full-no-filters/test.sh +++ b/tests/cli-tests/002-balance-full-no-filters/test.sh @@ -15,8 +15,6 @@ run_check_mount_test_dev run_check $SUDO_HELPER "$TOP/btrfs" balance start --full-balance "$TEST_MNT" run_check $SUDO_HELPER "$TOP/btrfs" balance start "$TEST_MNT" -run_check $SUDO_HELPER "$TOP/btrfs" balance --full-balance "$TEST_MNT" -run_check $SUDO_HELPER "$TOP/btrfs" balance "$TEST_MNT" # grep below can't use -q else this could lead to SIGPIPE run_check_stdout $SUDO_HELPER "$TOP/btrfs" balance start --background "$TEST_MNT" |