]> sourceware.org Git - lvm2.git/blame - tools/tools.h
Reinstate accidentally-deleted line.
[lvm2.git] / tools / tools.h
CommitLineData
269930c0 1/*
6606c3ae 2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
be684599 3 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
269930c0 4 *
6606c3ae
AK
5 * This file is part of LVM2.
6 *
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
be684599 9 * of the GNU Lesser General Public License v.2.1.
6606c3ae 10 *
be684599 11 * You should have received a copy of the GNU Lesser General Public License
6606c3ae
AK
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
269930c0
AK
14 */
15
25b73380
AK
16#ifndef _LVM_TOOLS_H
17#define _LVM_TOOLS_H
269930c0 18
5a52dca9 19#define _GNU_SOURCE
96185e9c 20#define _FILE_OFFSET_BITS 64
5a52dca9 21
cee2f123 22#include "configure.h"
8ef2b021 23#include <assert.h>
cee2f123 24#include "libdevmapper.h"
8ef2b021 25
2262b320 26#include "lvm-types.h"
84b9ec97 27#include "lvm-logging.h"
5a52dca9 28#include "activate.h"
040cfcf8 29#include "archiver.h"
914c9723 30#include "lvmcache.h"
dae08226 31#include "lvmetad.h"
b8ef655f 32#include "config.h"
8ef2b021 33#include "defaults.h"
b8ef655f 34#include "dev-cache.h"
b8ef655f
AK
35#include "device.h"
36#include "display.h"
269930c0 37#include "errors.h"
28f5d16b 38#include "filter.h"
20a2b71c 39#include "filter-composite.h"
5a52dca9 40#include "filter-persistent.h"
20a2b71c 41#include "filter-regex.h"
03eee0e2 42#include "metadata-exported.h"
7d0e6e80 43#include "locking.h"
a653923f 44#include "lvm-exec.h"
5a52dca9
AK
45#include "lvm-file.h"
46#include "lvm-string.h"
c4ddb31a 47#include "segtype.h"
cf6dd251 48#include "str_list.h"
60274aba 49#include "toolcontext.h"
5a52dca9 50#include "toollib.h"
197c3f2a 51
8ef2b021
AK
52#include <stdlib.h>
53#include <unistd.h>
5a52dca9
AK
54#include <ctype.h>
55#include <limits.h>
197c3f2a 56#include <stdarg.h>
197c3f2a 57#include <sys/types.h>
269930c0
AK
58
59#define CMD_LEN 256
60#define MAX_ARGS 64
61
62/* command functions */
6fda126d 63typedef int (*command_fn) (struct cmd_context * cmd, int argc, char **argv);
269930c0 64
60274aba 65#define xx(a, b...) int a(struct cmd_context *cmd, int argc, char **argv);
269930c0
AK
66#include "commands.h"
67#undef xx
68
69/* define the enums for the command line switches */
70enum {
edb3374d 71#define arg(a, b, c, d, e) a ,
269930c0 72#include "args.h"
9f23b355 73#undef arg
269930c0
AK
74};
75
7858f6fb
AK
76typedef enum {
77 SIGN_NONE = 0,
78 SIGN_PLUS = 1,
79 SIGN_MINUS = 2
80} sign_t;
9f23b355 81
34fadac4
AK
82typedef enum {
83 PERCENT_NONE = 0,
84 PERCENT_VG,
85 PERCENT_FREE,
dfef7f69 86 PERCENT_LV,
5bc2af26
MS
87 PERCENT_PVS,
88 PERCENT_ORIGIN
8191fe4f 89} percent_type_t;
34fadac4 90
f8452d8c
AK
91#define ARG_COUNTABLE 0x00000001 /* E.g. -vvvv */
92#define ARG_GROUPABLE 0x00000002 /* E.g. --addtag */
f8427641 93
f8452d8c 94struct arg_values {
72b2cb61 95 unsigned count;
269930c0 96 char *value;
8ef2b021
AK
97 int32_t i_value;
98 uint32_t ui_value;
4c64ed4c
AK
99 int64_t i64_value;
100 uint64_t ui64_value;
7858f6fb 101 sign_t sign;
8191fe4f 102 percent_type_t percent;
54d7741a 103/* void *ptr; // Currently not used. */
269930c0
AK
104};
105
f8452d8c
AK
106/* a global table of possible arguments */
107struct arg_props {
108 const char short_arg;
109 char _padding[7];
110 const char *long_arg;
111
112 int (*fn) (struct cmd_context *cmd, struct arg_values *av);
113 uint32_t flags;
114};
115
116struct arg_value_group_list {
117 struct dm_list list;
118 struct arg_values arg_values[0];
119};
120
b83af516
AK
121#define CACHE_VGMETADATA 0x00000001
122#define PERMITTED_READ_ONLY 0x00000002
bf7dea97 123
03a8a07d
AK
124/* a register of the lvm commands */
125struct command {
6fda126d
AK
126 const char *name;
127 const char *desc;
128 const char *usage;
129 command_fn fn;
03a8a07d 130
bf7dea97
AK
131 unsigned flags;
132
6fda126d
AK
133 int num_args;
134 int *valid_args;
03a8a07d
AK
135};
136
269930c0
AK
137void usage(const char *name);
138
139/* the argument verify/normalise functions */
f8452d8c
AK
140int yes_no_arg(struct cmd_context *cmd, struct arg_values *av);
141int yes_no_excl_arg(struct cmd_context *cmd, struct arg_values *av);
142int size_kb_arg(struct cmd_context *cmd, struct arg_values *av);
143int size_mb_arg(struct cmd_context *cmd, struct arg_values *av);
144int int_arg(struct cmd_context *cmd, struct arg_values *av);
145int int_arg_with_sign(struct cmd_context *cmd, struct arg_values *av);
146int int_arg_with_sign_and_percent(struct cmd_context *cmd, struct arg_values *av);
147int major_arg(struct cmd_context *cmd, struct arg_values *av);
148int minor_arg(struct cmd_context *cmd, struct arg_values *av);
149int string_arg(struct cmd_context *cmd, struct arg_values *av);
150int tag_arg(struct cmd_context *cmd, struct arg_values *av);
151int permission_arg(struct cmd_context *cmd, struct arg_values *av);
152int metadatatype_arg(struct cmd_context *cmd, struct arg_values *av);
153int units_arg(struct cmd_context *cmd, struct arg_values *av);
154int segtype_arg(struct cmd_context *cmd, struct arg_values *av);
155int alloc_arg(struct cmd_context *cmd, struct arg_values *av);
156int readahead_arg(struct cmd_context *cmd, struct arg_values *av);
157int metadatacopies_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
269930c0 158
269930c0 159/* we use the enums to access the switches */
a8fb89ad
AK
160unsigned arg_count(const struct cmd_context *cmd, int a);
161unsigned arg_is_set(const struct cmd_context *cmd, int a);
8a2fc586
AK
162const char *arg_value(struct cmd_context *cmd, int a);
163const char *arg_str_value(struct cmd_context *cmd, int a, const char *def);
164int32_t arg_int_value(struct cmd_context *cmd, int a, const int32_t def);
165uint32_t arg_uint_value(struct cmd_context *cmd, int a, const uint32_t def);
72b2cb61 166int64_t arg_int64_value(struct cmd_context *cmd, int a, const int64_t def);
8a2fc586
AK
167uint64_t arg_uint64_value(struct cmd_context *cmd, int a, const uint64_t def);
168const void *arg_ptr_value(struct cmd_context *cmd, int a, const void *def);
169sign_t arg_sign_value(struct cmd_context *cmd, int a, const sign_t def);
8191fe4f 170percent_type_t arg_percent_value(struct cmd_context *cmd, int a, const percent_type_t def);
8a2fc586
AK
171int arg_count_increment(struct cmd_context *cmd, int a);
172
f8452d8c
AK
173unsigned grouped_arg_count(const struct arg_values *av, int a);
174unsigned grouped_arg_is_set(const struct arg_values *av, int a);
175const char *grouped_arg_str_value(const struct arg_values *av, int a, const char *def);
176
8a2fc586 177const char *command_name(struct cmd_context *cmd);
677a06d5 178
13601dbf 179int pvmove_poll(struct cmd_context *cmd, const char *pv, unsigned background);
31f55a07 180int lvconvert_poll(struct cmd_context *cmd, struct logical_volume *lv, unsigned background);
13601dbf 181
6585b5a1
AK
182int mirror_remove_missing(struct cmd_context *cmd,
183 struct logical_volume *lv, int force);
184
4fbde014 185uint32_t percent_of_extents(uint32_t percents, uint32_t count, int roundup);
25d42d50 186#endif
This page took 0.111522 seconds and 5 git commands to generate.