btrfs-progs: balance: fix condition for recognizing old syntax

The commit 6f7151f499 extended the set of recognized valid subcommands
for the old path syntax but wrongly checks for more than 2 parameters.
That way a shortened and valid new syntax is not recognized (here 'can'
is short for 'cancel' and the short form is not in the list):

  btrfs-progs-6.1.3

  btrfs bal can /
  ERROR: balance cancel on '/' failed: Not in progress

  btrfs-progs-6.2.2

  btrfs bal can /
  WARNING: deprecated syntax, please use 'btrfs balance start'
  ERROR: cannot access 'can': No such file or directory

Issue: #612
Fixes: 6f7151f499 ("btrfs-progs: balance: fix some cases wrongly parsed as old syntax")
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2023-04-03 19:27:14 +02:00
parent 6ea85b680b
commit 9cb34031d7
1 changed files with 1 additions and 1 deletions

View File

@ -871,7 +871,7 @@ static int cmd_balance(const struct cmd_struct *cmd, int argc, char **argv)
* Exclude all valid subcommands from being potentially confused as path
* for the obsolete syntax: btrfs balance <path>
*/
if (argc >= 2) {
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;