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

dumpconfig: add --unconfigured option

Using this option, default string values that are
configurable are printed as unconfigured values,
e.g. "@CONFDIR@" instead of "/etc".
This commit is contained in:
David Teigland 2015-04-17 11:31:16 -05:00
parent 061e371319
commit 5cd6381717
7 changed files with 221 additions and 211 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.119 - Version 2.02.119 -
================================== ==================================
Add --unconfigured option to dumpconfig to print strings unconfigured.
Add --withfullcomments option to dumpconfig to print full comment. Add --withfullcomments option to dumpconfig to print full comment.
Check for lvm binary in blkdeactivate and skip LVM processing if not present. Check for lvm binary in blkdeactivate and skip LVM processing if not present.
Add --enable-halvm and --disable-halvm options to lvmconf script. Add --enable-halvm and --disable-halvm options to lvmconf script.

View File

@ -65,11 +65,11 @@ struct config_source {
* Map each ID to respective definition of the configuration item. * Map each ID to respective definition of the configuration item.
*/ */
static struct cfg_def_item _cfg_def_items[CFG_COUNT + 1] = { static struct cfg_def_item _cfg_def_items[CFG_COUNT + 1] = {
#define cfg_section(id, name, parent, flags, since_version, comment) {id, parent, name, CFG_TYPE_SECTION, {0}, flags, since_version, comment}, #define cfg_section(id, name, parent, flags, since_version, unconfigured_path, comment) {id, parent, name, CFG_TYPE_SECTION, {0}, flags, since_version, unconfigured_path, comment},
#define cfg(id, name, parent, flags, type, default_value, since_version, comment) {id, parent, name, type, {.v_##type = default_value}, flags, since_version, comment}, #define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_path, comment) {id, parent, name, type, {.v_##type = default_value}, flags, since_version, unconfigured_path, comment},
#define cfg_runtime(id, name, parent, flags, type, since_version, comment) {id, parent, name, type, {.fn_##type = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, comment}, #define cfg_runtime(id, name, parent, flags, type, since_version, unconfigured_path, comment) {id, parent, name, type, {.fn_##type = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, unconfigured_path, comment},
#define cfg_array(id, name, parent, flags, types, default_value, since_version, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.v_CFG_TYPE_STRING = default_value}, flags, since_version, comment}, #define cfg_array(id, name, parent, flags, types, default_value, since_version, unconfigured_path, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.v_CFG_TYPE_STRING = default_value}, flags, since_version, unconfigured_path, comment},
#define cfg_array_runtime(id, name, parent, flags, types, since_version, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.fn_CFG_TYPE_STRING = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, comment}, #define cfg_array_runtime(id, name, parent, flags, types, since_version, unconfigured_path, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.fn_CFG_TYPE_STRING = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, unconfigured_path, comment},
#include "config_settings.h" #include "config_settings.h"
#undef cfg_section #undef cfg_section
#undef cfg #undef cfg
@ -1697,6 +1697,9 @@ static struct dm_config_node *_add_def_node(struct dm_config_tree *cft,
if (!(str = cfg_def_get_default_value_hint(spec->cmd, def, CFG_TYPE_STRING, NULL))) if (!(str = cfg_def_get_default_value_hint(spec->cmd, def, CFG_TYPE_STRING, NULL)))
str = ""; str = "";
cn->v->v.str = str; cn->v->v.str = str;
if (spec->unconfigured && def->unconfigured_path)
cn->v->v.str = def->unconfigured_path;
break; break;
default: default:
log_error(INTERNAL_ERROR "_add_def_node: unknown type"); log_error(INTERNAL_ERROR "_add_def_node: unknown type");

View File

@ -121,6 +121,7 @@ typedef struct cfg_def_item {
cfg_def_value_t default_value; /* default value (only for settings) */ cfg_def_value_t default_value; /* default value (only for settings) */
uint16_t flags; /* configuration item definition flags */ uint16_t flags; /* configuration item definition flags */
uint16_t since_version; /* version this item appeared in */ uint16_t since_version; /* version this item appeared in */
const char *unconfigured_path; /* path in terms of @FOO@, pre-configured */
const char *comment; /* brief comment */ const char *comment; /* brief comment */
} cfg_def_item_t; } cfg_def_item_t;
@ -147,6 +148,7 @@ struct config_def_tree_spec {
unsigned withcomments:1; /* include first line of comment */ unsigned withcomments:1; /* include first line of comment */
unsigned withfullcomments:1; /* include all comment lines */ unsigned withfullcomments:1; /* include all comment lines */
unsigned withversions:1; /* include versions */ unsigned withversions:1; /* include versions */
unsigned unconfigured:1; /* use unconfigured path strings */
uint8_t *check_status; /* status of last tree check (currently needed for CFG_DEF_TREE_MISSING only) */ uint8_t *check_status; /* status of last tree check (currently needed for CFG_DEF_TREE_MISSING only) */
}; };
@ -162,11 +164,11 @@ struct config_def_tree_spec {
* Register ID for each possible item in the configuration tree. * Register ID for each possible item in the configuration tree.
*/ */
enum { enum {
#define cfg_section(id, name, parent, flags, since_version, comment) id, #define cfg_section(id, name, parent, flags, since_version, unconfigured_path, comment) id,
#define cfg(id, name, parent, flags, type, default_value, since_version, comment) id, #define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_path, comment) id,
#define cfg_runtime(id, name, parent, flags, type, since_version, comment) id, #define cfg_runtime(id, name, parent, flags, type, since_version, unconfigured_path, comment) id,
#define cfg_array(id, name, parent, flags, types, default_value, since_version, comment) id, #define cfg_array(id, name, parent, flags, types, default_value, since_version, unconfigured_path, comment) id,
#define cfg_array_runtime(id, name, parent, flags, types, since_version, comment) id, #define cfg_array_runtime(id, name, parent, flags, types, since_version, unconfigured_path, comment) id,
#include "config_settings.h" #include "config_settings.h"
#undef cfg_section #undef cfg_section
#undef cfg #undef cfg

File diff suppressed because it is too large Load Diff

View File

@ -109,6 +109,7 @@ arg(unbuffered_ARG, '\0', "unbuffered", NULL, 0)
arg(uncache_ARG, '\0', "uncache", NULL, 0) arg(uncache_ARG, '\0', "uncache", NULL, 0)
arg(cachepolicy_ARG, '\0', "cachepolicy", string_arg, 0) arg(cachepolicy_ARG, '\0', "cachepolicy", string_arg, 0)
arg(cachesettings_ARG, '\0', "cachesettings", string_arg, ARG_GROUPABLE) arg(cachesettings_ARG, '\0', "cachesettings", string_arg, ARG_GROUPABLE)
arg(unconfigured_ARG, '\0', "unconfigured", NULL, 0)
arg(units_ARG, '\0', "units", string_arg, 0) arg(units_ARG, '\0', "units", string_arg, 0)
arg(unquoted_ARG, '\0', "unquoted", NULL, 0) arg(unquoted_ARG, '\0', "unquoted", NULL, 0)
arg(use_policies_ARG, '\0', "use-policies", NULL, 0) arg(use_policies_ARG, '\0', "use-policies", NULL, 0)

View File

@ -71,11 +71,12 @@ xx(dumpconfig,
"\t[--validate]\n" "\t[--validate]\n"
"\t[--withcomments]\n" "\t[--withcomments]\n"
"\t[--withfullcomments]\n" "\t[--withfullcomments]\n"
"\t[--unconfigured]\n"
"\t[--withversions]\n" "\t[--withversions]\n"
"\t[ConfigurationNode...]\n", "\t[ConfigurationNode...]\n",
atversion_ARG, configtype_ARG, file_ARG, ignoreadvanced_ARG, atversion_ARG, configtype_ARG, file_ARG, ignoreadvanced_ARG,
ignoreunsupported_ARG, mergedconfig_ARG, metadataprofile_ARG, ignoreunsupported_ARG, mergedconfig_ARG, metadataprofile_ARG,
validate_ARG, withcomments_ARG, withfullcomments_ARG, withversions_ARG) validate_ARG, withcomments_ARG, withfullcomments_ARG, unconfigured_ARG, withversions_ARG)
xx(formats, xx(formats,
"List available metadata formats", "List available metadata formats",

View File

@ -221,6 +221,8 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
tree_spec.withcomments = 1; tree_spec.withcomments = 1;
if (arg_count(cmd, withfullcomments_ARG)) if (arg_count(cmd, withfullcomments_ARG))
tree_spec.withfullcomments = 1; tree_spec.withfullcomments = 1;
if (arg_count(cmd, unconfigured_ARG))
tree_spec.unconfigured = 1;
if (arg_count(cmd, withversions_ARG)) if (arg_count(cmd, withversions_ARG))
tree_spec.withversions = 1; tree_spec.withversions = 1;