Skip to contentSkip to conversation

master - dmsetup: Restructure arg handling.

PATCH Alasdair Kergon 1 participant 1 message Aug 13, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=043fb32c4b67d1456a77ab7caf0d077f419fae88
Commit:        043fb32c4b67d1456a77ab7caf0d077f419fae88
Parent:        b3cd5d294503fcfa4b826456e17071a909d739e1
Author:        Alasdair G Kergon <[email protected]>
AuthorDate:    Thu Aug 13 22:30:39 2015 +0100
Committer:     Alasdair G Kergon <[email protected]>
CommitterDate: Thu Aug 13 22:30:39 2015 +0100

dmsetup: Restructure arg handling.

Introduce enums and global variables to record cleanly which command we are processing and eliminate the historically inconsistent use of the shifted argv[0] and fix assorted bugs discovered along the way.

Add dm_report_is_empty() to indicate there is no data awaiting output and use this to suppress dmsetup report headings when no data is output so we don't get a stray line saying 'Help' at the end of reporting help.

Define a report type (as the interface requires) so -o all selects the right fields in splitname. (A fix for stats list will follow.)

Exit immediately if no device is supplied to dmsetup wipe_table instead of hitting errors later and failing.

Adjust the command name printed in usage/help output to match command invoked (most of the time).

---
 WHATS_NEW_DM                        |    6 +
 libdm/.exported_symbols.DM_1_02_105 |    1 +
 libdm/libdevmapper.h                |    5 +
 libdm/libdm-report.c                |    5 +
 tools/dmsetup.c                     |  400 +++++++++++++++++++++--------------
 5 files changed, 256 insertions(+), 161 deletions(-)
WHATS_NEW_DM +6 -0
index 45db0e4..f3b62b1 100644
@@ -1,5 +1,11 @@
 Version 1.02.105 - 
 ===================================
+  Exit immediately if no device is supplied to dmsetup wipe_table.
+  Suppress dmsetup report headings when no data is output. (1.02.104)
+  Adjust dmsetup usage/help output selection to match command invoked.
+  Fix dmsetup -o all to select correct fields in splitname report.
+  Restructure internal dmsetup argument handling across all commands.
+  Add dm_report_is_empty() to indicate there is no data awaiting output.
   Add more arg validation for dm_tree_node_add_cache_target().
   Add --alldevices switch to replace use of --force for stats create / delete.
 
libdm/.exported_symbols.DM_1_02_105 new file +1 -0
new file mode 100644
index 0000000..9b701f1
@@ -0,0 +1 @@
+dm_report_is_empty
libdm/libdevmapper.h +5 -0
index 192fd0f..303ed67 100644
@@ -2396,6 +2396,11 @@ int dm_report_object_is_selected(struct dm_report *rh, void *object, int do_outp
  */
 int dm_report_compact_fields(struct dm_report *rh);
 
+/*
+ * Returns 1 if there is no data waiting to be output.
+ */
+int dm_report_is_empty(struct dm_report *rh);
+
 int dm_report_output(struct dm_report *rh);
 
 /*
libdm/libdm-report.c +5 -0
index 17a7e13..84b1294 100644
@@ -4305,6 +4305,11 @@ static int _output_as_columns(struct dm_report *rh)
 	return 0;
 }
 
+int dm_report_is_empty(struct dm_report *rh)
+{
+	return dm_list_empty(&rh->rows) ? 1 : 0;
+}
+
 int dm_report_output(struct dm_report *rh)
 {
 	if (dm_list_empty(&rh->rows))
tools/dmsetup.c +239 -161

914 lines not on this page · raw message