From: Hongbo Li <lihongbo22@huawei.com>
To: Integral <integral@archlinuxcn.org>, <kent.overstreet@gmail.com>,
<kent.overstreet@linux.dev>
Cc: <mmpgouride@gmail.com>, <linux-bcachefs@vger.kernel.org>
Subject: Re: [PATCH] bcachefs-tools: add usage function for fs subcommand
Date: Mon, 11 Nov 2024 10:17:13 +0800 [thread overview]
Message-ID: <5484f8dd-da46-4d95-8a8a-e0d51778b414@huawei.com> (raw)
In-Reply-To: <20241109185648.30536-2-integral@archlinuxcn.org>
On 2024/11/10 2:56, Integral wrote:
> Add the missing usage function for "fs" subcommand; when no matching
> subcommand exists, print the usage and return -EINVAL.
>
> Signed-off-by: Integral <integral@archlinuxcn.org>
> ---
> c_src/bcachefs.c | 9 ++++-----
> c_src/cmd_fs.c | 12 ++++++++++++
> c_src/cmds.h | 1 +
> 3 files changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/c_src/bcachefs.c b/c_src/bcachefs.c
> index 77bf6215..e9e617e1 100644
> --- a/c_src/bcachefs.c
> +++ b/c_src/bcachefs.c
> @@ -113,14 +113,13 @@ int fs_cmds(int argc, char *argv[])
> {
> char *cmd = pop_cmd(&argc, argv);
>
> - if (argc < 1) {
> - bcachefs_usage();
> - exit(EXIT_FAILURE);
> - }
> + if (argc < 1)
> + return fs_usage();
> if (!strcmp(cmd, "usage"))
> return cmd_fs_usage(argc, argv);
>
> - return 0;
> + fs_usage();
Your previous patch also made changes here. Perhaps you could pack them
into a patchset or one patch which would make it more independent.
> + return -EINVAL;
> }
>
> int device_cmds(int argc, char *argv[])
> diff --git a/c_src/cmd_fs.c b/c_src/cmd_fs.c
> index 82eeceff..eb8f7d2e 100644
> --- a/c_src/cmd_fs.c
> +++ b/c_src/cmd_fs.c
> @@ -487,6 +487,18 @@ devs:
> bcache_fs_close(fs);
> }
>
> +int fs_usage(void)
> +{
> + puts("bcachefs fs - manage a running filesystem\n"
> + "Usage: bcachefs fs <CMD> [OPTIONS]\n"
May be the OPTIONS also should be displayed. ie like device_add_usage ...
Thanks,
Hongbo
> + "\n"
> + "Commands:\n"
> + " usage Display detailed filesystem usage\n"
> + "\n"
> + "Report bugs to <linux-bcachefs@vger.kernel.org>");
> + return 0;
> +}
> +
> static void fs_usage_usage(void)
> {
> puts("bcachefs fs usage - display detailed filesystem usage\n"
> diff --git a/c_src/cmds.h b/c_src/cmds.h
> index 64267dc4..99016d52 100644
> --- a/c_src/cmds.h
> +++ b/c_src/cmds.h
> @@ -14,6 +14,7 @@ int cmd_show_super(int argc, char *argv[]);
> int cmd_reset_counters(int argc, char *argv[]);
> int cmd_set_option(int argc, char *argv[]);
>
> +int fs_usage(void);
> int cmd_fs_usage(int argc, char *argv[]);
>
> int device_usage(void);
> --
> 2.47.0
>
next prev parent reply other threads:[~2024-11-11 2:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-09 18:56 [PATCH] bcachefs-tools: add usage function for fs subcommand Integral
2024-11-11 2:17 ` Hongbo Li [this message]
2024-11-11 3:49 ` [PATCH v2 combined] bcachefs-tools: add fs_usage & return -EINVAL when no matching subcommand Integral
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=5484f8dd-da46-4d95-8a8a-e0d51778b414@huawei.com \
--to=lihongbo22@huawei.com \
--cc=integral@archlinuxcn.org \
--cc=kent.overstreet@gmail.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
--cc=mmpgouride@gmail.com \
/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