1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Fix lvcreate corelog validation.

Add --config for overriding most config file settings from cmdline.
  Quote arguments when printing command line.
  Remove linefeed from 'initialising logging' message.
  Add 'Completed' debug message.
  Don't attempt library exit after reloading config files.
  Always compile with libdevmapper, even if device-mapper is disabled.
This commit is contained in:
Alasdair Kergon 2006-05-16 16:48:31 +00:00
parent 311d6d811b
commit 2293567c8c
40 changed files with 370 additions and 224 deletions

View File

@ -1,5 +1,12 @@
Version 2.02.07 - Version 2.02.07 -
=============================== =================================
Fix lvcreate corelog validation.
Add --config for overriding most config file settings from cmdline.
Quote arguments when printing command line.
Remove linefeed from 'initialising logging' message.
Add 'Completed' debug message.
Don't attempt library exit after reloading config files.
Always compile with libdevmapper, even if device-mapper is disabled.
Version 2.02.06 - 12th May 2006 Version 2.02.06 - 12th May 2006
=============================== ===============================

41
configure vendored
View File

@ -10699,7 +10699,6 @@ done
fi fi
if test x$DEVMAPPER = xyes; then
for ac_header in libdevmapper.h for ac_header in libdevmapper.h
do do
@ -10854,7 +10853,6 @@ fi
done done
fi
if test x$HAVE_SELINUX = xyes; then if test x$HAVE_SELINUX = xyes; then
@ -11053,45 +11051,6 @@ else
echo "${ECHO_T}no" >&6 echo "${ECHO_T}no" >&6
fi fi
# Extract the first word of "ifconfig", so it can be a program name with args.
set dummy ifconfig; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_MODPROBE_CMD+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
case $MODPROBE_CMD in
[\\/]* | ?:[\\/]*)
ac_cv_path_MODPROBE_CMD="$MODPROBE_CMD" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_MODPROBE_CMD="$as_dir/$ac_word$ac_exec_ext"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
;;
esac
fi
MODPROBE_CMD=$ac_cv_path_MODPROBE_CMD
if test -n "$MODPROBE_CMD"; then
echo "$as_me:$LINENO: result: $MODPROBE_CMD" >&5
echo "${ECHO_T}$MODPROBE_CMD" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
if test x$MODPROBE_CMD != x; then if test x$MODPROBE_CMD != x; then

View File

@ -538,9 +538,7 @@ if test x$INTL = xyes; then
AC_CHECK_HEADERS(libintl.h,,AC_MSG_ERROR(bailing out)) AC_CHECK_HEADERS(libintl.h,,AC_MSG_ERROR(bailing out))
fi fi
if test x$DEVMAPPER = xyes; then
AC_CHECK_HEADERS(libdevmapper.h,,AC_MSG_ERROR(bailing out)) AC_CHECK_HEADERS(libdevmapper.h,,AC_MSG_ERROR(bailing out))
fi
if test x$HAVE_SELINUX = xyes; then if test x$HAVE_SELINUX = xyes; then
AC_CHECK_HEADERS(selinux/selinux.h,,AC_MSG_ERROR(bailing out)) AC_CHECK_HEADERS(selinux/selinux.h,,AC_MSG_ERROR(bailing out))

View File

@ -59,9 +59,7 @@ ifeq ("@DMEVENTD@", "yes")
LVMLIBS += -ldevmapper-event LVMLIBS += -ldevmapper-event
endif endif
ifeq ("@DEVMAPPER@", "yes")
LVMLIBS += -ldevmapper LVMLIBS += -ldevmapper
endif
DEFS += -D_REENTRANT DEFS += -D_REENTRANT
CFLAGS += -fno-strict-aliasing CFLAGS += -fno-strict-aliasing

View File

