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