Skip to contentSkip to conversation

master - dumpconfig: add --unconfigured option

PATCH David Teigland 1 participant 1 message Apr 17, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5cd6381717696ad1513a9f8ff1cbd8fa3098e4b1
Commit:        5cd6381717696ad1513a9f8ff1cbd8fa3098e4b1
Parent:        061e371319676a914a65f07678d0d15f4000c468
Author:        David Teigland <[email protected]>
AuthorDate:    Fri Apr 17 11:31:16 2015 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Fri Apr 17 11:35:34 2015 -0500

dumpconfig: add --unconfigured option

Using this option, default string values that are
configurable are printed as unconfigured values,
e.g. "@CONFDIR@" instead of "/etc".

---
 WHATS_NEW                    |    1 +
 lib/config/config.c          |   13 +-
 lib/config/config.h          |   12 +-
 lib/config/config_settings.h |  400 +++++++++++++++++++++---------------------
 tools/args.h                 |    1 +
 tools/commands.h             |    3 +-
 tools/dumpconfig.c           |    2 +
 7 files changed, 221 insertions(+), 211 deletions(-)
WHATS_NEW +1 -0
index 29e461c..9c306db 100644
@@ -1,5 +1,6 @@
 Version 2.02.119 - 
 ==================================
+  Add --unconfigured option to dumpconfig to print strings unconfigured.
   Add --withfullcomments option to dumpconfig to print full comment.
   Check for lvm binary in blkdeactivate and skip LVM processing if not present.
   Add --enable-halvm and --disable-halvm options to lvmconf script.
lib/config/config.c +8 -5
index 8f116cd..57e7cb9 100644
@@ -65,11 +65,11 @@ struct config_source {
  * Map each ID to respective definition of the configuration item.
  */
 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(id, name, parent, flags, type, default_value, since_version, comment) {id, parent, name, type, {.v_##type = default_value}, flags, since_version, 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_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_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_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, 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, 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, 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, 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"
 #undef cfg_section
 #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)))
 					str = "";
 				cn->v->v.str = str;
+
+				if (spec->unconfigured && def->unconfigured_path)
+					cn->v->v.str = def->unconfigured_path;
 				break;
 			default:
 				log_error(INTERNAL_ERROR "_add_def_node: unknown type");
lib/config/config.h +7 -5
index 72c7606..54bd183 100644
@@ -121,6 +121,7 @@ typedef struct cfg_def_item {
 	cfg_def_value_t default_value;	/* default value (only for settings) */
 	uint16_t flags;			/* configuration item definition flags */
 	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 */
 } cfg_def_item_t;
 
@@ -147,6 +148,7 @@ struct config_def_tree_spec {
 	unsigned withcomments:1;		/* include first line of comment */
 	unsigned withfullcomments:1;		/* include all comment lines */
 	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) */
 };
 
@@ -162,11 +164,11 @@ struct config_def_tree_spec {
  * Register ID for each possible item in the configuration tree.
  */
 enum {
-#define cfg_section(id, name, parent, flags, since_version, comment) id,
-#define cfg(id, name, parent, flags, type, default_value, since_version, comment) id,
-#define cfg_runtime(id, name, parent, flags, type, since_version, comment) id,
-#define cfg_array(id, name, parent, flags, types, default_value, since_version, comment) id,
-#define cfg_array_runtime(id, name, parent, flags, types, 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, unconfigured_path, 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, unconfigured_path, comment) id,
+#define cfg_array_runtime(id, name, parent, flags, types, since_version, unconfigured_path, comment) id,
 #include "config_settings.h"
 #undef cfg_section
 #undef cfg
lib/config/config_settings.h +200 -200

1,189 lines not on this page · raw message

tools/args.h +1 -0
index 4a43457..201a2ef 100644
@@ -109,6 +109,7 @@ arg(unbuffered_ARG, '\0', "unbuffered", NULL, 0)
 arg(uncache_ARG, '\0', "uncache", NULL, 0)
 arg(cachepolicy_ARG, '\0', "cachepolicy", string_arg, 0)
 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(unquoted_ARG, '\0', "unquoted", NULL, 0)
 arg(use_policies_ARG, '\0', "use-policies", NULL, 0)
tools/commands.h +2 -1
index b9c7a8b..10916bf 100644
@@ -71,11 +71,12 @@ xx(dumpconfig,
    "\t[--validate]\n"
    "\t[--withcomments]\n"
    "\t[--withfullcomments]\n"
+   "\t[--unconfigured]\n"
    "\t[--withversions]\n"
    "\t[ConfigurationNode...]\n",
    atversion_ARG, configtype_ARG, file_ARG, ignoreadvanced_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,
    "List available metadata formats",
tools/dumpconfig.c +2 -0
index 6d2108f..2d1cd9c 100644
@@ -221,6 +221,8 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
 		tree_spec.withcomments = 1;
 	if (arg_count(cmd, withfullcomments_ARG))
 		tree_spec.withfullcomments = 1;
+	if (arg_count(cmd, unconfigured_ARG))
+		tree_spec.unconfigured = 1;
 
 	if (arg_count(cmd, withversions_ARG))
 		tree_spec.withversions = 1;