From 9cb34031d729bf9f658b57c62b4da5ba23677564 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Mon, 3 Apr 2023 19:27:14 +0200 Subject: [PATCH] btrfs-progs: balance: fix condition for recognizing old syntax The commit 6f7151f4992b 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: 6f7151f4992b ("btrfs-progs: balance: fix some cases wrongly parsed as old syntax") Signed-off-by: David Sterba --- cmds/balance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds/balance.c b/cmds/balance.c index a5937ea8..2fc38164 100644 --- a/cmds/balance.c +++ b/cmds/balance.c @@ -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 */ - 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;