xref: /netbsd-src/external/gpl2/lvm2/dist/lib/misc/lvm-globals.c (revision 274254cdae52594c1aa480a736aef78313d15c9c)
1 /*	$NetBSD: lvm-globals.c,v 1.1.1.2 2009/02/18 11:17:17 haad Exp $	*/
2 
3 /*
4  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
5  * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
6  *
7  * This file is part of LVM2.
8  *
9  * This copyrighted material is made available to anyone wishing to use,
10  * modify, copy, or redistribute it subject to the terms and conditions
11  * of the GNU Lesser General Public License v.2.1.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; if not, write to the Free Software Foundation,
15  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16  */
17 
18 #include "lib.h"
19 #include "device.h"
20 #include "memlock.h"
21 #include "lvm-string.h"
22 #include "lvm-file.h"
23 #include "defaults.h"
24 
25 #include <stdarg.h>
26 
27 static int _verbose_level = VERBOSE_BASE_LEVEL;
28 static int _test = 0;
29 static int _md_filtering = 0;
30 static int _pvmove = 0;
31 static int _full_scan_done = 0;	/* Restrict to one full scan during each cmd */
32 static int _trust_cache = 0; /* Don't scan when incomplete VGs encountered */
33 static int _debug_level = 0;
34 static int _log_cmd_name = 0;
35 static int _ignorelockingfailure = 0;
36 static int _lockingfailed = 0;
37 static int _security_level = SECURITY_LEVEL;
38 static char _cmd_name[30] = "";
39 static int _mirror_in_sync = 0;
40 static int _dmeventd_monitor = DEFAULT_DMEVENTD_MONITOR;
41 static int _ignore_suspended_devices = 0;
42 static int _error_message_produced = 0;
43 static unsigned _is_static = 0;
44 
45 void init_verbose(int level)
46 {
47 	_verbose_level = level;
48 }
49 
50 void init_test(int level)
51 {
52 	if (!_test && level)
53 		log_print("Test mode: Metadata will NOT be updated.");
54 	_test = level;
55 }
56 
57 void init_md_filtering(int level)
58 {
59 	_md_filtering = level;
60 }
61 
62 void init_pvmove(int level)
63 {
64 	_pvmove = level;
65 }
66 
67 void init_full_scan_done(int level)
68 {
69 	_full_scan_done = level;
70 }
71 
72 void init_trust_cache(int trustcache)
73 {
74 	_trust_cache = trustcache;
75 }
76 
77 void init_ignorelockingfailure(int level)
78 {
79 	_ignorelockingfailure = level;
80 }
81 
82 void init_lockingfailed(int level)
83 {
84 	_lockingfailed = level;
85 }
86 
87 void init_security_level(int level)
88 {
89 	_security_level = level;
90 }
91 
92 void init_mirror_in_sync(int in_sync)
93 {
94 	_mirror_in_sync = in_sync;
95 }
96 
97 void init_dmeventd_monitor(int reg)
98 {
99 	_dmeventd_monitor = reg;
100 }
101 
102 void init_ignore_suspended_devices(int ignore)
103 {
104 	_ignore_suspended_devices = ignore;
105 }
106 
107 void init_cmd_name(int status)
108 {
109 	_log_cmd_name = status;
110 }
111 
112 void init_is_static(unsigned value)
113 {
114 	_is_static = value;
115 }
116 
117 void set_cmd_name(const char *cmd)
118 {
119 	strncpy(_cmd_name, cmd, sizeof(_cmd_name));
120 	_cmd_name[sizeof(_cmd_name) - 1] = '\0';
121 }
122 
123 const char *log_command_name()
124 {
125 	if (!_log_cmd_name)
126 		return "";
127 
128 	return _cmd_name;
129 }
130 
131 void init_error_message_produced(int value)
132 {
133 	_error_message_produced = value;
134 }
135 
136 int error_message_produced(void)
137 {
138 	return _error_message_produced;
139 }
140 
141 int test_mode()
142 {
143 	return _test;
144 }
145 
146 int md_filtering()
147 {
148 	return _md_filtering;
149 }
150 
151 int pvmove_mode()
152 {
153 	return _pvmove;
154 }
155 
156 int full_scan_done()
157 {
158 	return _full_scan_done;
159 }
160 
161 int trust_cache()
162 {
163 	return _trust_cache;
164 }
165 
166 int lockingfailed()
167 {
168 	return _lockingfailed;
169 }
170 
171 int ignorelockingfailure()
172 {
173 	return _ignorelockingfailure;
174 }
175 
176 int security_level()
177 {
178 	return _security_level;
179 }
180 
181 int mirror_in_sync(void)
182 {
183 	return _mirror_in_sync;
184 }
185 
186 int dmeventd_monitor_mode(void)
187 {
188 	return _dmeventd_monitor;
189 }
190 
191 int ignore_suspended_devices(void)
192 {
193 	return _ignore_suspended_devices;
194 }
195 
196 void init_debug(int level)
197 {
198 	_debug_level = level;
199 }
200 
201 int verbose_level()
202 {
203 	return _verbose_level;
204 }
205 
206 int debug_level()
207 {
208 	return _debug_level;
209 }
210 
211 unsigned is_static(void)
212 {
213 	return _is_static;
214 }
215