diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2014-03-03 13:30:13 +0100 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2014-03-06 11:16:04 +0100 |
commit | 11039589d36b54f8ddb7fe2b0d59dd2610a7e2f4 (patch) | |
tree | 4e390a4c54622852b5b4ee21cd42a1e7cfa3140b | |
parent | 0da1e5d9f8bdb2e4d385faf7c0f4604e63100acc (diff) | |
download | lvm2-11039589d36b54f8ddb7fe2b0d59dd2610a7e2f4.tar.gz |
config: runtime default for config/profile_dir
The config/profile_dir default value takes LVM_SYSTEM_DIR into consideraton.
-rw-r--r-- | lib/commands/toolcontext.c | 12 | ||||
-rw-r--r-- | lib/config/config.c | 13 | ||||
-rw-r--r-- | lib/config/config.h | 1 | ||||
-rw-r--r-- | lib/config/config_settings.h | 2 |
4 files changed, 17 insertions, 11 deletions
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index ce4349de6..72825921a 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -613,7 +613,6 @@ static int _init_tag_configs(struct cmd_context *cmd) static int _init_profiles(struct cmd_context *cmd) { - static char default_dir[PATH_MAX]; const char *dir; struct profile_params *pp; @@ -622,15 +621,8 @@ static int _init_profiles(struct cmd_context *cmd) return 0; } - if (!(dir = find_config_tree_str(cmd, config_profile_dir_CFG, NULL))) { - if (dm_snprintf(default_dir, sizeof(default_dir), "%s/%s", - cmd->system_dir, DEFAULT_PROFILE_SUBDIR) == -1) { - log_error("Couldn't create default profile path '%s/%s'.", - cmd->system_dir, DEFAULT_PROFILE_SUBDIR); - return 0; - } - dir = default_dir; - } + if (!(dir = find_config_tree_str(cmd, config_profile_dir_CFG, NULL))) + return_0; pp->dir = dm_pool_strdup(cmd->libmem, dir); dm_list_init(&pp->profiles_to_load); diff --git a/lib/config/config.c b/lib/config/config.c index 75b90fb0e..f3e105d0c 100644 --- a/lib/config/config.c +++ b/lib/config/config.c @@ -1674,3 +1674,16 @@ const char *get_default_backup_archive_dir_CFG(struct cmd_context *cmd, struct p return dm_pool_strdup(cmd->mem, buf); } + +const char *get_default_config_profile_dir_CFG(struct cmd_context *cmd, struct profile *profile) +{ + static char buf[PATH_MAX]; + + if (dm_snprintf(buf, sizeof(buf), "%s/%s", cmd->system_dir, DEFAULT_PROFILE_SUBDIR) == -1) { + log_error("Couldn't create default profile path '%s/%s'.", + cmd->system_dir, DEFAULT_PROFILE_SUBDIR); + return NULL; + } + + return dm_pool_strdup(cmd->mem, buf); +} diff --git a/lib/config/config.h b/lib/config/config.h index a042c6051..f380e26dd 100644 --- a/lib/config/config.h +++ b/lib/config/config.h @@ -234,5 +234,6 @@ const char *get_default_devices_cache_dir_CFG(struct cmd_context *cmd, struct pr const char *get_default_devices_cache_CFG(struct cmd_context *cmd, struct profile *profile); const char *get_default_backup_backup_dir_CFG(struct cmd_context *cmd, struct profile *profile); const char *get_default_backup_archive_dir_CFG(struct cmd_context *cmd, struct profile *profile); +const char *get_default_config_profile_dir_CFG(struct cmd_context *cmd, struct profile *profile); #endif diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h index d6ccf0e41..081d6128a 100644 --- a/lib/config/config_settings.h +++ b/lib/config/config_settings.h @@ -83,7 +83,7 @@ cfg_section(tags_CFG_SECTION, "tags", root_CFG_SECTION, 0, vsn(1, 0, 18), NULL) cfg(config_checks_CFG, "checks", config_CFG_SECTION, 0, CFG_TYPE_BOOL, 1, vsn(2, 2, 99), "Configuration tree check on each LVM command execution.") cfg(config_abort_on_errors_CFG, "abort_on_errors", config_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(2,2,99), "Abort LVM command execution if configuration is invalid.") -cfg(config_profile_dir_CFG, "profile_dir", config_CFG_SECTION, 0, CFG_TYPE_STRING, 0, vsn(2, 2, 99), "Directory with configuration profiles.") +cfg_runtime(config_profile_dir_CFG, "profile_dir", config_CFG_SECTION, 0, CFG_TYPE_STRING, vsn(2, 2, 99), "Directory with configuration profiles.") cfg(devices_dir_CFG, "dir", devices_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_DEV_DIR, vsn(1, 0, 0), NULL) cfg_array(devices_scan_CFG, "scan", devices_CFG_SECTION, 0, CFG_TYPE_STRING, "#S/dev", vsn(1, 0, 0), NULL) |