Skip to contentSkip to conversation

master - libdm: report: add dm_report_object_is_selected

PATCH Peter Rajnoha 1 participant 1 message Feb 10, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=123a3383a021df737852892ff400f047b5ff609e
Commit:        123a3383a021df737852892ff400f047b5ff609e
Parent:        2ee3bcb877b081dd6281644d4c9c366dd08ad1c1
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Mon Nov 24 11:07:39 2014 +0100
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Tue Feb 10 16:04:38 2015 +0100

libdm: report: add dm_report_object_is_selected

The new dm_report_object_is_selected fn makes it possible to opt whether the object reported should be displayed on output or not. Also, in addition to that, it makes it possible to save the result of selection (either 0 or 1).

So dm_report_object_is_selected is simply more general form of object reporting fn - combinations now allow for:

dm_report_object_is_selected(rh, object, 1, NULL):
This is exactly the original dm_report_object fn and it's fully equal to it.

dm_report_object_is_selected(rh, object, 0, selected):
Do not display the result on output, but save info whether the object is selected or not in 'selected' variable.

dm_report_object_is_selected(rh, object, 1, selected):
Display the result on output (if it passes selection criteria) and save whether the object is selected or not in 'selected' variable.

dm_report_object(rh, object, 0, NULL):
This combination is not allowed - it will end up with internal error. We're either interested in selection status or we want to display the result on output or both, but never nothing of the two.

---
 WHATS_NEW_DM         |    1 +
 libdm/libdevmapper.h |   10 +++++++++
 libdm/libdm-report.c |   53 +++++++++++++++++++++++++++++++++----------------
 3 files changed, 47 insertions(+), 17 deletions(-)
WHATS_NEW_DM +1 -0
index 3fb69cb..183ef15 100644
@@ -1,5 +1,6 @@
 Version 1.02.94 - 
 ===================================
+  Add dm_report_object_is_selected for generalized interface for report/select.
 
 Version 1.02.93 - 21st January 2015
 ===================================
libdm/libdevmapper.h +10 -0
index b164b51..309e63f 100644
@@ -1761,7 +1761,17 @@ struct dm_report *dm_report_init_with_selection(uint32_t *report_types,
 						const char *selection,
 						const struct dm_report_reserved_value reserved_values[],
 						void *private_data);
+/*
+ * Report an object, pass it through the selection criteria if they
+ * are present and display the result on output if it passes the criteria.
+ */
 int dm_report_object(struct dm_report *rh, void *object);
+/*
+ * The same as dm_report_object, but display the result on output only if
+ * 'do_output' arg is set. Also, save the result of selection in 'selected'
+ * arg if it's not NULL (either 1 if the object passes, otherwise 0).
+ */
+int dm_report_object_is_selected(struct dm_report *rh, void *object, int do_output, int *selected);
 
 /*
  * Compact report output so that if field value is empty for all rows in
libdm/libdm-report.c +36 -17

131 lines not on this page · raw message