From: Wang Yugui <wangyugui@e16-tech.com>
To: linux-btrfs@vger.kernel.org
Cc: Wang Yugui <wangyugui@e16-tech.com>
Subject: [PATCH] btrfs-progs: balance: fix some cases wrongly parsed as old syntax
Date: Wed, 14 Sep 2022 13:58:46 +0800 [thread overview]
Message-ID: <20220914055846.52008-1-wangyugui@e16-tech.com> (raw)
Some cases of 'btrfs balance' are wrongly parsed as old syntax.
an example:
$ btrfs balance status
ERROR: cannot access 'status': No such file or directory
currently, only 'start' is successfully excluded in the check of old syntax.
fix it by adding others in the check of old syntax.
Signed-off-by: Wang Yugui <wangyugui@e16-tech.com>
---
cmds/balance.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/cmds/balance.c b/cmds/balance.c
index c5e10f92..bafd1714 100644
--- a/cmds/balance.c
+++ b/cmds/balance.c
@@ -852,8 +852,23 @@ static const struct cmd_group balance_cmd_group = {
static int cmd_balance(const struct cmd_struct *cmd, int argc, char **argv)
{
- if (argc == 2 && strcmp("start", argv[1]) != 0) {
- /* old 'btrfs filesystem balance <path>' syntax */
+ bool old_syntax = true; /* old 'btrfs balance <path>' syntax */
+ if (argc >= 2)
+ {
+ int i;
+ for (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;
memset(&args, 0, sizeof(args));
--
2.36.2
next reply other threads:[~2022-09-14 5:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 5:58 Wang Yugui [this message]
2022-09-14 7:11 ` [PATCH] btrfs-progs: balance: fix some cases wrongly parsed as old syntax Qu Wenruo
2022-09-21 8:24 ` David Sterba
2022-09-21 15:34 ` [PATCH] btrfs-progs: balance: deprecate " Wang Yugui
2022-09-21 21:54 ` [PATCH v2] " Wang Yugui
2023-03-16 15:47 ` [PATCH] btrfs-progs: balance: fix some cases wrongly parsed as " David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220914055846.52008-1-wangyugui@e16-tech.com \
--to=wangyugui@e16-tech.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox