Branch data Line data Source code
1 : : /*
2 : : * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 : : * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
4 : : *
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
9 : : * of the GNU Lesser General Public License v.2.1.
10 : : *
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
14 : : */
15 : :
16 : : #include "lib.h"
17 : : #include "device.h"
18 : : #include "memlock.h"
19 : : #include "lvm-string.h"
20 : : #include "lvm-file.h"
21 : : #include "defaults.h"
22 : :
23 : : #include <stdarg.h>
24 : :
25 : : static int _verbose_level = VERBOSE_BASE_LEVEL;
26 : : static int _test = 0;
27 : : static int _md_filtering = 0;
28 : : static int _pvmove = 0;
29 : : static int _full_scan_done = 0; /* Restrict to one full scan during each cmd */
30 : : static int _trust_cache = 0; /* Don't scan when incomplete VGs encountered */
31 : : static int _debug_level = 0;
32 : : static int _log_cmd_name = 0;
33 : : static int _ignorelockingfailure = 0;
34 : : static int _security_level = SECURITY_LEVEL;
35 : : static char _cmd_name[30] = "";
36 : : static int _mirror_in_sync = 0;
37 : : static int _dmeventd_monitor = DEFAULT_DMEVENTD_MONITOR;
38 : : static int _background_polling = DEFAULT_BACKGROUND_POLLING;
39 : : static int _ignore_suspended_devices = 0;
40 : : static int _error_message_produced = 0;
41 : : static unsigned _is_static = 0;
42 : : static int _udev_checking = 1;
43 : :
44 : 5 : void init_verbose(int level)
45 : : {
46 : 5 : _verbose_level = level;
47 : 5 : }
48 : :
49 : 5 : void init_test(int level)
50 : : {
51 [ + - ][ - + ]: 5 : if (!_test && level)
52 : 0 : log_print("Test mode: Metadata will NOT be updated.");
53 : 5 : _test = level;
54 : 5 : }
55 : :
56 : 3 : void init_md_filtering(int level)
57 : : {
58 : 3 : _md_filtering = level;
59 : 3 : }
60 : :
61 : 2 : void init_pvmove(int level)
62 : : {
63 : 2 : _pvmove = level;
64 : 2 : }
65 : :
66 : 4 : void init_full_scan_done(int level)
67 : : {
68 : 4 : _full_scan_done = level;
69 : 4 : }
70 : :
71 : 1 : void init_trust_cache(int trustcache)
72 : : {
73 : 1 : _trust_cache = trustcache;
74 : 1 : }
75 : :
76 : 1 : void init_ignorelockingfailure(int level)
77 : : {
78 : 1 : _ignorelockingfailure = level;
79 : 1 : }
80 : :
81 : 0 : void init_security_level(int level)
82 : : {
83 : 0 : _security_level = level;
84 : 0 : }
85 : :
86 : 3 : void init_mirror_in_sync(int in_sync)
87 : : {
88 : 3 : _mirror_in_sync = in_sync;
89 : 3 : }
90 : :
91 : 0 : void init_dmeventd_monitor(int reg)
92 : : {
93 : 0 : _dmeventd_monitor = reg;
94 : 0 : }
95 : :
96 : 0 : void init_background_polling(int polling)
97 : : {
98 : 0 : _background_polling = polling;
99 : 0 : }
100 : :
101 : 3 : void init_ignore_suspended_devices(int ignore)
102 : : {
103 : 3 : _ignore_suspended_devices = ignore;
104 : 3 : }
105 : :
106 : 5 : void init_cmd_name(int status)
107 : : {
108 : 5 : _log_cmd_name = status;
109 : 5 : }
110 : :
111 : 0 : void init_is_static(unsigned value)
112 : : {
113 : 0 : _is_static = value;
114 : 0 : }
115 : :
116 : 0 : void init_udev_checking(int checking)
117 : : {
118 [ # # ]: 0 : if ((_udev_checking = checking))
119 : 0 : log_debug("LVM udev checking enabled");
120 : : else
121 : 0 : log_debug("LVM udev checking disabled");
122 : 0 : }
123 : :
124 : 1 : void set_cmd_name(const char *cmd)
125 : : {
126 : 1 : strncpy(_cmd_name, cmd, sizeof(_cmd_name));
127 : 1 : _cmd_name[sizeof(_cmd_name) - 1] = '\0';
128 : 1 : }
129 : :
130 : 0 : const char *log_command_name()
131 : : {
132 [ # # ]: 0 : if (!_log_cmd_name)
133 : 0 : return "";
134 : :
135 : 0 : return _cmd_name;
136 : : }
137 : :
138 : 1 : void init_error_message_produced(int value)
139 : : {
140 : 1 : _error_message_produced = value;
141 : 1 : }
142 : :
143 : 0 : int error_message_produced(void)
144 : : {
145 : 0 : return _error_message_produced;
146 : : }
147 : :
148 : 1 : int test_mode()
149 : : {
150 : 1 : return _test;
151 : : }
152 : :
153 : 0 : int md_filtering()
154 : : {
155 : 0 : return _md_filtering;
156 : : }
157 : :
158 : 1 : int pvmove_mode()
159 : : {
160 : 1 : return _pvmove;
161 : : }
162 : :
163 : 0 : int full_scan_done()
164 : : {
165 : 0 : return _full_scan_done;
166 : : }
167 : :
168 : 0 : int trust_cache()
169 : : {
170 : 0 : return _trust_cache;
171 : : }
172 : :
173 : 0 : int background_polling()
174 : : {
175 : 0 : return _background_polling;
176 : : }
177 : :
178 : 1 : int ignorelockingfailure()
179 : : {
180 : 1 : return _ignorelockingfailure;
181 : : }
182 : :
183 : 0 : int security_level()
184 : : {
185 : 0 : return _security_level;
186 : : }
187 : :
188 : 0 : int mirror_in_sync(void)
189 : : {
190 : 0 : return _mirror_in_sync;
191 : : }
192 : :
193 : 0 : int dmeventd_monitor_mode(void)
194 : : {
195 : 0 : return _dmeventd_monitor;
196 : : }
197 : :
198 : 0 : int ignore_suspended_devices(void)
199 : : {
200 : 0 : return _ignore_suspended_devices;
201 : : }
202 : :
203 : 5 : void init_debug(int level)
204 : : {
205 : 5 : _debug_level = level;
206 : 5 : }
207 : :
208 : 1200 : int verbose_level()
209 : : {
210 : 1200 : return _verbose_level;
211 : : }
212 : :
213 : 600 : int debug_level()
214 : : {
215 : 600 : return _debug_level;
216 : : }
217 : :
218 : 7 : unsigned is_static(void)
219 : : {
220 : 7 : return _is_static;
221 : : }
222 : :
223 : 0 : int udev_checking(void)
224 : : {
225 : 0 : return _udev_checking;
226 : : }
|