mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
dumpconfig: add dumpconfig --type diff to show differences from defaults
This commit is contained in:
parent
76ff38fa5c
commit
5dcec1734e
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.106 -
|
Version 2.02.106 -
|
||||||
====================================
|
====================================
|
||||||
|
Add 'lvm dumpconfig --type diff' to show differences from defaults.
|
||||||
Fix swap signature detection for devices smaller then 2MB.
|
Fix swap signature detection for devices smaller then 2MB.
|
||||||
Reindent some clvmd.c code.
|
Reindent some clvmd.c code.
|
||||||
Use dm_malloc function in clvmd.c.
|
Use dm_malloc function in clvmd.c.
|
||||||
|
@ -1283,6 +1283,10 @@ static int _out_prefix_fn(const struct dm_config_node *cn, const char *line, voi
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((out->tree_spec->type == CFG_DEF_TREE_DIFF) &&
|
||||||
|
(!(out->tree_spec->check_status[cn->id] & CFG_DIFF)))
|
||||||
|
return 1;
|
||||||
|
|
||||||
cfg_def = cfg_def_get_item_p(cn->id);
|
cfg_def = cfg_def_get_item_p(cn->id);
|
||||||
|
|
||||||
if (out->tree_spec->withcomments) {
|
if (out->tree_spec->withcomments) {
|
||||||
@ -1324,7 +1328,12 @@ static int _out_line_fn(const struct dm_config_node *cn, const char *line, void
|
|||||||
struct out_baton *out = baton;
|
struct out_baton *out = baton;
|
||||||
struct cfg_def_item *cfg_def = cfg_def_get_item_p(cn->id);
|
struct cfg_def_item *cfg_def = cfg_def_get_item_p(cn->id);
|
||||||
|
|
||||||
|
if ((out->tree_spec->type == CFG_DEF_TREE_DIFF) &&
|
||||||
|
(!(out->tree_spec->check_status[cn->id] & CFG_DIFF)))
|
||||||
|
return 1;
|
||||||
|
|
||||||
fprintf(out->fp, "%s%s\n", (out->tree_spec->type != CFG_DEF_TREE_CURRENT) &&
|
fprintf(out->fp, "%s%s\n", (out->tree_spec->type != CFG_DEF_TREE_CURRENT) &&
|
||||||
|
(out->tree_spec->type != CFG_DEF_TREE_DIFF) &&
|
||||||
(cfg_def->flags & CFG_DEFAULT_UNDEFINED) ? "#" : "", line);
|
(cfg_def->flags & CFG_DEFAULT_UNDEFINED) ? "#" : "", line);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,8 @@ typedef enum {
|
|||||||
CFG_DEF_TREE_COMPLETE, /* CURRENT + MISSING, the tree actually used within execution, not implemented yet */
|
CFG_DEF_TREE_COMPLETE, /* CURRENT + MISSING, the tree actually used within execution, not implemented yet */
|
||||||
CFG_DEF_TREE_DEFAULT, /* tree of all possible config nodes with default values */
|
CFG_DEF_TREE_DEFAULT, /* tree of all possible config nodes with default values */
|
||||||
CFG_DEF_TREE_NEW, /* tree of all new nodes that appeared in given version */
|
CFG_DEF_TREE_NEW, /* tree of all new nodes that appeared in given version */
|
||||||
CFG_DEF_TREE_PROFILABLE /* tree of all nodes that are customizable by profiles */
|
CFG_DEF_TREE_PROFILABLE, /* tree of all nodes that are customizable by profiles */
|
||||||
|
CFG_DEF_TREE_DIFF, /* tree of all nodes that differ from defaults */
|
||||||
} cfg_def_tree_t;
|
} cfg_def_tree_t;
|
||||||
|
|
||||||
/* configuration definition tree specification */
|
/* configuration definition tree specification */
|
||||||
|
@ -57,7 +57,7 @@ xx(dumpconfig,
|
|||||||
PERMITTED_READ_ONLY,
|
PERMITTED_READ_ONLY,
|
||||||
"dumpconfig\n"
|
"dumpconfig\n"
|
||||||
"\t[-f|--file filename] \n"
|
"\t[-f|--file filename] \n"
|
||||||
"\t[--type {current|default|missing|new|profilable} \n"
|
"\t[--type {current|default|diff|missing|new|profilable} \n"
|
||||||
"\t[--atversion version]] \n"
|
"\t[--atversion version]] \n"
|
||||||
"\t[--ignoreadvanced] \n"
|
"\t[--ignoreadvanced] \n"
|
||||||
"\t[--ignoreunsupported] \n"
|
"\t[--ignoreunsupported] \n"
|
||||||
|
@ -56,18 +56,23 @@ static struct cft_check_handle *_get_cft_check_handle(struct cmd_context *cmd, s
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _do_def_check(struct cmd_context *cmd, struct dm_config_tree *cft,
|
static int _do_def_check(struct config_def_tree_spec *spec,
|
||||||
|
struct dm_config_tree *cft,
|
||||||
struct cft_check_handle **cft_check_handle)
|
struct cft_check_handle **cft_check_handle)
|
||||||
{
|
{
|
||||||
struct cft_check_handle *handle;
|
struct cft_check_handle *handle;
|
||||||
|
|
||||||
if (!(handle = _get_cft_check_handle(cmd, cft)))
|
if (!(handle = _get_cft_check_handle(spec->cmd, cft)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
handle->force_check = 1;
|
handle->force_check = 1;
|
||||||
handle->skip_if_checked = 1;
|
|
||||||
handle->suppress_messages = 1;
|
handle->suppress_messages = 1;
|
||||||
|
|
||||||
|
if (spec->type == CFG_DEF_TREE_DIFF)
|
||||||
|
handle->check_diff = 1;
|
||||||
|
else
|
||||||
|
handle->skip_if_checked = 1;
|
||||||
|
|
||||||
config_def_check(handle);
|
config_def_check(handle);
|
||||||
*cft_check_handle = handle;
|
*cft_check_handle = handle;
|
||||||
|
|
||||||
@ -168,14 +173,14 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
|
|
||||||
if (!strcmp(type, "current")) {
|
if (!strcmp(type, "current")) {
|
||||||
tree_spec.type = CFG_DEF_TREE_CURRENT;
|
tree_spec.type = CFG_DEF_TREE_CURRENT;
|
||||||
if (!_do_def_check(cmd, cft, &cft_check_handle)) {
|
if (!_do_def_check(&tree_spec, cft, &cft_check_handle)) {
|
||||||
r = ECMD_FAILED;
|
r = ECMD_FAILED;
|
||||||
goto_out;
|
goto_out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!strcmp(type, "missing")) {
|
else if (!strcmp(type, "missing")) {
|
||||||
tree_spec.type = CFG_DEF_TREE_MISSING;
|
tree_spec.type = CFG_DEF_TREE_MISSING;
|
||||||
if (!_do_def_check(cmd, cft, &cft_check_handle)) {
|
if (!_do_def_check(&tree_spec, cft, &cft_check_handle)) {
|
||||||
r = ECMD_FAILED;
|
r = ECMD_FAILED;
|
||||||
goto_out;
|
goto_out;
|
||||||
}
|
}
|
||||||
@ -184,6 +189,13 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
tree_spec.type = CFG_DEF_TREE_DEFAULT;
|
tree_spec.type = CFG_DEF_TREE_DEFAULT;
|
||||||
/* default type does not require check status */
|
/* default type does not require check status */
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(type, "diff")) {
|
||||||
|
tree_spec.type = CFG_DEF_TREE_DIFF;
|
||||||
|
if (!_do_def_check(&tree_spec, cft, &cft_check_handle)) {
|
||||||
|
r = ECMD_FAILED;
|
||||||
|
goto_out;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (!strcmp(type, "new")) {
|
else if (!strcmp(type, "new")) {
|
||||||
tree_spec.type = CFG_DEF_TREE_NEW;
|
tree_spec.type = CFG_DEF_TREE_NEW;
|
||||||
/* new type does not require check status */
|
/* new type does not require check status */
|
||||||
@ -209,6 +221,7 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
tree_spec.check_status = cft_check_handle->status;
|
tree_spec.check_status = cft_check_handle->status;
|
||||||
|
|
||||||
if ((tree_spec.type != CFG_DEF_TREE_CURRENT) &&
|
if ((tree_spec.type != CFG_DEF_TREE_CURRENT) &&
|
||||||
|
(tree_spec.type != CFG_DEF_TREE_DIFF) &&
|
||||||
!(cft = config_def_create_tree(&tree_spec))) {
|
!(cft = config_def_create_tree(&tree_spec))) {
|
||||||
r = ECMD_FAILED;
|
r = ECMD_FAILED;
|
||||||
goto_out;
|
goto_out;
|
||||||
|
Loading…
Reference in New Issue
Block a user