mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-09 00:00:04 +03:00
cmd_fs_usage: Implement --help
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
f43c9702e0
commit
7a66cf70c5
@ -113,8 +113,10 @@ static int fs_cmds(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
char *cmd = pop_cmd(&argc, argv);
|
char *cmd = pop_cmd(&argc, argv);
|
||||||
|
|
||||||
if (argc < 1)
|
if (argc < 1) {
|
||||||
return fs_usage();
|
usage();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
if (!strcmp(cmd, "usage"))
|
if (!strcmp(cmd, "usage"))
|
||||||
return cmd_fs_usage(argc, argv);
|
return cmd_fs_usage(argc, argv);
|
||||||
|
|
||||||
|
32
cmd_fs.c
32
cmd_fs.c
@ -1,4 +1,4 @@
|
|||||||
|
#include <getopt.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
@ -275,30 +275,40 @@ static void fs_usage_to_text(struct printbuf *out, const char *path)
|
|||||||
bcache_fs_close(fs);
|
bcache_fs_close(fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fs_usage(void)
|
static void fs_usage_usage(void)
|
||||||
{
|
{
|
||||||
puts("bcachefs fs - manage a running filesystem\n"
|
puts("bcachefs fs usage - display detailed filesystem usage\n"
|
||||||
"Usage: bcachefs fs <CMD> [OPTION]... path\n"
|
"Usage: bcachefs fs usage [OPTION]... <mountpoint>\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Commands:\n"
|
"Options:\n"
|
||||||
" usage show disk usage\n"
|
" -h, --human-readable Human readable units\n"
|
||||||
"\n"
|
" --help Display this help and exit\n"
|
||||||
"Report bugs to <linux-bcachefs@vger.kernel.org>");
|
"Report bugs to <linux-bcachefs@vger.kernel.org>");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmd_fs_usage(int argc, char *argv[])
|
int cmd_fs_usage(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
static const struct option longopts[] = {
|
||||||
|
{ "help", no_argument, NULL, 'H' },
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
bool human_readable = false;
|
bool human_readable = false;
|
||||||
struct printbuf buf = PRINTBUF;
|
struct printbuf buf = PRINTBUF;
|
||||||
char *fs;
|
char *fs;
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "h")) != -1)
|
while ((opt = getopt_long(argc, argv, "h",
|
||||||
|
longopts, NULL)) != -1)
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'h':
|
case 'h':
|
||||||
human_readable = true;
|
human_readable = true;
|
||||||
break;
|
break;
|
||||||
|
case 'H':
|
||||||
|
fs_usage_usage();
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
default:
|
||||||
|
fs_usage_usage();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
args_shift(optind);
|
args_shift(optind);
|
||||||
|
|
||||||
|
1
cmds.h
1
cmds.h
@ -20,7 +20,6 @@ int cmd_run(int argc, char *argv[]);
|
|||||||
int cmd_stop(int argc, char *argv[]);
|
int cmd_stop(int argc, char *argv[]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int fs_usage(void);
|
|
||||||
int cmd_fs_usage(int argc, char *argv[]);
|
int cmd_fs_usage(int argc, char *argv[]);
|
||||||
|
|
||||||
int device_usage(void);
|
int device_usage(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user