master - report: adapt selection code to recognize per-field reserved values
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0956fd230fea550707acb2889223438996102de4 Commit: 0956fd230fea550707acb2889223438996102de4 Parent: da545ce3b471e76b3ebcfcb5528118d8dd9264df Author: Peter Rajnoha <[email protected]> AuthorDate: Fri Jul 4 11:21:38 2014 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Fri Jul 4 15:50:50 2014 +0200
report: adapt selection code to recognize per-field reserved values
In contrast to per-type reserved values that are applied for all fields of that type, per-field reserved values are only applied for concrete field only.
Also add 'struct dm_report_field_reserved_value' to libdm for per-field reserved value definition. This is defined by field number (an index in the 'fields' array which is given for the dm_report_init_with_selection function during report initialization) and the value to use for any of the specified reserved names.
--- libdm/libdevmapper.h | 27 ++++++++++++ libdm/libdm-report.c | 112 +++++++++++++++++++++++++++++++++----------------- 2 files changed, 101 insertions(+), 38 deletions(-)
libdm/libdevmapper.h +27 -0
@@ -1633,6 +1633,7 @@ struct dm_report_field;#define DM_REPORT_FIELD_ALIGN_LEFT 0x00000001#define DM_REPORT_FIELD_ALIGN_RIGHT 0x00000002#define DM_REPORT_FIELD_TYPE_MASK 0x00000FF0 +#define DM_REPORT_FIELD_TYPE_NONE 0x00000000#define DM_REPORT_FIELD_TYPE_STRING 0x00000010#define DM_REPORT_FIELD_TYPE_NUMBER 0x00000020#define DM_REPORT_FIELD_TYPE_SIZE 0x00000040
@@ -1658,9 +1659,35 @@ struct dm_report_field_type {const char *desc;/* description of the field */ }; +/* +* Per-field reserved value. +*/ +struct dm_report_field_reserved_value { +/* field_num is the position of the field in 'fields' +array passed to dm_report_init_with_selection */ +uint32_t field_num; +/* the value is of the same type as the field +identified by field_num */ +const void *value; +}; + +/* +* Reserved value is a 'value' that is used directly if any of the 'names' is hit. +* +* If type is any of DM_REPORT_FIELD_TYPE_*, the reserved value is recognized +* for all fields of that type. +* +* If type is DM_REPORT_FIELD_TYPE_NONE, the reserved value is recognized +* for the exact field specified - hence the type of the value is automatically +* the same as the type of the field itself. +* +* The array of reserved values is used to initialize reporting with +* selection enabled (see also dm_report_init_with_selection function). +*/ struct dm_report_reserved_value {const unsigned type;/* DM_REPORT_FIELD_TYPE_* */ const void *value;/* reserved value: +struct dm_report_field_reserved_value for DM_REPORT_FIELD_TYPE_NONE uint64_t for DM_REPORT_FIELD_TYPE_NUMBER uint64_t for DM_REPORT_FIELD_TYPE_SIZE (number of 512-byte sectors) uint64_t for DM_REPORT_FIELD_TYPE_PERCENT
libdm/libdm-report.c +74 -38
192 lines not on this page · raw message