Skip to contentSkip to conversation

master - dumpconfig: add --type, --atversion and --validate arg

PATCH Peter Rajnoha 1 participant 1 message Mar 6, 2013

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=34350963d1b02d54205b1bdaa0c7778f4c5601fe
Commit:        34350963d1b02d54205b1bdaa0c7778f4c5601fe
Parent:        245b85692ec9f30153c1aa7216d81e65bb132792
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Tue Mar 5 17:48:29 2013 +0100
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Wed Mar 6 10:46:36 2013 +0100

dumpconfig: add --type, --atversion and --validate arg

lvm dumpconfig [--type {current|default|missing|new}] [--atversion] [--validate]

This patch adds above-mentioned args to lvm dumpconfig and it maps them to creation and writing out a configuration tree of a specific type (see also previous commit):

- current maps to CFG_TYPE_CURRENT
- default maps to CFG_TYPE_DEFAULT
- missing maps to CFG_TYPE_MISSING
- new maps to CFG_TYPE_NEW

If --type is not defined, dumpconfig defaults to "--type current" which is the original behaviour of dumpconfig before all these changes.

The --validate option just validates current configuration tree (lvm.conf/--config) and it writes a simple status message:

"LVM configuration valid" or "LVM configuration invalid"

---
 lib/config/config.c |    2 +-
 tools/args.h        |    3 ++
 tools/commands.h    |   13 +++++---
 tools/dumpconfig.c  |   80 +++++++++++++++++++++++++++++++++++++++++++++++++--
 tools/tools.h       |    1 +
 5 files changed, 90 insertions(+), 9 deletions(-)
lib/config/config.c +1 -1
index 43f9d21..a02f478 100644
@@ -488,7 +488,7 @@ static int _config_def_check_node(const char *vp, char *pvp, char *rp, char *prp
 
 	def->flags |= CFG_USED;
 	if (!_config_def_check_node_value(rp, cn->v, def, suppress_messages))
-		return 0;
+	return 0;
 
 	def->flags |= CFG_VALID;
 	return 1;
tools/args.h +3 -0
index 08ace69..8d9abd5 100644
@@ -79,6 +79,9 @@ arg(force_long_ARG, '\0', "force", NULL, ARG_COUNTABLE)
 arg(stripes_long_ARG, '\0', "stripes", int_arg, 0)
 arg(sysinit_ARG, '\0', "sysinit", NULL, 0)
 arg(thinpool_ARG, '\0', "thinpool", string_arg, 0)
+arg(configtype_ARG, '\0', "type", string_arg, 0)
+arg(atversion_ARG, '\0', "atversion", string_arg, 0)
+arg(validate_ARG, '\0', "validate", NULL, 0)
 
 /* Allow some variations */
 arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)
tools/commands.h +8 -5
index dedba54..dc245b9 100644
@@ -29,12 +29,15 @@ xx(e2fsadm,
 *********/
 
 xx(dumpconfig,
-   "Dump active configuration",
+   "Dump configuration",
    PERMITTED_READ_ONLY,
-   "dumpconfig "
-   "\t[-f|--file filename] " "\n"
-   "[ConfigurationVariable...]\n",
-   file_ARG)
+   "dumpconfig\n"
+   "\t[-f|--file filename] \n"
+   "\t[--type {current|default|missing|new} \n"
+   "\t[--atversion version]] \n"
+   "\t[--validate]\n"
+   "\t[ConfigurationNode...]\n",
+   file_ARG, configtype_ARG, atversion_ARG, validate_ARG)
 
 xx(formats,
    "List available metadata formats",
tools/dumpconfig.c +77 -3

91 lines not on this page · raw message

tools/tools.h +1 -0
index a3ad9fd..673e40b 100644
@@ -29,6 +29,7 @@
 #include "archiver.h"
 #include "lvmcache.h"
 #include "lvmetad.h"
+#include "lvm-version.h"
 #include "config.h"
 #include "defaults.h"
 #include "dev-cache.h"