1 /* $NetBSD: lvm-globals.c,v 1.1.1.3 2009/12/02 00:26:44 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 _security_level = SECURITY_LEVEL;
37 static char _cmd_name[30] = "";
38 static int _mirror_in_sync = 0;
39 static int _dmeventd_monitor = DEFAULT_DMEVENTD_MONITOR;
40 static int _ignore_suspended_devices = 0;
41 static int _error_message_produced = 0;
42 static unsigned _is_static = 0;
43
init_verbose(int level)44 void init_verbose(int level)
45 {
46 _verbose_level = level;
47 }
48
init_test(int level)49 void init_test(int level)
50 {
51 if (!_test && level)
52 log_print("Test mode: Metadata will NOT be updated.");
53 _test = level;
54 }
55
init_md_filtering(int level)56 void init_md_filtering(int level)
57 {
58 _md_filtering = level;
59 }
60
init_pvmove(int level)61 void init_pvmove(int level)
62 {
63 _pvmove = level;
64 }
65
init_full_scan_done(int level)66 void init_full_scan_done(int level)
67 {
68 _full_scan_done = level;
69 }
70
init_trust_cache(int trustcache)71 void init_trust_cache(int trustcache)
72 {
73 _trust_cache = trustcache;
74 }
75
init_ignorelockingfailure(int level)76 void init_ignorelockingfailure(int level)
77 {
78 _ignorelockingfailure = level;
79 }
80
init_security_level(int level)81 void init_security_level(int level)
82 {
83 _security_level = level;
84 }
85
init_mirror_in_sync(int in_sync)86 void init_mirror_in_sync(int in_sync)
87 {
88 _mirror_in_sync = in_sync;
89 }
90
init_dmeventd_monitor(int reg)91 void init_dmeventd_monitor(int reg)
92 {
93 _dmeventd_monitor = reg;
94 }
95
init_ignore_suspended_devices(int ignore)96 void init_ignore_suspended_devices(int ignore)
97 {
98 _ignore_suspended_devices = ignore;
99 }
100
init_cmd_name(int status)101 void init_cmd_name(int status)
102 {
103 _log_cmd_name = status;
104 }
105
init_is_static(unsigned value)106 void init_is_static(unsigned value)
107 {
108 _is_static = value;
109 }
110
set_cmd_name(const char * cmd)111 void set_cmd_name(const char *cmd)
112 {
113 strncpy(_cmd_name, cmd, sizeof(_cmd_name));
114 _cmd_name[sizeof(_cmd_name) - 1] = '\0';
115 }
116
log_command_name()117 const char *log_command_name()
118 {
119 if (!_log_cmd_name)
120 return "";
121
122 return _cmd_name;
123 }
124
init_error_message_produced(int value)125 void init_error_message_produced(int value)
126 {
127 _error_message_produced = value;
128 }
129
error_message_produced(void)130 int error_message_produced(void)
131 {
132 return _error_message_produced;
133 }
134
test_mode()135 int test_mode()
136 {
137 return _test;
138 }
139
md_filtering()140 int md_filtering()
141 {
142 return _md_filtering;
143 }
144
pvmove_mode()145 int pvmove_mode()
146 {
147 return _pvmove;
148 }
149
full_scan_done()150 int full_scan_done()
151 {
152 return _full_scan_done;
153 }
154
trust_cache()155 int trust_cache()
156 {
157 return _trust_cache;
158 }
159
ignorelockingfailure()160 int ignorelockingfailure()
161 {
162 return _ignorelockingfailure;
163 }
164
security_level()165 int security_level()
166 {
167 return _security_level;
168 }
169
mirror_in_sync(void)170 int mirror_in_sync(void)
171 {
172 return _mirror_in_sync;
173 }
174
dmeventd_monitor_mode(void)175 int dmeventd_monitor_mode(void)
176 {
177 return _dmeventd_monitor;
178 }
179
ignore_suspended_devices(void)180 int ignore_suspended_devices(void)
181 {
182 return _ignore_suspended_devices;
183 }
184
init_debug(int level)185 void init_debug(int level)
186 {
187 _debug_level = level;
188 }
189
verbose_level()190 int verbose_level()
191 {
192 return _verbose_level;
193 }
194
debug_level()195 int debug_level()
196 {
197 return _debug_level;
198 }
199
is_static(void)200 unsigned is_static(void)
201 {
202 return _is_static;
203 }
204