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

refactor: modify original _check_profile fn and rename to config_force_check for general use

This commit is contained in:
Peter Rajnoha 2016-08-08 12:55:15 +02:00
parent 785e2c31f5
commit 54bf15555b
2 changed files with 7 additions and 5 deletions

View File

@ -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);

View File

@ -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);