]>
Commit | Line | Data |
---|---|---|
60274aba | 1 | /* |
6606c3ae | 2 | * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. |
7ac8b7c3 | 3 | * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. |
60274aba | 4 | * |
6606c3ae | 5 | * This file is part of LVM2. |
60274aba | 6 | * |
6606c3ae AK |
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 | |
60274aba AK |
14 | */ |
15 | ||
16 | #ifndef _LVM_TOOLCONTEXT_H | |
17 | #define _LVM_TOOLCONTEXT_H | |
18 | ||
19 | #include "dev-cache.h" | |
60274aba | 20 | |
d1d9800e AK |
21 | #include <stdio.h> |
22 | #include <limits.h> | |
23 | ||
24 | /* | |
25 | * Config options that can be changed while commands are processed | |
26 | */ | |
27 | struct config_info { | |
28 | int debug; | |
29 | int verbose; | |
30 | int test; | |
31 | int syslog; | |
32 | int activation; | |
4c64ed4c | 33 | int suffix; |
d1d9800e AK |
34 | int archive; /* should we archive ? */ |
35 | int backup; /* should we backup ? */ | |
b4068515 | 36 | int read_ahead; /* DM_READ_AHEAD_NONE or _AUTO */ |
cda69e17 | 37 | int udev_rules; |
cf8235e0 | 38 | int udev_sync; |
418663b6 | 39 | int udev_fallback; |
bf7dea97 | 40 | int cache_vgmetadata; |
1165258c | 41 | const char *msg_prefix; |
54d7741a | 42 | const char *fmt_name; |
1165258c AK |
43 | uint64_t unit_factor; |
44 | int cmd_name; /* Show command name? */ | |
d1d9800e | 45 | mode_t umask; |
1165258c AK |
46 | char unit_type; |
47 | char _padding[1]; | |
d1d9800e AK |
48 | }; |
49 | ||
e59e2f7c | 50 | struct dm_config_tree; |
7ac8c238 AK |
51 | struct archive_params; |
52 | struct backup_params; | |
f8452d8c | 53 | struct arg_values; |
25579907 | 54 | |
e59e2f7c PR |
55 | struct config_tree_list { |
56 | struct dm_list list; | |
57 | struct dm_config_tree *cft; | |
58 | }; | |
59 | ||
d1d9800e | 60 | /* FIXME Split into tool & library contexts */ |
60274aba AK |
61 | /* command-instance-related variables needed by library */ |
62 | struct cmd_context { | |
2262b320 AK |
63 | struct dm_pool *libmem; /* For permanent config data */ |
64 | struct dm_pool *mem; /* Transient: Cleared between each command */ | |
60274aba | 65 | |
8ef2b021 | 66 | const struct format_type *fmt; /* Current format to use by default */ |
d1d9800e | 67 | struct format_type *fmt_backup; /* Format to use for backups */ |
25b73380 | 68 | |
2c44337b AK |
69 | struct dm_list formats; /* Available formats */ |
70 | struct dm_list segtypes; /* Available segment types */ | |
a0313876 | 71 | const char *hostname; |
7d1552c9 | 72 | const char *kernel_vsn; |
60274aba | 73 | |
d17a8e36 | 74 | unsigned rand_seed; |
eee66d2a | 75 | char *linebuffer; |
7f355587 | 76 | const char *cmd_line; |
60274aba | 77 | struct command *command; |
9019ed2e | 78 | char **argv; |
f8452d8c AK |
79 | struct arg_values *arg_values; |
80 | struct dm_list arg_value_groups; | |
8c5bcdab AK |
81 | unsigned is_long_lived:1; /* Optimises persistent_filter handling */ |
82 | unsigned handles_missing_pvs:1; | |
b4048242 | 83 | unsigned handles_unknown_segments:1; |
8dd6036d | 84 | unsigned use_linear_target:1; |
cda35408 | 85 | unsigned partial_activation:1; |
95eaa683 | 86 | unsigned si_unit_consistency:1; |
b83af516 | 87 | unsigned metadata_read_only:1; |
59475375 | 88 | unsigned threaded:1; /* Set if running within a thread e.g. clvmd */ |
d1d9800e | 89 | |
acb03765 AK |
90 | unsigned independent_metadata_areas:1; /* Active formats have MDAs outside PVs */ |
91 | ||
d1d9800e AK |
92 | struct dev_filter *filter; |
93 | int dump_filter; /* Dump filter when exiting? */ | |
94 | ||
2c44337b | 95 | struct dm_list config_files; |
25579907 | 96 | int config_valid; |
e59e2f7c | 97 | struct dm_config_tree *cft; |
d1d9800e AK |
98 | struct config_info default_settings; |
99 | struct config_info current_settings; | |
100 | ||
7ac8c238 AK |
101 | struct archive_params *archive_params; |
102 | struct backup_params *backup_params; | |
8c5bcdab | 103 | const char *stripe_filler; |
7ac8c238 | 104 | |
de17d760 | 105 | /* List of defined tags */ |
2c44337b | 106 | struct dm_list tags; |
25579907 | 107 | int hosttags; |
de17d760 | 108 | |
7ac8b7c3 | 109 | char system_dir[PATH_MAX]; |
d1d9800e AK |
110 | char dev_dir[PATH_MAX]; |
111 | char proc_dir[PATH_MAX]; | |
626242c1 | 112 | char sysfs_dir[PATH_MAX]; /* FIXME Use global value instead. */ |
60274aba AK |
113 | }; |
114 | ||
7ac8b7c3 AK |
115 | /* |
116 | * system_dir may be NULL to use the default value. | |
117 | * The environment variable LVM_SYSTEM_DIR always takes precedence. | |
118 | */ | |
119 | struct cmd_context *create_toolcontext(unsigned is_long_lived, | |
eee66d2a | 120 | const char *system_dir, |
59475375 AK |
121 | unsigned set_buffering, |
122 | unsigned threaded); | |
d1d9800e | 123 | void destroy_toolcontext(struct cmd_context *cmd); |
de17d760 | 124 | int refresh_toolcontext(struct cmd_context *cmd); |
e1ab01e3 | 125 | int refresh_filters(struct cmd_context *cmd); |
25579907 | 126 | int config_files_changed(struct cmd_context *cmd); |
6eb44b50 | 127 | int init_lvmcache_orphans(struct cmd_context *cmd); |
d1d9800e | 128 | |
54d7741a AK |
129 | struct format_type *get_format_by_name(struct cmd_context *cmd, const char *format); |
130 | ||
60274aba | 131 | #endif |