summaryrefslogtreecommitdiff
path: root/lib/commands
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2013-06-26 14:53:57 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2013-07-02 15:22:11 +0200
commitf1c292cc38f4ba2e8d9b7272bc1a1ce17bd729a5 (patch)
treecfddf4a2016df3b31103a8b5bfeb8c3544a796e2 /lib/commands
parent8769033e078c79ee4167c5186d7407d1729fd8a4 (diff)
downloadlvm2-f1c292cc38f4ba2e8d9b7272bc1a1ce17bd729a5.tar.gz
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.
Diffstat (limited to 'lib/commands')
-rw-r--r--lib/commands/toolcontext.c29
-rw-r--r--lib/commands/toolcontext.h2
2 files changed, 27 insertions, 4 deletions
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index b7e3d46ef..4919b93d2 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -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);
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 42a4e54f2..2d90138ed 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -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;