2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
5 * This file is part of LVM2.
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
9 * of the GNU Lesser General Public License v.2.1.
11 * You should have received a copy of the GNU Lesser General Public License
12 * along with this program; if not, write to the Free Software Foundation,
13 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #define _FILE_OFFSET_BITS 64
22 #include "configure.h"
24 #include "libdevmapper.h"
26 #include "lvm-types.h"
27 #include "lvm-logging.h"
33 #include "dev-cache.h"
38 #include "filter-composite.h"
39 #include "filter-persistent.h"
40 #include "filter-regex.h"
41 #include "metadata-exported.h"
45 #include "lvm-string.h"
48 #include "toolcontext.h"
56 #include <sys/types.h>
61 /* command functions */
62 typedef int (*command_fn) (struct cmd_context * cmd, int argc, char **argv);
64 #define xx(a, b...) int a(struct cmd_context *cmd, int argc, char **argv);
68 /* define the enums for the command line switches */
70 #define arg(a, b, c, d, e) a ,
98 #define ARG_COUNTABLE 0x00000001 /* E.g. -vvvv */
99 #define ARG_GROUPABLE 0x00000002 /* E.g. --addtag */
109 percent_type_t percent;
110 /* void *ptr; // Currently not used. */
113 /* a global table of possible arguments */
115 const char short_arg;
117 const char *long_arg;
119 int (*fn) (struct cmd_context *cmd, struct arg_values *av);
123 struct arg_value_group_list {
125 struct arg_values arg_values[0];
128 #define CACHE_VGMETADATA 0x00000001
129 #define PERMITTED_READ_ONLY 0x00000002
131 /* a register of the lvm commands */
144 void usage(const char *name);
146 /* the argument verify/normalise functions */
147 int yes_no_arg(struct cmd_context *cmd, struct arg_values *av);
148 int yes_no_excl_arg(struct cmd_context *cmd, struct arg_values *av);
149 int size_kb_arg(struct cmd_context *cmd, struct arg_values *av);
150 int size_mb_arg(struct cmd_context *cmd, struct arg_values *av);
151 int int_arg(struct cmd_context *cmd, struct arg_values *av);
152 int int_arg_with_sign(struct cmd_context *cmd, struct arg_values *av);
153 int int_arg_with_sign_and_percent(struct cmd_context *cmd, struct arg_values *av);
154 int major_arg(struct cmd_context *cmd, struct arg_values *av);
155 int minor_arg(struct cmd_context *cmd, struct arg_values *av);
156 int string_arg(struct cmd_context *cmd, struct arg_values *av);
157 int tag_arg(struct cmd_context *cmd, struct arg_values *av);
158 int permission_arg(struct cmd_context *cmd, struct arg_values *av);
159 int metadatatype_arg(struct cmd_context *cmd, struct arg_values *av);
160 int units_arg(struct cmd_context *cmd, struct arg_values *av);
161 int segtype_arg(struct cmd_context *cmd, struct arg_values *av);
162 int alloc_arg(struct cmd_context *cmd, struct arg_values *av);
163 int readahead_arg(struct cmd_context *cmd, struct arg_values *av);
164 int metadatacopies_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
166 /* we use the enums to access the switches */
167 unsigned arg_count(const struct cmd_context *cmd, int a);
168 unsigned arg_is_set(const struct cmd_context *cmd, int a);
169 const char *arg_value(struct cmd_context *cmd, int a);
170 const char *arg_str_value(struct cmd_context *cmd, int a, const char *def);
171 int32_t arg_int_value(struct cmd_context *cmd, int a, const int32_t def);
172 uint32_t arg_uint_value(struct cmd_context *cmd, int a, const uint32_t def);
173 int64_t arg_int64_value(struct cmd_context *cmd, int a, const int64_t def);
174 uint64_t arg_uint64_value(struct cmd_context *cmd, int a, const uint64_t def);
175 const void *arg_ptr_value(struct cmd_context *cmd, int a, const void *def);
176 sign_t arg_sign_value(struct cmd_context *cmd, int a, const sign_t def);
177 percent_type_t arg_percent_value(struct cmd_context *cmd, int a, const percent_type_t def);
178 int arg_count_increment(struct cmd_context *cmd, int a);
180 unsigned grouped_arg_count(const struct arg_values *av, int a);
181 unsigned grouped_arg_is_set(const struct arg_values *av, int a);
182 const char *grouped_arg_str_value(const struct arg_values *av, int a, const char *def);
184 const char *command_name(struct cmd_context *cmd);
186 int pvmove_poll(struct cmd_context *cmd, const char *pv, unsigned background);
187 int lvconvert_poll(struct cmd_context *cmd, struct logical_volume *lv, unsigned background);