1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-08-02 04:22:02 +03:00

config: make it possible to run several instances of configuration check at once

Before, the status of the configuration check (config_def_check fn call)
was saved directly in global configuration definitinion array (as part
of the cfg_def_item_t/flags)

This patch introduces the "struct cft_check_handle" that defines
configuration check parameters as well as separate place to store
the status (status here means CFG_USED and CFG_VALID flags, formerly
saved in cfg_def_item_t/flags). This struct can hold config check
parameters as well as the status for each config tree separately,
thus making it possible to run several instances of config_def_check
without interference.
This commit is contained in:
Peter Rajnoha
2013-06-26 14:53:57 +02:00
parent 8769033e07
commit f1c292cc38
5 changed files with 127 additions and 64 deletions

View File

@ -263,6 +263,29 @@ static int _check_disable_udev(const char *msg) {
return 0;
}
static int _check_config(struct cmd_context *cmd)
{
if (!find_config_tree_bool(cmd, config_checks_CFG, NULL))
return 1;
if (!cmd->cft_check_handle) {
if (!(cmd->cft_check_handle = dm_pool_zalloc(cmd->libmem, sizeof(*cmd->cft_check_handle)))) {
log_error("Configuration check handle allocation failed.");
return 0;
}
}
cmd->cft_check_handle->cft = cmd->cft;
if (!config_def_check(cmd, cmd->cft_check_handle) &&
find_config_tree_bool(cmd, config_abort_on_errors_CFG, NULL)) {
log_error("LVM configuration invalid.");
return 0;
}
return 1;
}
static int _process_config(struct cmd_context *cmd)
{
mode_t old_umask;
@ -275,10 +298,8 @@ static int _process_config(struct cmd_context *cmd)
int udev_disabled = 0;
char sysfs_dir[PATH_MAX];
if (!config_def_check(cmd, 0, 0, 0) && find_config_tree_bool(cmd, config_abort_on_errors_CFG, NULL)) {
log_error("LVM configuration invalid.");
return 0;
}
if (!_check_config(cmd))
return_0;
/* umask */
cmd->default_settings.umask = find_config_tree_int(cmd, global_umask_CFG, NULL);

View File

@ -102,7 +102,9 @@ struct cmd_context {
struct profile_params *profile_params; /* profile handling params including loaded profile configs */
struct dm_config_tree *cft; /* the whole cascade: CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_FILE/CONFIG_MERGED_FILES */
int config_initialized; /* used to reinitialize config if previous init was not successful */
struct dm_hash_table *cft_def_hash; /* config definition hash used for validity check (item type + item recognized) */
struct cft_check_handle *cft_check_handle;
/* selected settings with original default/configured value which can be changed during cmd processing */
struct config_info default_settings;