btrfs-progs: move help defines to own header

Signed-off-by: David Sterba <dsterba@suse.com>
master
David Sterba 2017-01-25 16:35:00 +01:00
parent e235f12de2
commit 1c880f34f1
36 changed files with 112 additions and 59 deletions

View File

@ -31,6 +31,7 @@
#include "transaction.h"
#include "list.h"
#include "utils.h"
#include "help.h"
#define FIELD_BUF_LEN 80

View File

@ -21,6 +21,7 @@
#include "utils.h"
#include "commands.h"
#include "cmds-inspect-dump-tree.h"
#include "help.h"
int main(int argc, char **argv)
{

View File

@ -35,6 +35,7 @@
#include "crc32c.h"
#include "extent-cache.h"
#include "find-root.h"
#include "help.h"
static void find_root_usage(void)
{

View File

@ -29,6 +29,7 @@
#include "transaction.h"
#include "list.h"
#include "utils.h"
#include "help.h"
#define BUFFER_SIZE SZ_64K

View File

@ -29,6 +29,7 @@
#include "transaction.h"
#include "list.h"
#include "utils.h"
#include "help.h"
static void print_usage(void)
{

View File

@ -24,6 +24,7 @@
#include "disk-io.h"
#include "transaction.h"
#include "utils.h"
#include "help.h"
__attribute__((noreturn)) static void print_usage(void)
{

View File

@ -22,6 +22,7 @@
#include "crc32c.h"
#include "commands.h"
#include "utils.h"
#include "help.h"
static const char * const btrfs_cmd_group_usage[] = {
"btrfs [--help] [--version] <group> [<group>...] <command> [<args>]",

View File

@ -32,6 +32,7 @@
#include "transaction.h"
#include "utils.h"
#include "volumes.h"
#include "help.h"
static char *device;
static int force = 0;

View File

@ -32,6 +32,7 @@
#include "commands.h"
#include "utils.h"
#include "help.h"
static const char * const balance_cmd_group_usage[] = {
"btrfs balance <command> [options] <path>",

View File

@ -42,6 +42,7 @@
#include "backref.h"
#include "ulist.h"
#include "hash.h"
#include "help.h"
enum task_position {
TASK_EXTENTS,

View File

@ -32,6 +32,7 @@
#include "cmds-fi-usage.h"
#include "commands.h"
#include "help.h"
static const char * const device_cmd_group_usage[] = {
"btrfs device <command> [<args>]",

View File

@ -40,6 +40,7 @@
#include "rbtree.h"
#include "interval_tree_generic.h"
#include "help.h"
static int summarize = 0;
static unsigned unit_mode = UNITS_RAW;

View File

@ -31,6 +31,7 @@
#include "commands.h"
#include "version.h"
#include "help.h"
/*
* Add the chunk info to the chunk_info list

View File

@ -38,6 +38,7 @@
#include "list_sort.h"
#include "disk-io.h"
#include "cmds-fi-du.h"
#include "help.h"
/*
* for btrfs fi show, we maintain a hash of fsids we've already printed.

View File

@ -34,6 +34,7 @@
#include "commands.h"
#include "crc32c.h"
#include "cmds-inspect-dump-super.h"
#include "help.h"
static int check_csum_sblock(void *sb, int csum_size)
{

View File

@ -32,6 +32,7 @@
#include "commands.h"
#include "utils.h"
#include "cmds-inspect-dump-tree.h"
#include "help.h"
static void print_extents(struct btrfs_root *root, struct extent_buffer *eb)
{

View File

@ -36,6 +36,7 @@
#include "utils.h"
#include "commands.h"
#include "cmds-inspect-tree-stats.h"
#include "help.h"
static int verbose = 0;
static int no_pretty = 0;

View File

@ -34,6 +34,7 @@
#include "cmds-inspect-dump-tree.h"
#include "cmds-inspect-dump-super.h"
#include "cmds-inspect-tree-stats.h"
#include "help.h"
static const char * const inspect_cmd_group_usage[] = {
"btrfs inspect-internal <command> <args>",

View File

@ -26,6 +26,7 @@
#include "props.h"
#include "ctree.h"
#include "utils.h"
#include "help.h"
static const char * const property_cmd_group_usage[] = {
"btrfs property get/set/list [-t <type>] <object> [<name>] [value]",

View File

@ -26,6 +26,7 @@
#include "commands.h"
#include "qgroup.h"
#include "utils.h"
#include "help.h"
static const char * const qgroup_cmd_group_usage[] = {
"btrfs qgroup <command> [options] <path>",

View File

@ -24,6 +24,7 @@
#include "commands.h"
#include "utils.h"
#include "help.h"
static const char * const quota_cmd_group_usage[] = {
"btrfs quota <command> [options] <path>",

View File

@ -50,6 +50,7 @@
#include "send-stream.h"
#include "send-utils.h"
#include "send-dump.h"
#include "help.h"
static int g_verbose = 0;

View File

@ -37,7 +37,7 @@
#include "disk-io.h"
#include "commands.h"
#include "help.h"
static int print_replace_status(int fd, const char *path, int once);
static char *time2string(char *buf, size_t s, __u64 t);

View File

@ -24,6 +24,7 @@
#include "disk-io.h"
#include "commands.h"
#include "utils.h"
#include "help.h"
static const char * const rescue_cmd_group_usage[] = {
"btrfs rescue <command> [options] <path>",

View File

@ -42,6 +42,7 @@
#include "volumes.h"
#include "utils.h"
#include "commands.h"
#include "help.h"
static char fs_name[PATH_MAX];
static char path_name[PATH_MAX];

View File

@ -44,6 +44,7 @@
#include "disk-io.h"
#include "commands.h"
#include "help.h"
static const char * const scrub_cmd_group_usage[] = {
"btrfs scrub <command> [options] <path>|<device>",

View File

@ -43,6 +43,7 @@
#include "send.h"
#include "send-utils.h"
#include "help.h"
#define SEND_BUFFER_SIZE SZ_64K

View File

@ -37,6 +37,7 @@
#include "utils.h"
#include "btrfs-list.h"
#include "utils.h"
#include "help.h"
static int is_subvolume_cleaned(int fd, u64 subvolid)
{

View File

@ -71,19 +71,8 @@ int prefixcmp(const char *str, const char *prefix);
int handle_command_group(const struct cmd_group *grp, int argc,
char **argv);
/* help.c */
extern const char * const generic_cmd_help_usage[];
void usage(const char * const *usagestr) __attribute__((noreturn));
void usage_command(const struct cmd_struct *cmd, int full, int err);
void usage_command_group(const struct cmd_group *grp, int all, int err);
void usage_command_group_short(const struct cmd_group *grp);
void help_unknown_token(const char *arg, const struct cmd_group *grp) __attribute__((noreturn));
void help_ambiguous_token(const char *arg, const struct cmd_group *grp) __attribute__((noreturn));
void help_command_group(const struct cmd_group *grp, int argc, char **argv);
extern const struct cmd_group subvolume_cmd_group;
extern const struct cmd_group filesystem_cmd_group;
extern const struct cmd_group balance_cmd_group;

View File

@ -37,6 +37,7 @@
#include "crc32c.h"
#include "utils.h"
#include "task-utils.h"
#include "help.h"
#if BTRFSCONVERT_EXT2
#include <ext2fs/ext2_fs.h>

1
help.c
View File

@ -21,6 +21,7 @@
#include "commands.h"
#include "utils.h"
#include "help.h"
#define USAGE_SHORT 1U
#define USAGE_LONG 2U

79
help.h 100644
View File

@ -0,0 +1,79 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License v2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*/
#ifndef __BTRFS_HELP_H__
#define __BTRFS_HELP_H__
#define GETOPT_VAL_SI 256
#define GETOPT_VAL_IEC 257
#define GETOPT_VAL_RAW 258
#define GETOPT_VAL_HUMAN_READABLE 259
#define GETOPT_VAL_KBYTES 260
#define GETOPT_VAL_MBYTES 261
#define GETOPT_VAL_GBYTES 262
#define GETOPT_VAL_TBYTES 263
#define GETOPT_VAL_HELP 270
#define ARGV0_BUF_SIZE PATH_MAX
#define HELPINFO_UNITS_LONG \
"--raw raw numbers in bytes", \
"--human-readable human friendly numbers, base 1024 (default)", \
"--iec use 1024 as a base (KiB, MiB, GiB, TiB)", \
"--si use 1000 as a base (kB, MB, GB, TB)", \
"--kbytes show sizes in KiB, or kB with --si", \
"--mbytes show sizes in MiB, or MB with --si", \
"--gbytes show sizes in GiB, or GB with --si", \
"--tbytes show sizes in TiB, or TB with --si"
#define HELPINFO_UNITS_SHORT_LONG \
"-b|--raw raw numbers in bytes", \
"-h|--human-readable", \
" human friendly numbers, base 1024 (default)", \
"-H human friendly numbers, base 1000", \
"--iec use 1024 as a base (KiB, MiB, GiB, TiB)", \
"--si use 1000 as a base (kB, MB, GB, TB)", \
"-k|--kbytes show sizes in KiB, or kB with --si", \
"-m|--mbytes show sizes in MiB, or MB with --si", \
"-g|--gbytes show sizes in GiB, or GB with --si", \
"-t|--tbytes show sizes in TiB, or TB with --si"
struct cmd_struct;
struct cmd_group;
void usage(const char * const *usagestr) __attribute__((noreturn));
void usage_command(const struct cmd_struct *cmd, int full, int err);
void usage_command_group(const struct cmd_group *grp, int all, int err);
void usage_command_group_short(const struct cmd_group *grp);
void help_unknown_token(const char *arg, const struct cmd_group *grp) __attribute__((noreturn));
void help_ambiguous_token(const char *arg, const struct cmd_group *grp) __attribute__((noreturn));
void help_command_group(const struct cmd_group *grp, int argc, char **argv);
int check_argc_exact(int nargs, int expected);
int check_argc_min(int nargs, int expected);
int check_argc_max(int nargs, int expected);
void clean_args_no_options(int argc, char *argv[], const char * const *usage);
void clean_args_no_options_relaxed(int argc, char *argv[],
const char * const *usagestr);
void fixup_argv0(char **argv, const char *token);
void set_argv0(char **argv);
const char *get_argv0_buf(void);
#endif

View File

@ -35,6 +35,7 @@
#include "utils.h"
#include "volumes.h"
#include "extent_io.h"
#include "help.h"
#define HEADER_MAGIC 0xbd5c25e27295668bULL
#define MAX_PENDING_SIZE (256 * 1024)

View File

@ -43,6 +43,7 @@
#include "transaction.h"
#include "utils.h"
#include "list_sort.h"
#include "help.h"
static u64 index_cnt = 2;
static int verbose = 1;

View File

@ -51,6 +51,7 @@
#include "volumes.h"
#include "ioctl.h"
#include "commands.h"
#include "help.h"
#ifndef BLKDISCARD
#define BLKDISCARD _IO(0x12,119)

47
utils.h
View File

@ -64,26 +64,6 @@
#define BTRFS_UUID_UNPARSED_SIZE 37
#define ARGV0_BUF_SIZE PATH_MAX
#define GETOPT_VAL_SI 256
#define GETOPT_VAL_IEC 257
#define GETOPT_VAL_RAW 258
#define GETOPT_VAL_HUMAN_READABLE 259
#define GETOPT_VAL_KBYTES 260
#define GETOPT_VAL_MBYTES 261
#define GETOPT_VAL_GBYTES 262
#define GETOPT_VAL_TBYTES 263
#define GETOPT_VAL_HELP 270
int check_argc_exact(int nargs, int expected);
int check_argc_min(int nargs, int expected);
int check_argc_max(int nargs, int expected);
void fixup_argv0(char **argv, const char *token);
void set_argv0(char **argv);
/*
* Output modes of size
*/
@ -286,34 +266,7 @@ static inline u64 div_factor(u64 num, int factor)
int btrfs_tree_search2_ioctl_supported(int fd);
int btrfs_check_nodesize(u32 nodesize, u32 sectorsize, u64 features);
const char *get_argv0_buf(void);
#define HELPINFO_UNITS_LONG \
"--raw raw numbers in bytes", \
"--human-readable human friendly numbers, base 1024 (default)", \
"--iec use 1024 as a base (KiB, MiB, GiB, TiB)", \
"--si use 1000 as a base (kB, MB, GB, TB)", \
"--kbytes show sizes in KiB, or kB with --si", \
"--mbytes show sizes in MiB, or MB with --si", \
"--gbytes show sizes in GiB, or GB with --si", \
"--tbytes show sizes in TiB, or TB with --si"
#define HELPINFO_UNITS_SHORT_LONG \
"-b|--raw raw numbers in bytes", \
"-h|--human-readable", \
" human friendly numbers, base 1024 (default)", \
"-H human friendly numbers, base 1000", \
"--iec use 1024 as a base (KiB, MiB, GiB, TiB)", \
"--si use 1000 as a base (kB, MB, GB, TB)", \
"-k|--kbytes show sizes in KiB, or kB with --si", \
"-m|--mbytes show sizes in MiB, or MB with --si", \
"-g|--gbytes show sizes in GiB, or GB with --si", \
"-t|--tbytes show sizes in TiB, or TB with --si"
unsigned int get_unit_mode_from_arg(int *argc, char *argv[], int df_mode);
void clean_args_no_options(int argc, char *argv[], const char * const *usage);
void clean_args_no_options_relaxed(int argc, char *argv[],
const char * const *usagestr);
int string_is_numerical(const char *str);
#if DEBUG_VERBOSE_ERROR