summaryrefslogtreecommitdiff
path: root/libdm/libdm-report.c
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2015-08-13 22:30:39 +0100
committerAlasdair G Kergon <agk@redhat.com>2015-08-13 22:30:39 +0100
commit043fb32c4b67d1456a77ab7caf0d077f419fae88 (patch)
tree21b752686448ae51c0b71fafc15b91aa3a918ba4 /libdm/libdm-report.c
parentb3cd5d294503fcfa4b826456e17071a909d739e1 (diff)
downloadlvm2-043fb32c4b67d1456a77ab7caf0d077f419fae88.tar.gz
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).
Diffstat (limited to 'libdm/libdm-report.c')
-rw-r--r--libdm/libdm-report.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 17a7e13b2..84b129449 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -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))