@ -510,7 +510,7 @@ static void check_config()
{ {
int locking_type; int locking_type;
locking_type = find_config_int(cmd->cft->root, "global/locking_type", 1); locking_type = find_config_tree_int(cmd, "global/locking_type", 1);
if (locking_type == 3) /* compiled-in cluster support */ if (locking_type == 3) /* compiled-in cluster support */
return; return;
@ -518,7 +518,7 @@ static void check_config()
if (locking_type == 2) { /* External library, check name */ if (locking_type == 2) { /* External library, check name */
const char *libname; const char *libname;
libname = find_config_str(cmd->cft->root, "global/locking_library", libname = find_config_tree_str(cmd, "global/locking_library",
""); "");
if (strstr(libname, "liblvm2clusterlock.so")) if (strstr(libname, "liblvm2clusterlock.so"))
return; return;

View File

@ -157,6 +157,11 @@ int pv_uses_vg(struct cmd_context *cmd, struct physical_volume *pv,
return 0; return 0;
} }
void activation_release(void)
{
return;
}
void activation_exit(void) void activation_exit(void)
{ {
return; return;
@ -193,7 +198,7 @@ static int _passes_activation_filter(struct cmd_context *cmd,
char *str; char *str;
char path[PATH_MAX]; char path[PATH_MAX];
if (!(cn = find_config_node(cmd->cft->root, "activation/volume_list"))) { if (!(cn = find_config_tree_node(cmd, "activation/volume_list"))) {
/* If no host tags defined, activate */ /* If no host tags defined, activate */
if (list_empty(&cmd->tags)) if (list_empty(&cmd->tags))
return 1; return 1;
@ -894,6 +899,11 @@ int pv_uses_vg(struct physical_volume *pv,
return dev_manager_device_uses_vg(pv->dev, vg); return dev_manager_device_uses_vg(pv->dev, vg);
} }
void activation_release(void)
{
dev_manager_release();
}
void activation_exit(void) void activation_exit(void)
{ {
dev_manager_exit(); dev_manager_exit();

View File

@ -40,6 +40,7 @@ int target_present(const char *target_name, int use_modprobe);
int target_version(const char *target_name, uint32_t *maj, int target_version(const char *target_name, uint32_t *maj,
uint32_t *min, uint32_t *patchlevel); uint32_t *min, uint32_t *patchlevel);
void activation_release(void);
void activation_exit(void); void activation_exit(void);
int lv_suspend(struct cmd_context *cmd, const char *lvid_s); int lv_suspend(struct cmd_context *cmd, const char *lvid_s);

View File

@ -401,7 +401,7 @@ struct dev_manager *dev_manager_create(struct cmd_context *cmd,
dm->mem = mem; dm->mem = mem;
if (!stripe_filler) { if (!stripe_filler) {
stripe_filler = find_config_str(cmd->cft->root, stripe_filler = find_config_tree_str(cmd,
"activation/missing_stripe_filler", "activation/missing_stripe_filler",
DEFAULT_STRIPE_FILLER); DEFAULT_STRIPE_FILLER);
} }
@ -426,6 +426,11 @@ void dev_manager_destroy(struct dev_manager *dm)
dm_pool_destroy(dm->mem); dm_pool_destroy(dm->mem);
} }
void dev_manager_release(void)
{
dm_lib_release();
}
void dev_manager_exit(void) void dev_manager_exit(void)
{ {
dm_lib_exit(); dm_lib_exit();
@ -758,7 +763,7 @@ static int _add_target_to_dtree(struct dev_manager *dm,
return 0; return 0;
} }
return seg->segtype->ops->add_target_line(dm, dm->mem, dm->cmd->cft, return seg->segtype->ops->add_target_line(dm, dm->mem, dm->cmd,
&dm->target_state, seg, &dm->target_state, seg,
dnode, dnode,
extent_size * seg->len, extent_size * seg->len,

View File

@ -29,6 +29,7 @@ struct device;
struct dev_manager *dev_manager_create(struct cmd_context *cmd, struct dev_manager *dev_manager_create(struct cmd_context *cmd,
const char *vg_name); const char *vg_name);
void dev_manager_destroy(struct dev_manager *dm); void dev_manager_destroy(struct dev_manager *dm);
void dev_manager_release(void);
void dev_manager_exit(void); void dev_manager_exit(void);
/* /*

View File

@ -84,10 +84,11 @@ static void _init_logging(struct cmd_context *cmd)
time_t t; time_t t;
const char *log_file; const char *log_file;
char timebuf[26];
/* Syslog */ /* Syslog */
cmd->default_settings.syslog = cmd->default_settings.syslog =
find_config_int(cmd->cft->root, "log/syslog", DEFAULT_SYSLOG); find_config_tree_int(cmd, "log/syslog", DEFAULT_SYSLOG);
if (cmd->default_settings.syslog != 1) if (cmd->default_settings.syslog != 1)
fin_syslog(); fin_syslog();
@ -96,37 +97,37 @@ static void _init_logging(struct cmd_context *cmd)
/* Debug level for log file output */ /* Debug level for log file output */
cmd->default_settings.debug = cmd->default_settings.debug =
find_config_int(cmd->cft->root, "log/level", DEFAULT_LOGLEVEL); find_config_tree_int(cmd, "log/level", DEFAULT_LOGLEVEL);
init_debug(cmd->default_settings.debug); init_debug(cmd->default_settings.debug);
/* Verbose level for tty output */ /* Verbose level for tty output */
cmd->default_settings.verbose = cmd->default_settings.verbose =
find_config_int(cmd->cft->root, "log/verbose", DEFAULT_VERBOSE); find_config_tree_int(cmd, "log/verbose", DEFAULT_VERBOSE);
init_verbose(cmd->default_settings.verbose + VERBOSE_BASE_LEVEL); init_verbose(cmd->default_settings.verbose + VERBOSE_BASE_LEVEL);
/* Log message formatting */ /* Log message formatting */
init_indent(find_config_int(cmd->cft->root, "log/indent", init_indent(find_config_tree_int(cmd, "log/indent",
DEFAULT_INDENT)); DEFAULT_INDENT));
cmd->default_settings.msg_prefix = find_config_str(cmd->cft->root, cmd->default_settings.msg_prefix = find_config_tree_str(cmd,
"log/prefix", "log/prefix",
DEFAULT_MSG_PREFIX); DEFAULT_MSG_PREFIX);
init_msg_prefix(cmd->default_settings.msg_prefix); init_msg_prefix(cmd->default_settings.msg_prefix);
cmd->default_settings.cmd_name = find_config_int(cmd->cft->root, cmd->default_settings.cmd_name = find_config_tree_int(cmd,
"log/command_names", "log/command_names",
DEFAULT_CMD_NAME); DEFAULT_CMD_NAME);
init_cmd_name(cmd->default_settings.cmd_name); init_cmd_name(cmd->default_settings.cmd_name);
/* Test mode */ /* Test mode */
cmd->default_settings.test = cmd->default_settings.test =
find_config_int(cmd->cft->root, "global/test", 0); find_config_tree_int(cmd, "global/test", 0);
/* Settings for logging to file */ /* Settings for logging to file */
if (find_config_int(cmd->cft->root, "log/overwrite", DEFAULT_OVERWRITE)) if (find_config_tree_int(cmd, "log/overwrite", DEFAULT_OVERWRITE))
append = 0; append = 0;
log_file = find_config_str(cmd->cft->root, "log/file", 0); log_file = find_config_tree_str(cmd, "log/file", 0);
if (log_file) { if (log_file) {
release_log_memory(); release_log_memory();
@ -134,15 +135,17 @@ static void _init_logging(struct cmd_context *cmd)
init_log_file(log_file, append); init_log_file(log_file, append);
} }
log_file = find_config_str(cmd->cft->root, "log/activate_file", 0); log_file = find_config_tree_str(cmd, "log/activate_file", 0);
if (log_file) if (log_file)
init_log_direct(log_file, append); init_log_direct(log_file, append);
init_log_while_suspended(find_config_int(cmd->cft->root, init_log_while_suspended(find_config_tree_int(cmd,
"log/activation", 0)); "log/activation", 0));
t = time(NULL); t = time(NULL);
log_verbose("Logging initialised at %s", ctime(&t)); ctime_r(&t, &timebuf[0]);
timebuf[24] = '\0';
log_verbose("Logging initialised at %s", timebuf);
/* Tell device-mapper about our logging */ /* Tell device-mapper about our logging */
#ifdef DEVMAPPER_SUPPORT #ifdef DEVMAPPER_SUPPORT
@ -155,7 +158,7 @@ static int _process_config(struct cmd_context *cmd)
mode_t old_umask; mode_t old_umask;
/* umask */ /* umask */
cmd->default_settings.umask = find_config_int(cmd->cft->root, cmd->default_settings.umask = find_config_tree_int(cmd,
"global/umask", "global/umask",
DEFAULT_UMASK); DEFAULT_UMASK);
@ -165,7 +168,7 @@ static int _process_config(struct cmd_context *cmd)
/* dev dir */ /* dev dir */
if (lvm_snprintf(cmd->dev_dir, sizeof(cmd->dev_dir), "%s/", if (lvm_snprintf(cmd->dev_dir, sizeof(cmd->dev_dir), "%s/",
find_config_str(cmd->cft->root, "devices/dir", find_config_tree_str(cmd, "devices/dir",
DEFAULT_DEV_DIR)) < 0) { DEFAULT_DEV_DIR)) < 0) {
log_error("Device directory given in config file too long"); log_error("Device directory given in config file too long");
return 0; return 0;
@ -176,7 +179,7 @@ static int _process_config(struct cmd_context *cmd)
/* proc dir */ /* proc dir */
if (lvm_snprintf(cmd->proc_dir, sizeof(cmd->proc_dir), "%s", if (lvm_snprintf(cmd->proc_dir, sizeof(cmd->proc_dir), "%s",
find_config_str(cmd->cft->root, "global/proc", find_config_tree_str(cmd, "global/proc",
DEFAULT_PROC_DIR)) < 0) { DEFAULT_PROC_DIR)) < 0) {
log_error("Device directory given in config file too long"); log_error("Device directory given in config file too long");
return 0; return 0;
@ -189,17 +192,17 @@ static int _process_config(struct cmd_context *cmd)
} }
/* activation? */ /* activation? */
cmd->default_settings.activation = find_config_int(cmd->cft->root, cmd->default_settings.activation = find_config_tree_int(cmd,
"global/activation", "global/activation",
DEFAULT_ACTIVATION); DEFAULT_ACTIVATION);
set_activation(cmd->default_settings.activation); set_activation(cmd->default_settings.activation);
cmd->default_settings.suffix = find_config_int(cmd->cft->root, cmd->default_settings.suffix = find_config_tree_int(cmd,
"global/suffix", "global/suffix",
DEFAULT_SUFFIX); DEFAULT_SUFFIX);
if (!(cmd->default_settings.unit_factor = if (!(cmd->default_settings.unit_factor =
units_to_bytes(find_config_str(cmd->cft->root, units_to_bytes(find_config_tree_str(cmd,
"global/units", "global/units",
DEFAULT_UNITS), DEFAULT_UNITS),
&cmd->default_settings.unit_type))) { &cmd->default_settings.unit_type))) {
@ -469,7 +472,7 @@ static int _init_dev_cache(struct cmd_context *cmd)
return 0; return 0;
} }
if (!(cn = find_config_node(cmd->cft->root, "devices/scan"))) { if (!(cn = find_config_tree_node(cmd, "devices/scan"))) {
if (!dev_cache_add_dir("/dev")) { if (!dev_cache_add_dir("/dev")) {
log_error("Failed to add /dev to internal " log_error("Failed to add /dev to internal "
"device cache"); "device cache");
@ -494,7 +497,7 @@ static int _init_dev_cache(struct cmd_context *cmd)
} }
} }
if (!(cn = find_config_node(cmd->cft->root, "devices/loopfiles"))) if (!(cn = find_config_tree_node(cmd, "devices/loopfiles")))
return 1; return 1;
for (cv = cn->v; cv; cv = cv->next) { for (cv = cn->v; cv; cv = cv->next) {
@ -536,14 +539,14 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
* Listed first because it's very efficient at eliminating * Listed first because it's very efficient at eliminating
* unavailable devices. * unavailable devices.
*/ */
if (find_config_bool(cmd->cft->root, "devices/sysfs_scan", if (find_config_tree_bool(cmd, "devices/sysfs_scan",
DEFAULT_SYSFS_SCAN)) { DEFAULT_SYSFS_SCAN)) {
if ((filters[nr_filt] = sysfs_filter_create(cmd->proc_dir))) if ((filters[nr_filt] = sysfs_filter_create(cmd->proc_dir)))
nr_filt++; nr_filt++;
} }
/* regex filter. Optional. */ /* regex filter. Optional. */
if (!(cn = find_config_node(cmd->cft->root, "devices/filter"))) if (!(cn = find_config_tree_node(cmd, "devices/filter")))
log_very_verbose("devices/filter not found in config file: " log_very_verbose("devices/filter not found in config file: "
"no regex filter installed"); "no regex filter installed");
@ -553,14 +556,14 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
} }
/* device type filter. Required. */ /* device type filter. Required. */
cn = find_config_node(cmd->cft->root, "devices/types"); cn = find_config_tree_node(cmd, "devices/types");
if (!(filters[nr_filt++] = lvm_type_filter_create(cmd->proc_dir, cn))) { if (!(filters[nr_filt++] = lvm_type_filter_create(cmd->proc_dir, cn))) {
log_error("Failed to create lvm type filter"); log_error("Failed to create lvm type filter");
return NULL; return NULL;
} }
/* md component filter. Optional, non-critical. */ /* md component filter. Optional, non-critical. */
if (find_config_bool(cmd->cft->root, "devices/md_component_detection", if (find_config_tree_bool(cmd, "devices/md_component_detection",
DEFAULT_MD_COMPONENT_DETECTION)) { DEFAULT_MD_COMPONENT_DETECTION)) {
init_md_filtering(1); init_md_filtering(1);
if ((filters[nr_filt] = md_filter_create())) if ((filters[nr_filt] = md_filter_create()))
@ -591,7 +594,7 @@ static int _init_filters(struct cmd_context *cmd)
return 0; return 0;
} }
dev_cache = find_config_str(cmd->cft->root, "devices/cache", dev_cache = find_config_tree_str(cmd, "devices/cache",
cache_file); cache_file);
if (!(f4 = persistent_filter_create(f3, dev_cache))) { if (!(f4 = persistent_filter_create(f3, dev_cache))) {
log_error("Failed to create persistent device filter"); log_error("Failed to create persistent device filter");
@ -599,7 +602,7 @@ static int _init_filters(struct cmd_context *cmd)
} }
/* Should we ever dump persistent filter state? */ /* Should we ever dump persistent filter state? */
if (find_config_int(cmd->cft->root, "devices/write_cache_state", 1)) if (find_config_tree_int(cmd, "devices/write_cache_state", 1))
cmd->dump_filter = 1; cmd->dump_filter = 1;
if (!*cmd->sys_dir) if (!*cmd->sys_dir)
@ -644,7 +647,7 @@ static int _init_formats(struct cmd_context *cmd)
#ifdef HAVE_LIBDL #ifdef HAVE_LIBDL
/* Load any formats in shared libs */ /* Load any formats in shared libs */
if ((cn = find_config_node(cmd->cft->root, "global/format_libraries"))) { if ((cn = find_config_tree_node(cmd, "global/format_libraries"))) {
struct config_value *cv; struct config_value *cv;
struct format_type *(*init_format_fn) (struct cmd_context *); struct format_type *(*init_format_fn) (struct cmd_context *);
@ -656,7 +659,7 @@ static int _init_formats(struct cmd_context *cmd)
"global/format_libraries"); "global/format_libraries");
return 0; return 0;
} }
if (!(lib = load_shared_library(cmd->cft, cv->v.str, if (!(lib = load_shared_library(cmd, cv->v.str,
"format", 0))) { "format", 0))) {
stack; stack;
return 0; return 0;
@ -684,7 +687,7 @@ static int _init_formats(struct cmd_context *cmd)
cmd->fmt_backup = fmt; cmd->fmt_backup = fmt;
format = find_config_str(cmd->cft->root, "global/format", format = find_config_tree_str(cmd, "global/format",
DEFAULT_FORMAT); DEFAULT_FORMAT);
list_iterate_items(fmt, &cmd->formats) { list_iterate_items(fmt, &cmd->formats) {
@ -738,7 +741,7 @@ static int _init_segtypes(struct cmd_context *cmd)
#ifdef HAVE_LIBDL #ifdef HAVE_LIBDL
/* Load any formats in shared libs */ /* Load any formats in shared libs */
if ((cn = find_config_node(cmd->cft->root, "global/segment_libraries"))) { if ((cn = find_config_tree_node(cmd, "global/segment_libraries"))) {
struct config_value *cv; struct config_value *cv;
struct segment_type *(*init_segtype_fn) (struct cmd_context *); struct segment_type *(*init_segtype_fn) (struct cmd_context *);
@ -752,7 +755,7 @@ static int _init_segtypes(struct cmd_context *cmd)
"global/segment_libraries"); "global/segment_libraries");
return 0; return 0;
} }
if (!(lib = load_shared_library(cmd->cft, cv->v.str, if (!(lib = load_shared_library(cmd, cv->v.str,
"segment type", 0))) { "segment type", 0))) {
stack; stack;
return 0; return 0;
@ -827,13 +830,13 @@ static int _init_backup(struct cmd_context *cmd)
/* set up archiving */ /* set up archiving */
cmd->default_settings.archive = cmd->default_settings.archive =
find_config_bool(cmd->cft->root, "backup/archive", find_config_tree_bool(cmd, "backup/archive",
DEFAULT_ARCHIVE_ENABLED); DEFAULT_ARCHIVE_ENABLED);
days = (uint32_t) find_config_int(cmd->cft->root, "backup/retain_days", days = (uint32_t) find_config_tree_int(cmd, "backup/retain_days",
DEFAULT_ARCHIVE_DAYS); DEFAULT_ARCHIVE_DAYS);
min = (uint32_t) find_config_int(cmd->cft->root, "backup/retain_min", min = (uint32_t) find_config_tree_int(cmd, "backup/retain_min",
DEFAULT_ARCHIVE_NUMBER); DEFAULT_ARCHIVE_NUMBER);
if (lvm_snprintf if (lvm_snprintf
@ -844,7 +847,7 @@ static int _init_backup(struct cmd_context *cmd)
return 0; return 0;
} }
dir = find_config_str(cmd->cft->root, "backup/archive_dir", dir = find_config_tree_str(cmd, "backup/archive_dir",
default_dir); default_dir);
if (!archive_init(cmd, dir, days, min)) { if (!archive_init(cmd, dir, days, min)) {
@ -854,7 +857,7 @@ static int _init_backup(struct cmd_context *cmd)
/* set up the backup */ /* set up the backup */
cmd->default_settings.backup = cmd->default_settings.backup =
find_config_bool(cmd->cft->root, "backup/backup", find_config_tree_bool(cmd, "backup/backup",
DEFAULT_BACKUP_ENABLED); DEFAULT_BACKUP_ENABLED);
if (lvm_snprintf if (lvm_snprintf
@ -865,7 +868,7 @@ static int _init_backup(struct cmd_context *cmd)
return 0; return 0;
} }
dir = find_config_str(cmd->cft->root, "backup/backup_dir", default_dir); dir = find_config_tree_str(cmd, "backup/backup_dir", default_dir);
if (!backup_init(cmd, dir)) { if (!backup_init(cmd, dir)) {
log_debug("backup_init failed."); log_debug("backup_init failed.");
@ -1021,7 +1024,7 @@ int refresh_toolcontext(struct cmd_context *cmd)
persistent_filter_dump(cmd->filter); persistent_filter_dump(cmd->filter);
} }
activation_exit(); activation_release();
lvmcache_destroy(); lvmcache_destroy();
label_exit(); label_exit();
_destroy_segtypes(&cmd->segtypes); _destroy_segtypes(&cmd->segtypes);

View File

@ -71,6 +71,7 @@ struct cmd_context {
struct list config_files; struct list config_files;
int config_valid; int config_valid;
struct config_tree *cft; struct config_tree *cft;
struct config_tree *cft_override;
struct config_info default_settings; struct config_info default_settings;
struct config_info current_settings; struct config_info current_settings;

View File

@ -41,10 +41,10 @@ enum {
}; };
struct parser { struct parser {
char *fb, *fe; /* file limits */ const char *fb, *fe; /* file limits */
int t; /* token limits and type */ int t; /* token limits and type */
char *tb, *te; const char *tb, *te;
int fd; /* descriptor for file being parsed */ int fd; /* descriptor for file being parsed */
int line; /* line number we are on */ int line; /* line number we are on */
@ -77,7 +77,7 @@ static const int sep = '/';
#define match(t) do {\ #define match(t) do {\
if (!_match_aux(p, (t))) {\ if (!_match_aux(p, (t))) {\
log_error("Parse error at line %d: unexpected token", p->line); \ log_error("Parse error at byte %d (line %d): unexpected token", p->tb - p->fb + 1, p->line); \
return 0;\ return 0;\
} \ } \
} while(0); } while(0);
@ -101,12 +101,12 @@ struct config_tree *create_config_tree(const char *filename)
struct dm_pool *mem = dm_pool_create("config", 10 * 1024); struct dm_pool *mem = dm_pool_create("config", 10 * 1024);
if (!mem) { if (!mem) {
stack; log_error("Failed to allocate config pool.");
return 0; return 0;
} }
if (!(c = dm_pool_zalloc(mem, sizeof(*c)))) { if (!(c = dm_pool_zalloc(mem, sizeof(*c)))) {
stack; log_error("Failed to allocate config tree.");
dm_pool_destroy(mem); dm_pool_destroy(mem);
return 0; return 0;
} }
@ -125,6 +125,46 @@ void destroy_config_tree(struct config_tree *cft)
dm_pool_destroy(((struct cs *) cft)->mem); dm_pool_destroy(((struct cs *) cft)->mem);
} }
static int _parse_config_file(struct parser *p, struct config_tree *cft)
{
p->tb = p->te = p->fb;
p->line = 1;
_get_token(p, TOK_SECTION_E);
if (!(cft->root = _file(p)))
return_0;
return 1;
}
struct config_tree *create_config_tree_from_string(struct cmd_context *cmd,
const char *config_settings)
{
struct cs *c;
struct config_tree *cft;
struct parser *p;
if (!(cft = create_config_tree(NULL)))
return_NULL;
c = (struct cs *) cft;
if (!(p = dm_pool_alloc(c->mem, sizeof(*p)))) {
log_error("Failed to allocate config tree parser.");
destroy_config_tree(cft);
return NULL;
}
p->mem = c->mem;
p->fb = config_settings;
p->fe = config_settings + strlen(config_settings);
if (!_parse_config_file(p, cft)) {
destroy_config_tree(cft);
return_NULL;
}
return cft;
}
int read_config_fd(struct config_tree *cft, struct device *dev, int read_config_fd(struct config_tree *cft, struct device *dev,
off_t offset, size_t size, off_t offset2, size_t size2, off_t offset, size_t size, off_t offset2, size_t size2,
checksum_fn_t checksum_fn, uint32_t checksum) checksum_fn_t checksum_fn, uint32_t checksum)
@ -134,6 +174,7 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
int r = 0; int r = 0;
int use_mmap = 1; int use_mmap = 1;
off_t mmap_offset = 0; off_t mmap_offset = 0;
char *buf;
if (!(p = dm_pool_alloc(c->mem, sizeof(*p)))) { if (!(p = dm_pool_alloc(c->mem, sizeof(*p)))) {
stack; stack;
@ -156,22 +197,23 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
} }
p->fb = p->fb + mmap_offset; p->fb = p->fb + mmap_offset;
} else { } else {
if (!(p->fb = dm_malloc(size + size2))) { if (!(buf = dm_malloc(size + size2))) {
stack; stack;
return 0; return 0;
} }
if (!dev_read(dev, (uint64_t) offset, size, p->fb)) { if (!dev_read(dev, (uint64_t) offset, size, buf)) {
log_error("Read from %s failed", dev_name(dev)); log_error("Read from %s failed", dev_name(dev));
goto out; goto out;
} }
if (size2) { if (size2) {
if (!dev_read(dev, (uint64_t) offset2, size2, if (!dev_read(dev, (uint64_t) offset2, size2,
p->fb + size)) { buf + size)) {
log_error("Circular read from %s failed", log_error("Circular read from %s failed",
dev_name(dev)); dev_name(dev));
goto out; goto out;
} }
} }
p->fb = buf;
} }
if (checksum_fn && checksum != if (checksum_fn && checksum !=
@ -183,11 +225,7 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
p->fe = p->fb + size + size2; p->fe = p->fb + size + size2;
/* parse */ if (!_parse_config_file(p, cft)) {
p->tb = p->te = p->fb;
p->line = 1;
_get_token(p, TOK_SECTION_E);
if (!(cft->root = _file(p))) {
stack; stack;
goto out; goto out;
} }
@ -196,7 +234,7 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
out: out:
if (!use_mmap) if (!use_mmap)
dm_free(p->fb); dm_free(buf);
else { else {
/* unmap the file */ /* unmap the file */
if (munmap((char *) (p->fb - mmap_offset), size + mmap_offset)) { if (munmap((char *) (p->fb - mmap_offset), size + mmap_offset)) {
@ -529,7 +567,7 @@ static struct config_value *_type(struct parser *p)
break; break;
default: default:
log_error("Parse error at line %d: expected a value", p->line); log_error("Parse error at byte %d (line %d): expected a value", p->tb - p->fb + 1, p->line);
return 0; return 0;
} }
return v; return v;
@ -721,7 +759,7 @@ static char *_dup_tok(struct parser *p)
/* /*
* utility functions * utility functions
*/ */
struct config_node *find_config_node(const struct config_node *cn, static struct config_node *_find_config_node(const struct config_node *cn,
const char *path) const char *path)
{ {
const char *e; const char *e;
@ -753,10 +791,32 @@ struct config_node *find_config_node(const struct config_node *cn,
return (struct config_node *) cn; return (struct config_node *) cn;
} }
const char *find_config_str(const struct config_node *cn, static struct config_node *_find_first_config_node(const struct config_node *cn1,
const struct config_node *cn2,
const char *path)
{
struct config_node *cn;
if (cn1 && (cn = _find_config_node(cn1, path)))
return cn;
if (cn2 && (cn = _find_config_node(cn2, path)))
return cn;
return NULL;
}
struct config_node *find_config_node(const struct config_node *cn,
const char *path)
{
return _find_config_node(cn, path);
}
static const char *_find_config_str(const struct config_node *cn1,
const struct config_node *cn2,
const char *path, const char *fail) const char *path, const char *fail)
{ {
const struct config_node *n = find_config_node(cn, path); const struct config_node *n = _find_first_config_node(cn1, cn2, path);
/* Empty strings are ignored */ /* Empty strings are ignored */
if ((n && n->v->type == CFG_STRING) && (*n->v->v.str)) { if ((n && n->v->type == CFG_STRING) && (*n->v->v.str)) {
@ -770,9 +830,17 @@ const char *find_config_str(const struct config_node *cn,
return fail; return fail;
} }
int find_config_int(const struct config_node *cn, const char *path, int fail) const char *find_config_str(const struct config_node *cn,
const char *path, const char *fail)
{ {
const struct config_node *n = find_config_node(cn, path); return _find_config_str(cn, NULL, path, fail);
}
static int _find_config_int(const struct config_node *cn1,
const struct config_node *cn2,
const char *path, int fail)
{
const struct config_node *n = _find_first_config_node(cn1, cn2, path);
if (n && n->v->type == CFG_INT) { if (n && n->v->type == CFG_INT) {
log_very_verbose("Setting %s to %d", path, n->v->v.i); log_very_verbose("Setting %s to %d", path, n->v->v.i);
@ -784,10 +852,16 @@ int find_config_int(const struct config_node *cn, const char *path, int fail)
return fail; return fail;
} }
float find_config_float(const struct config_node *cn, const char *path, int find_config_int(const struct config_node *cn, const char *path, int fail)
float fail)
{ {
const struct config_node *n = find_config_node(cn, path); return _find_config_int(cn, NULL, path, fail);
}
static float _find_config_float(const struct config_node *cn1,
const struct config_node *cn2,
const char *path, float fail)
{
const struct config_node *n = _find_first_config_node(cn1, cn2, path);
if (n && n->v->type == CFG_FLOAT) { if (n && n->v->type == CFG_FLOAT) {
log_very_verbose("Setting %s to %f", path, n->v->v.r); log_very_verbose("Setting %s to %f", path, n->v->v.r);
@ -801,6 +875,36 @@ float find_config_float(const struct config_node *cn, const char *path,
} }
float find_config_float(const struct config_node *cn, const char *path,
float fail)
{
return _find_config_float(cn, NULL, path, fail);
}
struct config_node *find_config_tree_node(struct cmd_context *cmd,
const char *path)
{
return _find_first_config_node(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path);
}
const char *find_config_tree_str(struct cmd_context *cmd,
const char *path, const char *fail)
{
return _find_config_str(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path, fail);
}
int find_config_tree_int(struct cmd_context *cmd, const char *path,
int fail)
{
return _find_config_int(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path, fail);
}
float find_config_tree_float(struct cmd_context *cmd, const char *path,
float fail)
{
return _find_config_float(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path, fail);
}
static int _str_in_array(const char *str, const char *values[]) static int _str_in_array(const char *str, const char *values[])
{ {
int i; int i;
@ -827,9 +931,11 @@ static int _str_to_bool(const char *str, int fail)
return fail; return fail;
} }
int find_config_bool(const struct config_node *cn, const char *path, int fail) static int _find_config_bool(const struct config_node *cn1,
const struct config_node *cn2,
const char *path, int fail)
{ {
const struct config_node *n = find_config_node(cn, path); const struct config_node *n = _find_first_config_node(cn1, cn2, path);
struct config_value *v; struct config_value *v;
if (!n) if (!n)
@ -848,6 +954,16 @@ int find_config_bool(const struct config_node *cn, const char *path, int fail)
return fail; return fail;
} }
int find_config_bool(const struct config_node *cn, const char *path, int fail)
{
return _find_config_bool(cn, NULL, path, fail);
}
int find_config_tree_bool(struct cmd_context *cmd, const char *path, int fail)
{
return _find_config_bool(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path, fail);
}
int get_config_uint32(const struct config_node *cn, const char *path, int get_config_uint32(const struct config_node *cn, const char *path,
uint32_t *result) uint32_t *result)
{ {

View File

@ -54,9 +54,11 @@ struct config_tree_list {
}; };
struct config_tree *create_config_tree(const char *filename); struct config_tree *create_config_tree(const char *filename);
struct config_tree *create_config_tree_from_string(struct cmd_context *cmd,
const char *config_settings);
void destroy_config_tree(struct config_tree *cft); void destroy_config_tree(struct config_tree *cft);
typedef uint32_t (*checksum_fn_t) (uint32_t initial, void *buf, uint32_t size); typedef uint32_t (*checksum_fn_t) (uint32_t initial, const void *buf, uint32_t size);
int read_config_fd(struct config_tree *cft, struct device *dev, int read_config_fd(struct config_tree *cft, struct device *dev,
off_t offset, size_t size, off_t offset2, size_t size2, off_t offset, size_t size, off_t offset2, size_t size2,
@ -71,20 +73,30 @@ int merge_config_tree(struct cmd_context *cmd, struct config_tree *cft,
struct config_node *find_config_node(const struct config_node *cn, struct config_node *find_config_node(const struct config_node *cn,
const char *path); const char *path);
const char *find_config_str(const struct config_node *cn, const char *path, const char *find_config_str(const struct config_node *cn, const char *path,
const char *fail); const char *fail);
int find_config_int(const struct config_node *cn, const char *path, int fail); int find_config_int(const struct config_node *cn, const char *path, int fail);
float find_config_float(const struct config_node *cn, const char *path, float find_config_float(const struct config_node *cn, const char *path,
float fail); float fail);
/*
* These versions check an override tree, if present, first.
*/
struct config_node *find_config_tree_node(struct cmd_context *cmd,
const char *path);
const char *find_config_tree_str(struct cmd_context *cmd,
const char *path, const char *fail);
int find_config_tree_int(struct cmd_context *cmd, const char *path,
int fail);
float find_config_tree_float(struct cmd_context *cmd, const char *path,
float fail);
/* /*
* Understands (0, ~0), (y, n), (yes, no), (on, * Understands (0, ~0), (y, n), (yes, no), (on,
* off), (true, false). * off), (true, false).
*/ */
int find_config_bool(const struct config_node *cn, const char *path, int fail); int find_config_bool(const struct config_node *cn, const char *path, int fail);
int find_config_tree_bool(struct cmd_context *cmd, const char *path, int fail);
int get_config_uint32(const struct config_node *cn, const char *path, int get_config_uint32(const struct config_node *cn, const char *path,
uint32_t *result); uint32_t *result);

View File

@ -40,7 +40,7 @@ static int _errseg_merge_segments(struct lv_segment *seg1, struct lv_segment *se
#ifdef DEVMAPPER_SUPPORT #ifdef DEVMAPPER_SUPPORT
static int _errseg_add_target_line(struct dev_manager *dm __attribute((unused)), static int _errseg_add_target_line(struct dev_manager *dm __attribute((unused)),
struct dm_pool *mem __attribute((unused)), struct dm_pool *mem __attribute((unused)),
struct config_tree *cft __attribute((unused)), struct cmd_context *cmd __attribute((unused)),
void **target_state __attribute((unused)), void **target_state __attribute((unused)),
struct lv_segment *seg __attribute((unused)), struct lv_segment *seg __attribute((unused)),
struct dm_tree_node *node, uint64_t len, struct dm_tree_node *node, uint64_t len,

View File

@ -1783,7 +1783,7 @@ struct format_type *create_text_format(struct cmd_context *cmd)
return NULL; return NULL;
} }
if ((cn = find_config_node(cmd->cft->root, "metadata/dirs"))) { if ((cn = find_config_tree_node(cmd, "metadata/dirs"))) {
for (cv = cn->v; cv; cv = cv->next) { for (cv = cn->v; cv; cv = cv->next) {
if (cv->type != CFG_STRING) { if (cv->type != CFG_STRING) {
log_error("Invalid string in config file: " log_error("Invalid string in config file: "
@ -1799,7 +1799,7 @@ struct format_type *create_text_format(struct cmd_context *cmd)
} }
} }
if ((cn = find_config_node(cmd->cft->root, "metadata/disk_areas"))) { if ((cn = find_config_tree_node(cmd, "metadata/disk_areas"))) {
for (cn = cn->child; cn; cn = cn->sib) { for (cn = cn->child; cn; cn = cn->sib) {
if (!_get_config_disk_area(cmd, cn, &mda_lists->raws)) if (!_get_config_disk_area(cmd, cn, &mda_lists->raws))
goto err; goto err;

View File

@ -452,7 +452,7 @@ void reset_locking(void)
} }
#ifdef CLUSTER_LOCKING_INTERNAL #ifdef CLUSTER_LOCKING_INTERNAL
int init_cluster_locking(struct locking_type *locking, struct config_tree *cft) int init_cluster_locking(struct locking_type *locking, struct cmd_context *cmd)
{ {
locking->lock_resource = _lock_resource; locking->lock_resource = _lock_resource;
locking->fin_locking = _locking_end; locking->fin_locking = _locking_end;

View File

@ -17,6 +17,7 @@
#include "locking_types.h" #include "locking_types.h"
#include "defaults.h" #include "defaults.h"
#include "sharedlib.h" #include "sharedlib.h"
#include "toolcontext.h"
static void *_locking_lib = NULL; static void *_locking_lib = NULL;
static void (*_reset_fn) (void) = NULL; static void (*_reset_fn) (void) = NULL;
@ -55,7 +56,7 @@ static void _reset_external_locking(void)
_reset_fn(); _reset_fn();
} }
int init_external_locking(struct locking_type *locking, struct config_tree *cft) int init_external_locking(struct locking_type *locking, struct cmd_context *cmd)
{ {
const char *libname; const char *libname;
@ -69,10 +70,10 @@ int init_external_locking(struct locking_type *locking, struct config_tree *cft)
locking->reset_locking = _reset_external_locking; locking->reset_locking = _reset_external_locking;
locking->flags = 0; locking->flags = 0;
libname = find_config_str(cft->root, "global/locking_library", libname = find_config_tree_str(cmd, "global/locking_library",
DEFAULT_LOCKING_LIB); DEFAULT_LOCKING_LIB);
if (!(_locking_lib = load_shared_library(cft, libname, "locking", 1))) { if (!(_locking_lib = load_shared_library(cmd, libname, "locking", 1))) {
stack; stack;
return 0; return 0;
} }
@ -90,5 +91,5 @@ int init_external_locking(struct locking_type *locking, struct config_tree *cft)
} }
log_verbose("Loaded external locking library %s", libname); log_verbose("Loaded external locking library %s", libname);
return _init_fn(2, cft, &locking->flags); return _init_fn(2, cmd->cft, &locking->flags);
} }

View File

@ -271,7 +271,7 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
return 1; return 1;
} }
int init_file_locking(struct locking_type *locking, struct config_tree *cft) int init_file_locking(struct locking_type *locking, struct cmd_context *cmd)
{ {
locking->lock_resource = _file_lock_resource; locking->lock_resource = _file_lock_resource;
locking->reset_locking = _reset_file_locking; locking->reset_locking = _reset_file_locking;
@ -279,7 +279,7 @@ int init_file_locking(struct locking_type *locking, struct config_tree *cft)
locking->flags = 0; locking->flags = 0;
/* Get lockfile directory from config file */ /* Get lockfile directory from config file */
strncpy(_lock_dir, find_config_str(cft->root, "global/locking_dir", strncpy(_lock_dir, find_config_tree_str(cmd, "global/locking_dir",
DEFAULT_LOCK_DIR), DEFAULT_LOCK_DIR),
sizeof(_lock_dir)); sizeof(_lock_dir));

View File

@ -122,26 +122,26 @@ static void _update_vg_lock_count(int flags)
/* /*
* Select a locking type * Select a locking type
*/ */
int init_locking(int type, struct config_tree *cft) int init_locking(int type, struct cmd_context *cmd)
{ {
init_lockingfailed(0); init_lockingfailed(0);
switch (type) { switch (type) {
case 0: case 0:
init_no_locking(&_locking, cft); init_no_locking(&_locking, cmd);
log_print("WARNING: Locking disabled. Be careful! " log_print("WARNING: Locking disabled. Be careful! "
"This could corrupt your metadata."); "This could corrupt your metadata.");
return 1; return 1;
case 1: case 1:
if (!init_file_locking(&_locking, cft)) if (!init_file_locking(&_locking, cmd))
break; break;
log_very_verbose("File-based locking enabled."); log_very_verbose("File-based locking enabled.");
return 1; return 1;
#ifdef HAVE_LIBDL #ifdef HAVE_LIBDL
case 2: case 2:
if (!init_external_locking(&_locking, cft)) if (!init_external_locking(&_locking, cmd))
break; break;
log_very_verbose("External locking enabled."); log_very_verbose("External locking enabled.");
return 1; return 1;
@ -149,7 +149,7 @@ int init_locking(int type, struct config_tree *cft)
#ifdef CLUSTER_LOCKING_INTERNAL #ifdef CLUSTER_LOCKING_INTERNAL
case 3: case 3:
if (!init_cluster_locking(&_locking, cft)) if (!init_cluster_locking(&_locking, cmd))
break; break;
log_very_verbose("Cluster locking enabled."); log_very_verbose("Cluster locking enabled.");
return 1; return 1;
@ -166,7 +166,7 @@ int init_locking(int type, struct config_tree *cft)
/* FIXME Ensure only read ops are permitted */ /* FIXME Ensure only read ops are permitted */
log_verbose("Locking disabled - only read operations permitted."); log_verbose("Locking disabled - only read operations permitted.");
init_no_locking(&_locking, cft); init_no_locking(&_locking, cmd);
init_lockingfailed(1); init_lockingfailed(1);
return 1; return 1;

View File

@ -19,7 +19,7 @@
#include "uuid.h" #include "uuid.h"
#include "config.h" #include "config.h"
int init_locking(int type, struct config_tree *cf); int init_locking(int type, struct cmd_context *cmd);
void fin_locking(void); void fin_locking(void);
void reset_locking(void); void reset_locking(void);
int vg_write_lock_held(void); int vg_write_lock_held(void);

View File

@ -36,10 +36,10 @@ struct locking_type {
/* /*
* Locking types * Locking types
*/ */
int init_no_locking(struct locking_type *locking, struct config_tree *cf); int init_no_locking(struct locking_type *locking, struct cmd_context *cmd);
int init_file_locking(struct locking_type *locking, struct config_tree *cf); int init_file_locking(struct locking_type *locking, struct cmd_context *cmd);
int init_external_locking(struct locking_type *locking, struct config_tree *cf); int init_external_locking(struct locking_type *locking, struct cmd_context *cmd);
int init_cluster_locking(struct locking_type *locking, struct config_tree *cf); int init_cluster_locking(struct locking_type *locking, struct cmd_context *cmd);

View File

@ -76,7 +76,7 @@ static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
return 1; return 1;
} }
int init_no_locking(struct locking_type *locking, struct config_tree *cft) int init_no_locking(struct locking_type *locking, struct cmd_context *cmd)
{ {
locking->lock_resource = _no_lock_resource; locking->lock_resource = _no_lock_resource;
locking->reset_locking = _no_reset_locking; locking->reset_locking = _no_reset_locking;

View File

@ -67,7 +67,7 @@ struct segtype_handler {
int (*merge_segments) (struct lv_segment * seg1, int (*merge_segments) (struct lv_segment * seg1,
struct lv_segment * seg2); struct lv_segment * seg2);
int (*add_target_line) (struct dev_manager *dm, struct dm_pool *mem, int (*add_target_line) (struct dev_manager *dm, struct dm_pool *mem,
struct config_tree *cft, void **target_state, struct cmd_context *cmd, void **target_state,
struct lv_segment *seg, struct lv_segment *seg,
struct dm_tree_node *node, uint64_t len, struct dm_tree_node *node, uint64_t len,
uint32_t *pvmove_mirror_count); uint32_t *pvmove_mirror_count);
@ -80,10 +80,10 @@ struct segtype_handler {
void (*destroy) (const struct segment_type * segtype); void (*destroy) (const struct segment_type * segtype);
int (*target_register_events) (struct dm_pool *mem, int (*target_register_events) (struct dm_pool *mem,
struct lv_segment *seg, struct lv_segment *seg,
struct config_tree *cft, int events); struct cmd_context *cmd, int events);
int (*target_unregister_events) (struct dm_pool *mem, int (*target_unregister_events) (struct dm_pool *mem,
struct lv_segment *seg, struct lv_segment *seg,
struct config_tree *cft, int events); struct cmd_context *cmd, int events);
}; };
struct segment_type *get_segtype_from_string(struct cmd_context *cmd, struct segment_type *get_segtype_from_string(struct cmd_context *cmd,

View File

@ -154,7 +154,7 @@ static int _mirrored_text_export(const struct lv_segment *seg, struct formatter
#ifdef DEVMAPPER_SUPPORT #ifdef DEVMAPPER_SUPPORT
static struct mirror_state *_mirrored_init_target(struct dm_pool *mem, static struct mirror_state *_mirrored_init_target(struct dm_pool *mem,
struct config_tree *cft) struct cmd_context *cmd)
{ {
struct mirror_state *mirr_state; struct mirror_state *mirr_state;
@ -164,7 +164,7 @@ static struct mirror_state *_mirrored_init_target(struct dm_pool *mem,
} }
mirr_state->default_region_size = 2 * mirr_state->default_region_size = 2 *
find_config_int(cft->root, find_config_tree_int(cmd,
"activation/mirror_region_size", "activation/mirror_region_size",
DEFAULT_MIRROR_REGION_SIZE); DEFAULT_MIRROR_REGION_SIZE);
@ -172,7 +172,7 @@ static struct mirror_state *_mirrored_init_target(struct dm_pool *mem,
} }
static int _mirrored_target_percent(void **target_state, struct dm_pool *mem, static int _mirrored_target_percent(void **target_state, struct dm_pool *mem,
struct config_tree *cft, struct lv_segment *seg, struct cmd_context *cmd, struct lv_segment *seg,
char *params, uint64_t *total_numerator, char *params, uint64_t *total_numerator,
uint64_t *total_denominator, uint64_t *total_denominator,
float *percent __attribute((unused))) float *percent __attribute((unused)))
@ -184,7 +184,7 @@ static int _mirrored_target_percent(void **target_state, struct dm_pool *mem,
char *pos = params; char *pos = params;
if (!*target_state) if (!*target_state)
*target_state = _mirrored_init_target(mem, cft); *target_state = _mirrored_init_target(mem, cmd);
mirr_state = *target_state; mirr_state = *target_state;
@ -265,7 +265,7 @@ static int _add_log(struct dev_manager *dm, struct lv_segment *seg,
} }
static int _mirrored_add_target_line(struct dev_manager *dm, struct dm_pool *mem, static int _mirrored_add_target_line(struct dev_manager *dm, struct dm_pool *mem,
struct config_tree *cft, void **target_state, struct cmd_context *cmd, void **target_state,
struct lv_segment *seg, struct lv_segment *seg,
struct dm_tree_node *node, uint64_t len, struct dm_tree_node *node, uint64_t len,
uint32_t *pvmove_mirror_count) uint32_t *pvmove_mirror_count)
@ -278,7 +278,7 @@ static int _mirrored_add_target_line(struct dev_manager *dm, struct dm_pool *mem
int r; int r;
if (!*target_state) if (!*target_state)
*target_state = _mirrored_init_target(mem, cft); *target_state = _mirrored_init_target(mem, cmd);
mirr_state = *target_state; mirr_state = *target_state;
@ -367,7 +367,7 @@ static int _mirrored_target_present(void)
} }
#ifdef DMEVENTD #ifdef DMEVENTD
static int _setup_registration(struct dm_pool *mem, struct config_tree *cft, static int _setup_registration(struct dm_pool *mem, struct cmd_context *cmd,
char **dso) char **dso)
{ {
char *path; char *path;
@ -378,10 +378,10 @@ static int _setup_registration(struct dm_pool *mem, struct config_tree *cft,
return 0; return 0;
} }
libpath = find_config_str(cft->root, "dmeventd/mirror_library", libpath = find_config_tree_str(cmd, "dmeventd/mirror_library",
DEFAULT_DMEVENTD_MIRROR_LIB); DEFAULT_DMEVENTD_MIRROR_LIB);
get_shared_library_path(cft, libpath, path, PATH_MAX); get_shared_library_path(cmd, libpath, path, PATH_MAX);
*dso = path; *dso = path;
@ -390,9 +390,10 @@ static int _setup_registration(struct dm_pool *mem, struct config_tree *cft,
/* FIXME This gets run while suspended and performs banned operations. */ /* FIXME This gets run while suspended and performs banned operations. */
/* FIXME Merge these two functions */ /* FIXME Merge these two functions */
static int _target_register_events(struct dm_pool *mem, static int _target_register_events(struct cmd_context *cmd,
struct dm_pool *mem,
struct lv_segment *seg, struct lv_segment *seg,
struct config_tree *cft, int events) int events)
{ {
char *dso, *name; char *dso, *name;
struct logical_volume *lv; struct logical_volume *lv;
@ -401,7 +402,7 @@ static int _target_register_events(struct dm_pool *mem,
lv = seg->lv; lv = seg->lv;
vg = lv->vg; vg = lv->vg;
if (!_setup_registration(mem, cft, &dso)) { if (!_setup_registration(mem, cmd, &dso)) {
stack; stack;
return 0; return 0;
} }
@ -418,9 +419,10 @@ static int _target_register_events(struct dm_pool *mem,
return 1; return 1;
} }
static int _target_unregister_events(struct dm_pool *mem, static int _target_unregister_events(struct cmd_context *cmd,
struct dm_pool *mem,
struct lv_segment *seg, struct lv_segment *seg,
struct config_tree *cft, int events) int events)
{ {
char *dso; char *dso;
char *name; char *name;
@ -431,7 +433,7 @@ static int _target_unregister_events(struct dm_pool *mem,
vg = lv->vg; vg = lv->vg;
/* FIXME Remove this and use handle to avoid config file race */ /* FIXME Remove this and use handle to avoid config file race */
if (!_setup_registration(mem, cft, &dso)) if (!_setup_registration(mem, cmd, &dso))
return_0; return_0;
if (!(name = build_dm_name(mem, vg->name, lv->name, NULL))) if (!(name = build_dm_name(mem, vg->name, lv->name, NULL)))

View File

@ -18,7 +18,7 @@
#include "crc.h" #include "crc.h"
/* Calculate an endian-independent CRC of supplied buffer */ /* Calculate an endian-independent CRC of supplied buffer */
uint32_t calc_crc(uint32_t initial, void *buf, uint32_t size) uint32_t calc_crc(uint32_t initial, const void *buf, uint32_t size)
{ {
static const uint32_t crctab[] = { static const uint32_t crctab[] = {
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
@ -27,7 +27,7 @@ uint32_t calc_crc(uint32_t initial, void *buf, uint32_t size)
0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
}; };
uint32_t i, crc = initial; uint32_t i, crc = initial;
uint8_t *data = (uint8_t *) buf; const uint8_t *data = (const uint8_t *) buf;
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
crc ^= *data++; crc ^= *data++;

View File

@ -18,6 +18,6 @@
#define INITIAL_CRC 0xf597a6cf #define INITIAL_CRC 0xf597a6cf
uint32_t calc_crc(uint32_t initial, void *buf, uint32_t size); uint32_t calc_crc(uint32_t initial, const void *buf, uint32_t size);
#endif #endif

View File

@ -22,7 +22,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <dlfcn.h> #include <dlfcn.h>
void get_shared_library_path(struct config_tree *cft, const char *libname, void get_shared_library_path(struct cmd_context *cmd, const char *libname,
char *path, size_t path_len) char *path, size_t path_len)
{ {
struct stat info; struct stat info;
@ -31,19 +31,19 @@ void get_shared_library_path(struct config_tree *cft, const char *libname,
/* If libname doesn't begin with '/' then use lib_dir/libname, /* If libname doesn't begin with '/' then use lib_dir/libname,
* if present */ * if present */
if (libname[0] == '/' || if (libname[0] == '/' ||
!(lib_dir = find_config_str(cft->root, "global/library_dir", 0)) || !(lib_dir = find_config_tree_str(cmd, "global/library_dir", 0)) ||
(lvm_snprintf(path, path_len, "%s/%s", lib_dir, (lvm_snprintf(path, path_len, "%s/%s", lib_dir,
libname) == -1) || stat(path, &info) == -1) libname) == -1) || stat(path, &info) == -1)
strncpy(path, libname, path_len); strncpy(path, libname, path_len);
} }
void *load_shared_library(struct config_tree *cft, const char *libname, void *load_shared_library(struct cmd_context *cmd, const char *libname,
const char *desc, int silent) const char *desc, int silent)
{ {
char path[PATH_MAX]; char path[PATH_MAX];
void *library; void *library;
get_shared_library_path(cft, libname, path, sizeof(path)); get_shared_library_path(cmd, libname, path, sizeof(path));
log_very_verbose("Opening shared %s library %s", desc, path); log_very_verbose("Opening shared %s library %s", desc, path);

View File

@ -19,9 +19,9 @@
#include "config.h" #include "config.h"
#include <dlfcn.h> #include <dlfcn.h>
void get_shared_library_path(struct config_tree *cft, const char *libname, void get_shared_library_path(struct cmd_context *cmd, const char *libname,
char *path, size_t path_len); char *path, size_t path_len);
void *load_shared_library(struct config_tree *cf, const char *libname, void *load_shared_library(struct cmd_context *cmd, const char *libname,
const char *what, int silent); const char *what, int silent);
#endif #endif

View File

@ -144,13 +144,13 @@ int memlock(void)
void memlock_init(struct cmd_context *cmd) void memlock_init(struct cmd_context *cmd)
{ {
_size_stack = find_config_int(cmd->cft->root, _size_stack = find_config_tree_int(cmd,
"activation/reserved_stack", "activation/reserved_stack",
DEFAULT_RESERVED_STACK) * 1024; DEFAULT_RESERVED_STACK) * 1024;
_size_malloc_tmp = find_config_int(cmd->cft->root, _size_malloc_tmp = find_config_tree_int(cmd,
"activation/reserved_memory", "activation/reserved_memory",
DEFAULT_RESERVED_MEMORY) * 1024; DEFAULT_RESERVED_MEMORY) * 1024;
_default_priority = find_config_int(cmd->cft->root, _default_priority = find_config_tree_int(cmd,
"activation/process_priority", "activation/process_priority",
DEFAULT_PROCESS_PRIORITY); DEFAULT_PROCESS_PRIORITY);
} }

View File

@ -153,7 +153,7 @@ static int _striped_merge_segments(struct lv_segment *seg1, struct lv_segment *s
#ifdef DEVMAPPER_SUPPORT #ifdef DEVMAPPER_SUPPORT
static int _striped_add_target_line(struct dev_manager *dm, static int _striped_add_target_line(struct dev_manager *dm,
struct dm_pool *mem __attribute((unused)), struct dm_pool *mem __attribute((unused)),
struct config_tree *cft __attribute((unused)), struct cmd_context *cmd __attribute((unused)),
void **target_state __attribute((unused)), void **target_state __attribute((unused)),
struct lv_segment *seg, struct lv_segment *seg,
struct dm_tree_node *node, uint64_t len, struct dm_tree_node *node, uint64_t len,

View File

@ -40,7 +40,7 @@ static int _zero_merge_segments(struct lv_segment *seg1, struct lv_segment *seg2
#ifdef DEVMAPPER_SUPPORT #ifdef DEVMAPPER_SUPPORT
static int _zero_add_target_line(struct dev_manager *dm __attribute((unused)), static int _zero_add_target_line(struct dev_manager *dm __attribute((unused)),
struct dm_pool *mem __attribute((unused)), struct dm_pool *mem __attribute((unused)),
struct config_tree *cft __attribute((unused)), struct cmd_context *cmd __attribute((unused)),
void **target_state __attribute((unused)), void **target_state __attribute((unused)),
struct lv_segment *seg __attribute((unused)), struct lv_segment *seg __attribute((unused)),
struct dm_tree_node *node,uint64_t len, struct dm_tree_node *node,uint64_t len,

View File

@ -91,9 +91,7 @@ ifeq ("@DMEVENTD@", "yes")
LVMLIBS += -ldevmapper-event -lpthread LVMLIBS += -ldevmapper-event -lpthread
endif endif
ifeq ("@DEVMAPPER@", "yes")
LVMLIBS += -ldevmapper LVMLIBS += -ldevmapper
endif
DEFS += -DLVM_SHARED_PATH=\"$(exec_prefix)/sbin/lvm\" DEFS += -DLVM_SHARED_PATH=\"$(exec_prefix)/sbin/lvm\"

View File

@ -48,6 +48,7 @@ arg(mirrorsonly_ARG, '\0', "mirrorsonly", NULL)
arg(nosync_ARG, '\0', "nosync", NULL) arg(nosync_ARG, '\0', "nosync", NULL)
arg(corelog_ARG, '\0', "corelog", NULL) arg(corelog_ARG, '\0', "corelog", NULL)
arg(monitor_ARG, '\0', "monitor", yes_no_arg) arg(monitor_ARG, '\0', "monitor", yes_no_arg)
arg(config_ARG, '\0', "config", string_arg)
/* Allow some variations */ /* Allow some variations */
arg(resizable_ARG, '\0', "resizable", yes_no_arg) arg(resizable_ARG, '\0', "resizable", yes_no_arg)

View File

@ -177,7 +177,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
lp->region_size = 2 * arg_uint_value(cmd, lp->region_size = 2 * arg_uint_value(cmd,
regionsize_ARG, 0); regionsize_ARG, 0);
} else { } else {
region_size = 2 * find_config_int(cmd->cft->root, region_size = 2 * find_config_tree_int(cmd,
"activation/mirror_region_size", "activation/mirror_region_size",
DEFAULT_MIRROR_REGION_SIZE); DEFAULT_MIRROR_REGION_SIZE);
if (region_size < 0) { if (region_size < 0) {

View File

@ -213,7 +213,7 @@ static int _read_stripe_params(struct lvcreate_params *lp,
} }
if (lp->stripes > 1 && !lp->stripe_size) { if (lp->stripes > 1 && !lp->stripe_size) {
lp->stripe_size = find_config_int(cmd->cft->root, lp->stripe_size = find_config_tree_int(cmd,
"metadata/stripesize", "metadata/stripesize",
DEFAULT_STRIPESIZE) * 2; DEFAULT_STRIPESIZE) * 2;
log_print("Using default stripesize %s", log_print("Using default stripesize %s",
@ -264,7 +264,7 @@ static int _read_mirror_params(struct lvcreate_params *lp,
} }
lp->region_size = 2 * arg_uint_value(cmd, regionsize_ARG, 0); lp->region_size = 2 * arg_uint_value(cmd, regionsize_ARG, 0);
} else { } else {
region_size = 2 * find_config_int(cmd->cft->root, region_size = 2 * find_config_tree_int(cmd,
"activation/mirror_region_size", "activation/mirror_region_size",
DEFAULT_MIRROR_REGION_SIZE); DEFAULT_MIRROR_REGION_SIZE);
if (region_size < 0) { if (region_size < 0) {
@ -668,7 +668,8 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
status |= MIRROR_NOTSYNCED; status |= MIRROR_NOTSYNCED;
} }
if (!(log_lv = create_mirror_log(cmd, vg, ah, lp->alloc, if (!lp->corelog &&
!(log_lv = create_mirror_log(cmd, vg, ah, lp->alloc,
lv_name, lp->nosync))) { lv_name, lp->nosync))) {
log_error("Failed to create mirror log."); log_error("Failed to create mirror log.");
return 0; return 0;

View File

@ -449,7 +449,7 @@ static void _register_commands()
driverloaded_ARG, \ driverloaded_ARG, \
debug_ARG, help_ARG, help2_ARG, \ debug_ARG, help_ARG, help2_ARG, \
version_ARG, verbose_ARG, \ version_ARG, verbose_ARG, \
quiet_ARG, -1); quiet_ARG, config_ARG, -1);
#include "commands.h" #include "commands.h"
#undef xx #undef xx
} }
@ -713,8 +713,6 @@ static int _get_settings(struct cmd_context *cmd)
!_merge_synonym(cmd, allocation_ARG, resizeable_ARG)) !_merge_synonym(cmd, allocation_ARG, resizeable_ARG))
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
init_mirror_in_sync(0);
/* Zero indicates success */ /* Zero indicates success */
return 0; return 0;
} }
@ -762,12 +760,23 @@ int help(struct cmd_context *cmd __attribute((unused)), int argc, char **argv)
return 0; return 0;
} }
static int _override_settings(struct cmd_context *cmd)
{
if (!(cmd->cft_override = create_config_tree_from_string(cmd, arg_str_value(cmd, config_ARG, "")))) {
log_error("Failed to set overridden configuration entries.");
return EINVALID_CMD_LINE;
}
return 0;
}
static void _apply_settings(struct cmd_context *cmd) static void _apply_settings(struct cmd_context *cmd)
{ {
init_debug(cmd->current_settings.debug); init_debug(cmd->current_settings.debug);
init_verbose(cmd->current_settings.verbose + VERBOSE_BASE_LEVEL); init_verbose(cmd->current_settings.verbose + VERBOSE_BASE_LEVEL);
init_test(cmd->current_settings.test); init_test(cmd->current_settings.test);
init_full_scan_done(0); init_full_scan_done(0);
init_mirror_in_sync(0);
init_msg_prefix(cmd->default_settings.msg_prefix); init_msg_prefix(cmd->default_settings.msg_prefix);
init_cmd_name(cmd->default_settings.cmd_name); init_cmd_name(cmd->default_settings.cmd_name);
@ -783,7 +792,7 @@ static void _apply_settings(struct cmd_context *cmd)
static char *_copy_command_line(struct cmd_context *cmd, int argc, char **argv) static char *_copy_command_line(struct cmd_context *cmd, int argc, char **argv)
{ {
int i; int i, space;
/* /*
* Build up the complete command line, used as a * Build up the complete command line, used as a
@ -793,9 +802,17 @@ static char *_copy_command_line(struct cmd_context *cmd, int argc, char **argv)
goto bad; goto bad;
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
space = strchr(argv[i], ' ') ? 1 : 0;
if (space && !dm_pool_grow_object(cmd->mem, "'", 1))
goto bad;
if (!dm_pool_grow_object(cmd->mem, argv[i], strlen(argv[i]))) if (!dm_pool_grow_object(cmd->mem, argv[i], strlen(argv[i])))
goto bad; goto bad;
if (space && !dm_pool_grow_object(cmd->mem, "'", 1))
goto bad;
if (i < (argc - 1)) if (i < (argc - 1))
if (!dm_pool_grow_object(cmd->mem, " ", 1)) if (!dm_pool_grow_object(cmd->mem, " ", 1))
goto bad; goto bad;
@ -835,7 +852,11 @@ static int _run_command(struct cmd_context *cmd, int argc, char **argv)
set_cmd_name(cmd->command->name); set_cmd_name(cmd->command->name);
if (!cmd->config_valid || config_files_changed(cmd)) { if (arg_count(cmd, config_ARG))
if ((ret = _override_settings(cmd)))
goto_out;
if (arg_count(cmd, config_ARG) || !cmd->config_valid || config_files_changed(cmd)) {
/* Reinitialise various settings inc. logging, filters */ /* Reinitialise various settings inc. logging, filters */
if (!refresh_toolcontext(cmd)) { if (!refresh_toolcontext(cmd)) {
log_error("Updated config file invalid. Aborting."); log_error("Updated config file invalid. Aborting.");
@ -844,7 +865,7 @@ static int _run_command(struct cmd_context *cmd, int argc, char **argv)
} }
if ((ret = _get_settings(cmd))) if ((ret = _get_settings(cmd)))
goto out; goto_out;
_apply_settings(cmd); _apply_settings(cmd);
log_debug("Processing: %s", cmd->cmd_line); log_debug("Processing: %s", cmd->cmd_line);
@ -854,15 +875,15 @@ static int _run_command(struct cmd_context *cmd, int argc, char **argv)
#endif #endif
if ((ret = _process_common_commands(cmd))) if ((ret = _process_common_commands(cmd)))
goto out; goto_out;
if (arg_count(cmd, nolocking_ARG)) if (arg_count(cmd, nolocking_ARG))
locking_type = 0; locking_type = 0;
else else
locking_type = find_config_int(cmd->cft->root, locking_type = find_config_tree_int(cmd,
"global/locking_type", 1); "global/locking_type", 1);
if (!init_locking(locking_type, cmd->cft)) { if (!init_locking(locking_type, cmd)) {
log_error("Locking type %d initialisation failed.", log_error("Locking type %d initialisation failed.",
locking_type); locking_type);
ret = ECMD_FAILED; ret = ECMD_FAILED;
@ -879,6 +900,15 @@ static int _run_command(struct cmd_context *cmd, int argc, char **argv)
lvmcache_destroy(); lvmcache_destroy();
} }
if (cmd->cft_override) {
destroy_config_tree(cmd->cft_override);
cmd->cft_override = NULL;
/* Move this? */
if (!refresh_toolcontext(cmd))
stack;
}
/* FIXME Move this? */
cmd->current_settings = cmd->default_settings; cmd->current_settings = cmd->default_settings;
_apply_settings(cmd); _apply_settings(cmd);
@ -890,6 +920,8 @@ static int _run_command(struct cmd_context *cmd, int argc, char **argv)
if (ret == EINVALID_CMD_LINE && !_interactive) if (ret == EINVALID_CMD_LINE && !_interactive)
_usage(cmd->command->name); _usage(cmd->command->name);
log_debug("Completed: %s", cmd->cmd_line);
return ret; return ret;
} }
@ -1163,7 +1195,7 @@ static void _read_history(struct cmd_context *cmd)
if (read_history(hist_file)) if (read_history(hist_file))
log_very_verbose("Couldn't read history from %s.", hist_file); log_very_verbose("Couldn't read history from %s.", hist_file);
stifle_history(find_config_int(cmd->cft->root, "shell/history_size", stifle_history(find_config_tree_int(cmd, "shell/history_size",
DEFAULT_MAX_HISTORY)); DEFAULT_MAX_HISTORY));
} }
@ -1335,7 +1367,7 @@ static int _lvm1_fallback(struct cmd_context *cmd)
char vsn[80]; char vsn[80];
int dm_present; int dm_present;
if (!find_config_int(cmd->cft->root, "global/fallback_to_lvm1", if (!find_config_tree_int(cmd, "global/fallback_to_lvm1",
DEFAULT_FALLBACK_TO_LVM1) || DEFAULT_FALLBACK_TO_LVM1) ||
strncmp(cmd->kernel_vsn, "2.4.", 4)) strncmp(cmd->kernel_vsn, "2.4.", 4))
return 0; return 0;

View File

@ -301,7 +301,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
lp->stripe_size = seg_stripesize; lp->stripe_size = seg_stripesize;
} else { } else {
lp->stripe_size = lp->stripe_size =
find_config_int(cmd->cft->root, find_config_tree_int(cmd,
"metadata/stripesize", "metadata/stripesize",
DEFAULT_STRIPESIZE) * 2; DEFAULT_STRIPESIZE) * 2;
log_print("Using default stripesize %s", log_print("Using default stripesize %s",

View File

@ -185,13 +185,13 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0)) pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0))
* 2; * 2;
if (!pvmetadatasize) if (!pvmetadatasize)
pvmetadatasize = find_config_int(cmd->cft->root, pvmetadatasize = find_config_tree_int(cmd,
"metadata/pvmetadatasize", "metadata/pvmetadatasize",
DEFAULT_PVMETADATASIZE); DEFAULT_PVMETADATASIZE);
pvmetadatacopies = arg_int_value(cmd, metadatacopies_ARG, -1); pvmetadatacopies = arg_int_value(cmd, metadatacopies_ARG, -1);
if (pvmetadatacopies < 0) if (pvmetadatacopies < 0)
pvmetadatacopies = find_config_int(cmd->cft->root, pvmetadatacopies = find_config_tree_int(cmd,
"metadata/pvmetadatacopies", "metadata/pvmetadatacopies",
DEFAULT_PVMETADATACOPIES); DEFAULT_PVMETADATACOPIES);

View File

@ -134,73 +134,73 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
int aligned, buffered, headings; int aligned, buffered, headings;
aligned = find_config_int(cmd->cft->root, "report/aligned", aligned = find_config_tree_int(cmd, "report/aligned",
DEFAULT_REP_ALIGNED); DEFAULT_REP_ALIGNED);
buffered = find_config_int(cmd->cft->root, "report/buffered", buffered = find_config_tree_int(cmd, "report/buffered",
DEFAULT_REP_BUFFERED); DEFAULT_REP_BUFFERED);
headings = find_config_int(cmd->cft->root, "report/headings", headings = find_config_tree_int(cmd, "report/headings",
DEFAULT_REP_HEADINGS); DEFAULT_REP_HEADINGS);
separator = find_config_str(cmd->cft->root, "report/separator", separator = find_config_tree_str(cmd, "report/separator",
DEFAULT_REP_SEPARATOR); DEFAULT_REP_SEPARATOR);
switch (report_type) { switch (report_type) {
case LVS: case LVS:
keys = find_config_str(cmd->cft->root, "report/lvs_sort", keys = find_config_tree_str(cmd, "report/lvs_sort",
DEFAULT_LVS_SORT); DEFAULT_LVS_SORT);
if (!arg_count(cmd, verbose_ARG)) if (!arg_count(cmd, verbose_ARG))
options = find_config_str(cmd->cft->root, options = find_config_tree_str(cmd,
"report/lvs_cols", "report/lvs_cols",
DEFAULT_LVS_COLS); DEFAULT_LVS_COLS);
else else
options = find_config_str(cmd->cft->root, options = find_config_tree_str(cmd,
"report/lvs_cols_verbose", "report/lvs_cols_verbose",
DEFAULT_LVS_COLS_VERB); DEFAULT_LVS_COLS_VERB);
break; break;
case VGS: case VGS:
keys = find_config_str(cmd->cft->root, "report/vgs_sort", keys = find_config_tree_str(cmd, "report/vgs_sort",
DEFAULT_VGS_SORT); DEFAULT_VGS_SORT);
if (!arg_count(cmd, verbose_ARG)) if (!arg_count(cmd, verbose_ARG))
options = find_config_str(cmd->cft->root, options = find_config_tree_str(cmd,
"report/vgs_cols", "report/vgs_cols",
DEFAULT_VGS_COLS); DEFAULT_VGS_COLS);
else else
options = find_config_str(cmd->cft->root, options = find_config_tree_str(cmd,
"report/vgs_cols_verbose", "report/vgs_cols_verbose",
DEFAULT_VGS_COLS_VERB); DEFAULT_VGS_COLS_VERB);
break; break;
case PVS: case PVS:
keys = find_config_str(cmd->cft->root, "report/pvs_sort", keys = find_config_tree_str(cmd, "report/pvs_sort",
DEFAULT_PVS_SORT); DEFAULT_PVS_SORT);
if (!arg_count(cmd, verbose_ARG)) if (!arg_count(cmd, verbose_ARG))
options = find_config_str(cmd->cft->root, options = find_config_tree_str(cmd,
"report/pvs_cols", "report/pvs_cols",
DEFAULT_PVS_COLS); DEFAULT_PVS_COLS);
else else
options = find_config_str(cmd->cft->root, options = find_config_tree_str(cmd,
"report/pvs_cols_verbose", "report/pvs_cols_verbose",
DEFAULT_PVS_COLS_VERB); DEFAULT_PVS_COLS_VERB);
break; break;
case SEGS: case SEGS:
keys = find_config_str(cmd->cft->root, "report/segs_sort", keys = find_config_tree_str(cmd, "report/segs_sort",
DEFAULT_SEGS_SORT); DEFAULT_SEGS_SORT);
if (!arg_count(cmd, verbose_ARG)) if (!arg_count(cmd, verbose_ARG))
options = find_config_str(cmd->cft->root, options = find_config_tree_str(cmd,
"report/segs_cols", "report/segs_cols",
DEFAULT_SEGS_COLS); DEFAULT_SEGS_COLS);
else else
options = find_config_str(cmd->cft->root, options = find_config_tree_str(cmd,
"report/segs_cols_verbose", "report/segs_cols_verbose",
DEFAULT_SEGS_COLS_VERB); DEFAULT_SEGS_COLS_VERB);
break; break;
case PVSEGS: case PVSEGS:
keys = find_config_str(cmd->cft->root, "report/pvsegs_sort", keys = find_config_tree_str(cmd, "report/pvsegs_sort",
DEFAULT_PVSEGS_SORT); DEFAULT_PVSEGS_SORT);
if (!arg_count(cmd, verbose_ARG)) if (!arg_count(cmd, verbose_ARG))
options = find_config_str(cmd->cft->root, options = find_config_tree_str(cmd,
"report/pvsegs_cols", "report/pvsegs_cols",
DEFAULT_PVSEGS_COLS); DEFAULT_PVSEGS_COLS);
else else
options = find_config_str(cmd->cft->root, options = find_config_tree_str(cmd,
"report/pvsegs_cols_verbose", "report/pvsegs_cols_verbose",
DEFAULT_PVSEGS_COLS_VERB); DEFAULT_PVSEGS_COLS_VERB);
break; break;

View File

@ -71,14 +71,14 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
UINT64_C(0)) * 2; UINT64_C(0)) * 2;
if (!pvmetadatasize) if (!pvmetadatasize)
pvmetadatasize = pvmetadatasize =
find_config_int(cmd->cft->root, find_config_tree_int(cmd,
"metadata/pvmetadatasize", "metadata/pvmetadatasize",
DEFAULT_PVMETADATASIZE); DEFAULT_PVMETADATASIZE);
pvmetadatacopies = arg_int_value(cmd, metadatacopies_ARG, -1); pvmetadatacopies = arg_int_value(cmd, metadatacopies_ARG, -1);
if (pvmetadatacopies < 0) if (pvmetadatacopies < 0)
pvmetadatacopies = pvmetadatacopies =
find_config_int(cmd->cft->root, find_config_tree_int(cmd,
"metadata/pvmetadatacopies", "metadata/pvmetadatacopies",
DEFAULT_PVMETADATACOPIES); DEFAULT_PVMETADATACOPIES);
} }