summaryrefslogtreecommitdiff
path: root/tools/dumpconfig.c
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2014-03-03 12:34:11 +0100
committerPeter Rajnoha <prajnoha@redhat.com>2014-03-06 10:54:17 +0100
commitb53ec372864cea412505327012cc46dc06dec366 (patch)
tree51cbf3f164ac2274016b757944a528e00ffa3b32 /tools/dumpconfig.c
parente2870c94cf501f15ff9b1201bf468b40c1efd6d3 (diff)
downloadlvm2-b53ec372864cea412505327012cc46dc06dec366.tar.gz
config: add CFG_DEFAULT_RUN_TIME for config options with runtime defaults
Previously, we declared a default value as undefined ("NULL") for settings which require runtime context to be set first (e.g. settings for paths that rely on SYSTEM_DIR environment variable or they depend on any other setting in some way). If we want to output default values as they are really used in runtime, we should make it possible to define a default value as function which is evaluated, not just providing a firm constant value as it was before. This patch defines simple prototypes for such functions. Also, there's new helper macros "cfg_runtime" and "cfg_array_runtime" - they provide exactly the same functionality as the original "cfg" and "cfg_array" macros when defining the configuration settings in config_settings.h, but they don't set the constant default value. Instead, they automatically link the configuration setting definition with one of these functions: typedef int (*t_fn_CFG_TYPE_BOOL) (struct cmd_context *cmd, struct profile *profile); typedef int (*t_fn_CFG_TYPE_INT) (struct cmd_context *cmd, struct profile *profile); typedef float (*t_fn_CFG_TYPE_FLOAT) (struct cmd_context *cmd, struct profile *profile); typedef const char* (*t_fn_CFG_TYPE_STRING) (struct cmd_context *cmd, struct profile *profile); typedef const char* (*t_fn_CFG_TYPE_ARRAY) (struct cmd_context *cmd, struct profile *profile); (The new macros actually set the CFG_DEFAULT_RUNTIME flag properly and set the default value link to the function accordingly). Then such configuration setting requires a function of selected type to be defined. This function has a predefined name: get_default_<id> ...where the <id> is the id of the setting as defined in config_settings.h. For example "backup_archive_dir_CFG" if defined as a setting with default value evaluated in runtime with "cfg_runtime" will automatically have "get_default_backup_archive_dir_CFG" function linked to this setting to get the default value.
Diffstat (limited to 'tools/dumpconfig.c')
-rw-r--r--tools/dumpconfig.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index cb88bc646..dd8673389 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -97,6 +97,8 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
struct cft_check_handle *cft_check_handle = NULL;
int r = ECMD_PROCESSED;
+ tree_spec.cmd = cmd;
+
if (arg_count(cmd, configtype_ARG) && arg_count(cmd, validate_ARG)) {
log_error("Only one of --type and --validate permitted.");
return EINVALID_CMD_LINE;