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

config: add profile arg to find_config_tree_str_allow_empty

This commit is contained in:
Peter Rajnoha 2013-06-25 12:30:08 +02:00
parent 06dd66af54
commit 8ac4fcf8ff
4 changed files with 15 additions and 5 deletions

View File

@ -1560,7 +1560,7 @@ static int _thin_pool_callback(struct dm_tree_node *node,
const struct dm_config_node *cn;
const struct dm_config_value *cv;
const char *thin_check =
find_config_tree_str_allow_empty(data->pool_lv->vg->cmd, global_thin_check_executable_CFG);
find_config_tree_str_allow_empty(data->pool_lv->vg->cmd, global_thin_check_executable_CFG, NULL);
const struct logical_volume *mlv = first_seg(data->pool_lv)->metadata_lv;
size_t len = strlen(dmdir) + 2 * (strlen(mlv->vg->name) + strlen(mlv->name)) + 3;
char meta_path[len];

View File

@ -202,7 +202,7 @@ static void _init_logging(struct cmd_context *cmd)
init_indent(find_config_tree_bool(cmd, log_indent_CFG));
init_abort_on_internal_errors(find_config_tree_bool(cmd, global_abort_on_internal_errors_CFG));
cmd->default_settings.msg_prefix = find_config_tree_str_allow_empty(cmd, log_prefix_CFG);
cmd->default_settings.msg_prefix = find_config_tree_str_allow_empty(cmd, log_prefix_CFG, NULL);
init_msg_prefix(cmd->default_settings.msg_prefix);
cmd->default_settings.cmd_name = find_config_tree_bool(cmd, log_command_names_CFG);

View File

@ -821,17 +821,27 @@ const char *find_config_tree_str(struct cmd_context *cmd, int id, struct profile
return str;
}
const char *find_config_tree_str_allow_empty(struct cmd_context *cmd, int id)
const char *find_config_tree_str_allow_empty(struct cmd_context *cmd, int id, struct profile *profile)
{
cfg_def_item_t *item = cfg_def_get_item_p(id);
const char *path = cfg_def_get_path(item);
int profile_applied = 0;
const char *str;
if (item->type != CFG_TYPE_STRING)
log_error(INTERNAL_ERROR "%s cfg tree element not declared as string.", path);
if (!(item->flags & CFG_ALLOW_EMPTY))
log_error(INTERNAL_ERROR "%s cfg tree element not declared to allow empty values.", path);
return dm_config_tree_find_str_allow_empty(cmd->cft, path, cfg_def_get_default_value(item, CFG_TYPE_STRING));
if (profile && !cmd->profile_params->global_profile)
profile_applied = override_config_tree_from_profile(cmd, profile);
str = dm_config_tree_find_str_allow_empty(cmd->cft, path, cfg_def_get_default_value(item, CFG_TYPE_STRING));
if (profile_applied)
remove_config_tree_by_source(cmd, CONFIG_PROFILE);
return str;
}
int find_config_tree_int(struct cmd_context *cmd, int id)

View File

@ -166,7 +166,7 @@ int merge_config_tree(struct cmd_context *cmd, struct dm_config_tree *cft,
*/
const struct dm_config_node *find_config_tree_node(struct cmd_context *cmd, int id, struct profile *profile);
const char *find_config_tree_str(struct cmd_context *cmd, int id, struct profile *profile);
const char *find_config_tree_str_allow_empty(struct cmd_context *cmd, int id);
const char *find_config_tree_str_allow_empty(struct cmd_context *cmd, int id, struct profile *profile);
int find_config_tree_int(struct cmd_context *cmd, int id);
int64_t find_config_tree_int64(struct cmd_context *cmd, int id);
float find_config_tree_float(struct cmd_context *cmd, int id);