diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2013-07-08 14:13:09 +0200 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2013-07-08 15:57:49 +0200 |
commit | 661406a417e3cbf2170ba7c3debd767d50e99cae (patch) | |
tree | b66d4ecbcc7b1c2d48ad4e7d8f8fb1ba7060a77e /tools/dumpconfig.c | |
parent | f5584d420356c8ca0b797952b07f5b5387957c17 (diff) | |
download | lvm2-661406a417e3cbf2170ba7c3debd767d50e99cae.tar.gz |
config: fix use of last config check status if creating CFG_DEF_TREE_MISSING tree
When CFG_DEF_TREE_MISSING is created, it needs to know the status
of the check done on the tree used (the CFG_USED flag).
This bug was introduced with f1c292cc38f4ba2e8d9b7272bc1a1ce17bd729a5
"make it possible to run several instances of configuration check at
once". This patch separated the CFG_USED and CFG_VALID flags in
a separate 'status' field in struct cft_check_handle.
However, when creating some trees, like CFG_DEF_TREE_MISSING,
we need this status to do a comparison with full config definition
to determine which items are missing and for which default values
were used. Otherwise, all items would be considered missing.
So, pass this status in a new field called 'check_status' in
struct config_def_tree_spec that defines how the (dumpconfig) tree
should be constructed (and this struct is passed to
config_def_create_tree fn then).
Diffstat (limited to 'tools/dumpconfig.c')
-rw-r--r-- | tools/dumpconfig.c | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c index ebee78629..3839defab 100644 --- a/tools/dumpconfig.c +++ b/tools/dumpconfig.c @@ -45,13 +45,30 @@ static struct cft_check_handle *_get_cft_check_handle(struct cmd_context *cmd) return handle; } +static int _do_def_check(struct cmd_context *cmd, struct cft_check_handle **cft_check_handle) +{ + struct cft_check_handle *handle; + + if (!(handle = _get_cft_check_handle(cmd))) + return 0; + + handle->force_check = 1; + handle->skip_if_checked = 1; + handle->suppress_messages = 1; + + config_def_check(cmd, handle); + *cft_check_handle = handle; + + return 1; +} + int dumpconfig(struct cmd_context *cmd, int argc, char **argv) { const char *file = arg_str_value(cmd, file_ARG, NULL); const char *type = arg_str_value(cmd, configtype_ARG, "current"); struct config_def_tree_spec tree_spec = {0}; struct dm_config_tree *cft = NULL; - struct cft_check_handle *cft_check_handle; + struct cft_check_handle *cft_check_handle = NULL; int r = ECMD_PROCESSED; if (arg_count(cmd, configtype_ARG) && arg_count(cmd, validate_ARG)) { @@ -105,29 +122,31 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv) if (!strcmp(type, "current")) { tree_spec.type = CFG_DEF_TREE_CURRENT; - - if (!(cft_check_handle = _get_cft_check_handle(cmd))) + if (!_do_def_check(cmd, &cft_check_handle)) return ECMD_FAILED; - - cft_check_handle->force_check = 1; - cft_check_handle->skip_if_checked = 1; - cft_check_handle->suppress_messages = 1; - - config_def_check(cmd, cft_check_handle); } - - else if (!strcmp(type, "default")) - tree_spec.type = CFG_DEF_TREE_DEFAULT; - else if (!strcmp(type, "missing")) + else if (!strcmp(type, "missing")) { tree_spec.type = CFG_DEF_TREE_MISSING; - else if (!strcmp(type, "new")) + if (!_do_def_check(cmd, &cft_check_handle)) + return ECMD_FAILED; + } + else if (!strcmp(type, "default")) { + tree_spec.type = CFG_DEF_TREE_DEFAULT; + /* default type does not require check status */ + } + else if (!strcmp(type, "new")) { tree_spec.type = CFG_DEF_TREE_NEW; + /* new type does not require check status */ + } else { log_error("Incorrect type of configuration specified. " "Expected one of: current, default, missing, new."); return EINVALID_CMD_LINE; } + if (cft_check_handle) + tree_spec.check_status = cft_check_handle->status; + if (tree_spec.type == CFG_DEF_TREE_CURRENT) cft = cmd->cft; else |