From: Integral <integral@archlinuxcn.org>
To: kent.overstreet@gmail.com, kent.overstreet@linux.dev,
lihongbo22@huawei.com
Cc: mmpgouride@gmail.com, linux-bcachefs@vger.kernel.org,
integral@archlinuxcn.org
Subject: [PATCH] bcachefs-tools: add usage function for fs subcommand
Date: Sun, 10 Nov 2024 02:56:49 +0800 [thread overview]
Message-ID: <20241109185648.30536-2-integral@archlinuxcn.org> (raw)
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();
+ 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"
+ "\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 reply other threads:[~2024-11-09 18:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-09 18:56 Integral [this message]
2024-11-11 2:17 ` [PATCH] bcachefs-tools: add usage function for fs subcommand Hongbo Li
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=20241109185648.30536-2-integral@archlinuxcn.org \
--to=integral@archlinuxcn.org \
--cc=kent.overstreet@gmail.com \
--cc=kent.overstreet@linux.dev \
--cc=lihongbo22@huawei.com \
--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