2008-10-30 20:39:00 +03:00
/*
* Copyright ( C ) 2001 - 2004 Sistina Software , Inc . All rights reserved .
* Copyright ( C ) 2004 - 2007 Red Hat , Inc . All rights reserved .
*
* This file is part of LVM2 .
*
* This copyrighted material is made available to anyone wishing to use ,
* modify , copy , or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v .2 .1 .
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program ; if not , write to the Free Software Foundation ,
* Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*/
# include "lib.h"
# include "device.h"
# include "memlock.h"
# include "lvm-string.h"
# include "lvm-file.h"
# include "defaults.h"
2011-02-18 17:11:22 +03:00
# include "metadata-exported.h"
2008-10-30 20:39:00 +03:00
# include <stdarg.h>
static int _verbose_level = VERBOSE_BASE_LEVEL ;
static int _test = 0 ;
static int _md_filtering = 0 ;
static int _pvmove = 0 ;
static int _full_scan_done = 0 ; /* Restrict to one full scan during each cmd */
2011-04-22 16:05:32 +04:00
static int _obtain_device_list_from_udev = DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV ;
2008-10-30 20:39:00 +03:00
static int _trust_cache = 0 ; /* Don't scan when incomplete VGs encountered */
static int _debug_level = 0 ;
static int _log_cmd_name = 0 ;
static int _ignorelockingfailure = 0 ;
static int _security_level = SECURITY_LEVEL ;
static char _cmd_name [ 30 ] = " " ;
static int _mirror_in_sync = 0 ;
static int _dmeventd_monitor = DEFAULT_DMEVENTD_MONITOR ;
2010-01-05 23:56:51 +03:00
static int _background_polling = DEFAULT_BACKGROUND_POLLING ;
2008-10-30 20:39:00 +03:00
static int _ignore_suspended_devices = 0 ;
static int _error_message_produced = 0 ;
2008-12-18 08:27:17 +03:00
static unsigned _is_static = 0 ;
2010-01-11 18:40:03 +03:00
static int _udev_checking = 1 ;
2011-07-01 18:09:19 +04:00
static int _activation_checks = 0 ;
2010-08-11 16:14:23 +04:00
static char _sysfs_dir_path [ PATH_MAX ] = " " ;
2010-10-13 19:40:38 +04:00
static int _dev_disable_after_error_count = DEFAULT_DISABLE_AFTER_ERROR_COUNT ;
2011-02-18 17:11:22 +03:00
static uint64_t _pv_min_size = ( DEFAULT_PV_MIN_SIZE_KB * 1024L > > SECTOR_SHIFT ) ;
2008-10-30 20:39:00 +03:00
void init_verbose ( int level )
{
_verbose_level = level ;
}
void init_test ( int level )
{
if ( ! _test & & level )
2011-01-24 17:19:05 +03:00
log_print ( " Test mode: Metadata will NOT be updated and volumes will not be (de)activated. " ) ;
2008-10-30 20:39:00 +03:00
_test = level ;
}
void init_md_filtering ( int level )
{
_md_filtering = level ;
}
void init_pvmove ( int level )
{
_pvmove = level ;
}
void init_full_scan_done ( int level )
{
_full_scan_done = level ;
}
2011-04-22 16:05:32 +04:00
void init_obtain_device_list_from_udev ( int device_list_from_udev )
{
_obtain_device_list_from_udev = device_list_from_udev ;
}
2008-10-30 20:39:00 +03:00
void init_trust_cache ( int trustcache )
{
_trust_cache = trustcache ;
}
void init_ignorelockingfailure ( int level )
{
_ignorelockingfailure = level ;
}
void init_security_level ( int level )
{
_security_level = level ;
}
void init_mirror_in_sync ( int in_sync )
{
_mirror_in_sync = in_sync ;
}
void init_dmeventd_monitor ( int reg )
{
_dmeventd_monitor = reg ;
}
2010-01-05 23:56:51 +03:00
void init_background_polling ( int polling )
{
_background_polling = polling ;
}
2008-10-30 20:39:00 +03:00
void init_ignore_suspended_devices ( int ignore )
{
_ignore_suspended_devices = ignore ;
}
void init_cmd_name ( int status )
{
_log_cmd_name = status ;
}
2008-12-18 08:27:17 +03:00
void init_is_static ( unsigned value )
{
_is_static = value ;
}
2010-01-11 18:40:03 +03:00
void init_udev_checking ( int checking )
{
if ( ( _udev_checking = checking ) )
log_debug ( " LVM udev checking enabled " ) ;
else
log_debug ( " LVM udev checking disabled " ) ;
}
2011-07-01 18:09:19 +04:00
void init_activation_checks ( int checks )
{
if ( ( _activation_checks = checks ) )
log_debug ( " LVM activation checks enabled " ) ;
else
log_debug ( " LVM activation checks disabled " ) ;
}
2010-10-13 19:40:38 +04:00
void init_dev_disable_after_error_count ( int value )
{
_dev_disable_after_error_count = value ;
}
2011-02-18 17:11:22 +03:00
void init_pv_min_size ( uint64_t sectors )
{
_pv_min_size = sectors ;
}
2008-10-30 20:39:00 +03:00
void set_cmd_name ( const char * cmd )
{
strncpy ( _cmd_name , cmd , sizeof ( _cmd_name ) ) ;
_cmd_name [ sizeof ( _cmd_name ) - 1 ] = ' \0 ' ;
}
2010-08-11 16:14:23 +04:00
void set_sysfs_dir_path ( const char * path )
{
strncpy ( _sysfs_dir_path , path , sizeof ( _sysfs_dir_path ) ) ;
_sysfs_dir_path [ sizeof ( _sysfs_dir_path ) - 1 ] = ' \0 ' ;
}
2011-03-30 00:30:05 +04:00
const char * log_command_name ( void )
2008-10-30 20:39:00 +03:00
{
if ( ! _log_cmd_name )
return " " ;
return _cmd_name ;
}
void init_error_message_produced ( int value )
{
_error_message_produced = value ;
}
int error_message_produced ( void )
{
return _error_message_produced ;
}
2011-03-30 00:30:05 +04:00
int test_mode ( void )
2008-10-30 20:39:00 +03:00
{
return _test ;
}
2011-03-30 00:30:05 +04:00
int md_filtering ( void )
2008-10-30 20:39:00 +03:00
{
return _md_filtering ;
}
2011-03-30 00:30:05 +04:00
int pvmove_mode ( void )
2008-10-30 20:39:00 +03:00
{
return _pvmove ;
}
2011-03-30 00:30:05 +04:00
int full_scan_done ( void )
2008-10-30 20:39:00 +03:00
{
return _full_scan_done ;
}
2011-04-22 16:05:32 +04:00
int obtain_device_list_from_udev ( )
{
return _obtain_device_list_from_udev ;
}
2011-03-30 00:30:05 +04:00
int trust_cache ( void )
2008-10-30 20:39:00 +03:00
{
return _trust_cache ;
}
2011-03-30 00:30:05 +04:00
int background_polling ( void )
2010-01-05 23:56:51 +03:00
{
return _background_polling ;
}
2011-03-30 00:30:05 +04:00
int ignorelockingfailure ( void )
2008-10-30 20:39:00 +03:00
{
return _ignorelockingfailure ;
}
2011-03-30 00:30:05 +04:00
int security_level ( void )
2008-10-30 20:39:00 +03:00
{
return _security_level ;
}
int mirror_in_sync ( void )
{
return _mirror_in_sync ;
}
int dmeventd_monitor_mode ( void )
{
return _dmeventd_monitor ;
}
int ignore_suspended_devices ( void )
{
return _ignore_suspended_devices ;
}
void init_debug ( int level )
{
_debug_level = level ;
}
2011-03-30 00:30:05 +04:00
int verbose_level ( void )
2008-10-30 20:39:00 +03:00
{
return _verbose_level ;
}
2011-03-30 00:30:05 +04:00
int debug_level ( void )
2008-10-30 20:39:00 +03:00
{
return _debug_level ;
}
2008-12-18 08:27:17 +03:00
unsigned is_static ( void )
{
return _is_static ;
}
2010-01-11 18:40:03 +03:00
int udev_checking ( void )
{
return _udev_checking ;
}
2010-08-11 16:14:23 +04:00
2011-07-01 18:09:19 +04:00
int activation_checks ( void )
{
return _activation_checks ;
}
2011-03-30 00:30:05 +04:00
const char * sysfs_dir_path ( void )
2010-08-11 16:14:23 +04:00
{
return _sysfs_dir_path ;
}
2010-10-13 19:40:38 +04:00
int dev_disable_after_error_count ( void )
{
return _dev_disable_after_error_count ;
}
2011-02-18 17:11:22 +03:00
uint64_t pv_min_size ( void )
{
return _pv_min_size ;
}