btrfs-progs: Introduce change_uuid function
[platform/upstream/btrfs-progs.git] / commands.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_COMMANDS_H__
18 #define __BTRFS_COMMANDS_H__
19
20 struct cmd_struct {
21         const char *token;
22         int (*fn)(int, char **);
23
24         /*
25          * Usage strings
26          *
27          * A NULL-terminated array of the following format:
28          *
29          *   usagestr[0] - one-line synopsis (required)
30          *   usagestr[1] - one-line short description (required)
31          *   usagestr[2..m] - a long (possibly multi-line) description
32          *                    (optional)
33          *   usagestr[m + 1] - an empty line separator (required if at least one
34          *                     option string is given, not needed otherwise)
35          *   usagestr[m + 2..n] - option strings, one option per line
36          *                        (optional)
37          *   usagestr[n + 1] - NULL terminator
38          *
39          * Options (if present) should always (even if there is no long
40          * description) be prepended with an empty line.  Supplied strings are
41          * indented but otherwise printed as-is, no automatic wrapping is done.
42          *
43          * Grep for cmd_*_usage[] for examples.
44          */
45         const char * const *usagestr;
46
47         /* should be NULL if token is not a subgroup */
48         const struct cmd_group *next;
49
50         /* if true don't list this token in help listings */
51         int hidden;
52 };
53
54 #define NULL_CMD_STRUCT {NULL, NULL, NULL, NULL, 0}
55
56 struct cmd_group {
57         const char * const *usagestr;
58         const char *infostr;
59
60         const struct cmd_struct commands[];
61 };
62
63 /* btrfs.c */
64 int prefixcmp(const char *str, const char *prefix);
65
66 int handle_command_group(const struct cmd_group *grp, int argc,
67                          char **argv);
68
69 /* help.c */
70 extern const char * const generic_cmd_help_usage[];
71
72 void usage(const char * const *usagestr) __attribute__((noreturn));
73 void usage_command(const struct cmd_struct *cmd, int full, int err);
74 void usage_command_group(const struct cmd_group *grp, int all, int err);
75
76 void help_unknown_token(const char *arg, const struct cmd_group *grp) __attribute__((noreturn));
77 void help_ambiguous_token(const char *arg, const struct cmd_group *grp) __attribute__((noreturn));
78
79 void help_command_group(const struct cmd_group *grp, int argc, char **argv);
80
81 extern const struct cmd_group subvolume_cmd_group;
82 extern const struct cmd_group filesystem_cmd_group;
83 extern const struct cmd_group balance_cmd_group;
84 extern const struct cmd_group device_cmd_group;
85 extern const struct cmd_group scrub_cmd_group;
86 extern const struct cmd_group inspect_cmd_group;
87 extern const struct cmd_group property_cmd_group;
88 extern const struct cmd_group quota_cmd_group;
89 extern const struct cmd_group qgroup_cmd_group;
90 extern const struct cmd_group replace_cmd_group;
91 extern const struct cmd_group rescue_cmd_group;
92
93 extern const char * const cmd_send_usage[];
94 extern const char * const cmd_receive_usage[];
95 extern const char * const cmd_check_usage[];
96 extern const char * const cmd_chunk_recover_usage[];
97 extern const char * const cmd_super_recover_usage[];
98 extern const char * const cmd_restore_usage[];
99 extern const char * const cmd_rescue_usage[];
100
101 int cmd_subvolume(int argc, char **argv);
102 int cmd_filesystem(int argc, char **argv);
103 int cmd_balance(int argc, char **argv);
104 int cmd_device(int argc, char **argv);
105 int cmd_scrub(int argc, char **argv);
106 int cmd_check(int argc, char **argv);
107 int cmd_chunk_recover(int argc, char **argv);
108 int cmd_super_recover(int argc, char **argv);
109 int cmd_inspect(int argc, char **argv);
110 int cmd_property(int argc, char **argv);
111 int cmd_send(int argc, char **argv);
112 int cmd_receive(int argc, char **argv);
113 int cmd_quota(int argc, char **argv);
114 int cmd_qgroup(int argc, char **argv);
115 int cmd_replace(int argc, char **argv);
116 int cmd_restore(int argc, char **argv);
117 int cmd_select_super(int argc, char **argv);
118 int cmd_dump_super(int argc, char **argv);
119 int cmd_debug_tree(int argc, char **argv);
120 int cmd_rescue(int argc, char **argv);
121
122 /* subvolume exported functions */
123 int test_issubvolume(char *path);
124
125 /* send.c */
126 char *get_subvol_name(char *mnt, char *full_path);
127
128 #endif