summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2016-08-08 12:55:15 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2016-08-09 18:49:11 +0200
commit54bf15555be1808eb292cfc3edeece236a1c9744 (patch)
tree42dd30ada3a9cf54f8ee02394c099ae96cdf13c6
parent785e2c31f553b0d2e98eb2a0d2087c942da81be7 (diff)
downloadlvm2-54bf15555be1808eb292cfc3edeece236a1c9744.tar.gz
refactor: modify original _check_profile fn and rename to config_force_check for general use
-rw-r--r--lib/config/config.c9
-rw-r--r--lib/config/config.h3
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/config/config.c b/lib/config/config.c
index 784c4b05b..a569444dd 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -2113,7 +2113,7 @@ bad:
return NULL;
}
-static int _check_profile(struct cmd_context *cmd, struct profile *profile)
+int config_force_check(struct cmd_context *cmd, config_source_t source, struct dm_config_tree *cft)
{
struct cft_check_handle *handle;
int r;
@@ -2124,9 +2124,8 @@ static int _check_profile(struct cmd_context *cmd, struct profile *profile)
}
handle->cmd = cmd;
- handle->cft = profile->cft;
- handle->source = profile->source;
- /* the check is compulsory - allow only profilable items in a profile config! */
+ handle->cft = cft;
+ handle->source = source;
handle->force_check = 1;
/* provide warning messages only if config/checks=1 */
handle->suppress_messages = !find_config_tree_bool(cmd, config_checks_CFG, NULL);
@@ -2252,7 +2251,7 @@ int load_profile(struct cmd_context *cmd, struct profile *profile) {
* messages to be suppressed, but the check itself is always done
* for profiles!
*/
- if (!_check_profile(cmd, profile)) {
+ if (!config_force_check(cmd, profile->source, profile->cft)) {
log_error("Ignoring invalid %s %s.",
_config_source_names[profile->source], profile->name);
config_destroy(profile->cft);
diff --git a/lib/config/config.h b/lib/config/config.h
index 157cfeb1c..659b8b00b 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -216,7 +216,10 @@ struct cft_check_handle {
};
int config_def_get_path(char *buf, size_t buf_size, int id);
+/* Checks config using given handle - the handle may be reused. */
int config_def_check(struct cft_check_handle *handle);
+/* Forces config check and automatically creates a new handle inside with defaults and discards the handle after the check. */
+int config_force_check(struct cmd_context *cmd, config_source_t source, struct dm_config_tree *cft);
int override_config_tree_from_string(struct cmd_context *cmd, const char *config_settings);
int override_config_tree_from_profile(struct cmd_context *cmd, struct profile *profile);