diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2015-06-24 13:14:30 +0200 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2015-06-24 13:19:23 +0200 |
commit | a4724350e4909dd1b74231f22c41434dbe02c14d (patch) | |
tree | e1477a984b9550e6f42e42ffbddd8d8a67133cb6 | |
parent | a25d92c88b034996667da3764ac5b1de15448174 (diff) | |
download | lvm2-a4724350e4909dd1b74231f22c41434dbe02c14d.tar.gz |
lvmconfig: add --withspaces option
We shouldn't be adding spaces by default in output as that
may be be used already in scripts and especially for the eval
in shell scripts where spaces are not allowed between key
and value!
Add --withspaces option to lvmconfig for pretty output with
more space in for readability.
-rw-r--r-- | WHATS_NEW | 1 | ||||
-rw-r--r-- | lib/config/config.c | 8 | ||||
-rw-r--r-- | lib/config/config.h | 1 | ||||
-rw-r--r-- | man/lvmconfig.8.in | 5 | ||||
-rw-r--r-- | tools/args.h | 1 | ||||
-rw-r--r-- | tools/commands.h | 3 | ||||
-rw-r--r-- | tools/dumpconfig.c | 3 |
7 files changed, 18 insertions, 4 deletions
@@ -1,5 +1,6 @@ Version 2.02.123 - ================================= + Add --withspaces to lvmconfig to add spaces in output for better readability. Version 2.02.122 - 20th June 2015 ================================= diff --git a/lib/config/config.c b/lib/config/config.c index 6f9d413db..22b8f09a2 100644 --- a/lib/config/config.c +++ b/lib/config/config.c @@ -1756,7 +1756,8 @@ static struct dm_config_node *_add_def_node(struct dm_config_tree *cft, log_error("Failed to create default config setting node value."); return NULL; } - format_flags |= DM_CONFIG_VALUE_FMT_COMMON_EXTRA_SPACES; + if (spec->withspaces) + format_flags |= DM_CONFIG_VALUE_FMT_COMMON_EXTRA_SPACES; } cn->id = def->id; @@ -1799,8 +1800,9 @@ static struct dm_config_node *_add_def_node(struct dm_config_tree *cft, } dm_config_value_set_format_flags(cn->v, format_flags); } else { - format_flags |= (DM_CONFIG_VALUE_FMT_COMMON_ARRAY | - DM_CONFIG_VALUE_FMT_COMMON_EXTRA_SPACES); + if (spec->withspaces) + format_flags |= DM_CONFIG_VALUE_FMT_COMMON_EXTRA_SPACES; + format_flags |= DM_CONFIG_VALUE_FMT_COMMON_ARRAY; cn->v = _get_def_array_values(cft, def, format_flags); } diff --git a/lib/config/config.h b/lib/config/config.h index b03ad6bde..9601dc189 100644 --- a/lib/config/config.h +++ b/lib/config/config.h @@ -163,6 +163,7 @@ struct config_def_tree_spec { unsigned withsummary:1; /* include first line of comments - a summary */ unsigned withcomments:1; /* include all comment lines */ unsigned withversions:1; /* include versions */ + unsigned withspaces:1; /* add more spaces in output for better readability */ unsigned unconfigured:1; /* use unconfigured path strings */ uint8_t *check_status; /* status of last tree check (currently needed for CFG_DEF_TREE_MISSING only) */ }; diff --git a/man/lvmconfig.8.in b/man/lvmconfig.8.in index 4e6128098..761b1e922 100644 --- a/man/lvmconfig.8.in +++ b/man/lvmconfig.8.in @@ -27,6 +27,7 @@ lvmconfig, lvm dumpconfig, lvm config \(em Display LVM configuration .RB [ \-\-validate ] .RB [ \-\-withsummary ] .RB [ \-\-withcomments ] +.RB [ \-\-withspaces ] .RB [ \-\-withversions ] .RB [ ConfigurationNode... ] @@ -186,6 +187,10 @@ Display a full comment for each configuration node. For deprecated settings, also display comments about deprecation in addition. .TP +.B \-\-withspaces +Where appropriate, add more spaces in output for better readability. + +.TP .B \-\-withversions Also display a comment containing the version of introduction for each configuration node. If the setting is deprecated, also display diff --git a/tools/args.h b/tools/args.h index b5c4243d4..7f7667da2 100644 --- a/tools/args.h +++ b/tools/args.h @@ -124,6 +124,7 @@ arg(vgmetadatacopies_ARG, '\0', "vgmetadatacopies", metadatacopies_arg, 0) arg(virtualoriginsize_ARG, '\0', "virtualoriginsize", size_mb_arg, 0) arg(withsummary_ARG, '\0', "withsummary", NULL, 0) arg(withcomments_ARG, '\0', "withcomments", NULL, 0) +arg(withspaces_ARG, '\0', "withspaces", NULL, 0) arg(withversions_ARG, '\0', "withversions", NULL, 0) arg(writebehind_ARG, '\0', "writebehind", int_arg, 0) arg(writemostly_ARG, '\0', "writemostly", string_arg, ARG_GROUPABLE) diff --git a/tools/commands.h b/tools/commands.h index 8e87681ea..9403951e8 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -104,13 +104,14 @@ xx(dumpconfig, "\t[--validate]\n" "\t[--withsummary]\n" "\t[--withcomments]\n" + "\t[--withspaces]\n" "\t[--unconfigured]\n" "\t[--withversions]\n" "\t[ConfigurationNode...]\n", atversion_ARG, configtype_ARG, file_ARG, ignoreadvanced_ARG, ignoreunsupported_ARG, ignorelocal_ARG, list_ARG, mergedconfig_ARG, metadataprofile_ARG, showdeprecated_ARG, showunsupported_ARG, validate_ARG, withsummary_ARG, withcomments_ARG, - unconfigured_ARG, withversions_ARG) + withspaces_ARG, unconfigured_ARG, withversions_ARG) xx(formats, "List available metadata formats", diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c index 97de57abd..f6a62172e 100644 --- a/tools/dumpconfig.c +++ b/tools/dumpconfig.c @@ -277,6 +277,9 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv) if (arg_count(cmd, withversions_ARG)) tree_spec.withversions = 1; + if (arg_count(cmd, withspaces_ARG)) + tree_spec.withspaces = 1; + if (cft_check_handle) tree_spec.check_status = cft_check_handle->status; |