btrfs-progs: mkfs/rootdir: Don't follow symbolic link when calcuating size
[platform/upstream/btrfs-progs.git] / help.h
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public
4  * License v2 as published by the Free Software Foundation.
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9  * General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the
13  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
14  * Boston, MA 021110-1307, USA.
15  */
16
17 #ifndef __BTRFS_HELP_H__
18 #define __BTRFS_HELP_H__
19
20 #define GETOPT_VAL_SI                           256
21 #define GETOPT_VAL_IEC                          257
22 #define GETOPT_VAL_RAW                          258
23 #define GETOPT_VAL_HUMAN_READABLE               259
24 #define GETOPT_VAL_KBYTES                       260
25 #define GETOPT_VAL_MBYTES                       261
26 #define GETOPT_VAL_GBYTES                       262
27 #define GETOPT_VAL_TBYTES                       263
28
29 #define GETOPT_VAL_HELP                         270
30
31 #define ARGV0_BUF_SIZE  PATH_MAX
32
33 #define HELPINFO_UNITS_LONG                                                     \
34         "--raw              raw numbers in bytes",                              \
35         "--human-readable   human friendly numbers, base 1024 (default)",       \
36         "--iec              use 1024 as a base (KiB, MiB, GiB, TiB)",           \
37         "--si               use 1000 as a base (kB, MB, GB, TB)",               \
38         "--kbytes           show sizes in KiB, or kB with --si",                \
39         "--mbytes           show sizes in MiB, or MB with --si",                \
40         "--gbytes           show sizes in GiB, or GB with --si",                \
41         "--tbytes           show sizes in TiB, or TB with --si"
42
43 #define HELPINFO_UNITS_SHORT_LONG                                               \
44         "-b|--raw           raw numbers in bytes",                              \
45         "-h|--human-readable",                                                  \
46         "                   human friendly numbers, base 1024 (default)",       \
47         "-H                 human friendly numbers, base 1000",                 \
48         "--iec              use 1024 as a base (KiB, MiB, GiB, TiB)",           \
49         "--si               use 1000 as a base (kB, MB, GB, TB)",               \
50         "-k|--kbytes        show sizes in KiB, or kB with --si",                \
51         "-m|--mbytes        show sizes in MiB, or MB with --si",                \
52         "-g|--gbytes        show sizes in GiB, or GB with --si",                \
53         "-t|--tbytes        show sizes in TiB, or TB with --si"
54
55 struct cmd_struct;
56 struct cmd_group;
57
58 __attribute__((noreturn))
59 void usage(const char * const *usagestr);
60 void usage_command(const struct cmd_struct *cmd, int full, int err);
61 void usage_command_group(const struct cmd_group *grp, int all, int err);
62 void usage_command_group_short(const struct cmd_group *grp);
63
64 __attribute__((noreturn))
65 void help_unknown_token(const char *arg, const struct cmd_group *grp);
66 __attribute__((noreturn))
67 void help_ambiguous_token(const char *arg, const struct cmd_group *grp);
68
69 void help_command_group(const struct cmd_group *grp, int argc, char **argv);
70
71 int check_argc_exact(int nargs, int expected);
72 int check_argc_min(int nargs, int expected);
73 int check_argc_max(int nargs, int expected);
74 void clean_args_no_options(int argc, char *argv[], const char * const *usage);
75 void clean_args_no_options_relaxed(int argc, char *argv[],
76                 const char * const *usagestr);
77
78 void fixup_argv0(char **argv, const char *token);
79 void set_argv0(char **argv);
80 const char *get_argv0_buf(void);
81
82 #endif