btrfs-progs: map-logical: convert help text to option formatter

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2023-02-22 00:39:14 +01:00
parent 7ed23eca5c
commit 7eefb7bab1

View File

@ -34,6 +34,7 @@
#include "common/help.h" #include "common/help.h"
#include "common/extent-cache.h" #include "common/extent-cache.h"
#include "common/string-utils.h" #include "common/string-utils.h"
#include "cmds/commands.h"
#define BUFFER_SIZE SZ_64K #define BUFFER_SIZE SZ_64K
@ -198,16 +199,20 @@ static int write_extent_content(struct btrfs_fs_info *fs_info, int out_fd,
return ret; return ret;
} }
__attribute__((noreturn)) static const char * const map_logical_usage[] = {
static void print_usage(void) "btrfs-map-logical [options] device",
{ "Map logical addres on a device",
printf("usage: btrfs-map-logical [options] device\n"); "",
printf("\t-l Logical extent to map\n"); OPTLINE("-l OFFSET", "logical extent to map"),
printf("\t-c Copy of the extent to read (usually 1 or 2)\n"); OPTLINE("-c COPY", "copy of the extent to read (usually 1 or 2)"),
printf("\t-o Output file to hold the extent\n"); OPTLINE("-o FILE", "output file to hold the extent"),
printf("\t-b Number of bytes to read\n"); OPTLINE("-b BYTES", "number of bytes to read"),
exit(1); NULL
} };
static const struct cmd_struct map_logical_cmd = {
.usagestr = map_logical_usage
};
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
@ -252,14 +257,14 @@ int main(int argc, char **argv)
output_file = strdup(optarg); output_file = strdup(optarg);
break; break;
default: default:
print_usage(); usage(&map_logical_cmd, 1);
} }
} }
set_argv0(argv); set_argv0(argv);
if (check_argc_min(argc - optind, 1)) if (check_argc_min(argc - optind, 1))
return 1; return 1;
if (logical == 0) if (logical == 0)
print_usage(); usage(&map_logical_cmd, 1);
dev = argv[optind]; dev = argv[optind];