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