Skip to contentSkip to conversation

master - report: select: add DM_REPORT_FIELD_TYPE_SIZE to make a difference between NUMBER and SIZE

PATCH Peter Rajnoha 1 participant 1 message Jun 17, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7dbbc05a69c4cb9756464720cad29e3c1ed971c3
Commit:        7dbbc05a69c4cb9756464720cad29e3c1ed971c3
Parent:        378fa9d1585941a8492830d866377e5f29dff29c
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Thu May 29 09:37:22 2014 +0200
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Tue Jun 17 16:27:20 2014 +0200

report: select: add DM_REPORT_FIELD_TYPE_SIZE to make a difference between NUMBER and SIZE

This makes it easier to check against the fields (following patches for report selection) and check whether size units are allowed or not with the field value.

---
 lib/properties/prop_common.h |    1 +
 lib/report/columns.h         |   48 +++++++++++++++++++++---------------------
 lib/report/properties.c      |    2 +
 lib/report/report.c          |    2 +
 libdm/libdevmapper.h         |    1 +
 libdm/libdm-report.c         |    6 +++-
 tools/dmsetup.c              |    2 +
 7 files changed, 36 insertions(+), 26 deletions(-)
lib/properties/prop_common.h +1 -0
index 6c89ad6..d6a0bb7 100644
@@ -122,6 +122,7 @@ static int _ ## NAME ## _get (const void *obj, struct lvm_property_type *prop) \
 
 #define STR 1
 #define NUM 2
+#define SIZ 3
 
 #define FIELD_MODIFIABLE 0x00000001
 #define FIELD(type, strct, field_type, head, field, width, fn, id, desc, settable) \
lib/report/columns.h +24 -24

96 lines not on this page · raw message

lib/report/properties.c +2 -0
index c6ccb72..876a408 100644
@@ -334,6 +334,7 @@ GET_PVSEG_NUM_PROPERTY_FN(pvseg_start, pvseg->pe)
 GET_PVSEG_NUM_PROPERTY_FN(pvseg_size, (SECTOR_SIZE * pvseg->len))
 #define _pvseg_size_set prop_not_implemented_set
 
+
 struct lvm_property_type _properties[] = {
 #include "columns.h"
 	{ 0, "", 0, 0, 0, { .integer = 0 }, prop_not_implemented_get, prop_not_implemented_set },
@@ -341,6 +342,7 @@ struct lvm_property_type _properties[] = {
 
 #undef STR
 #undef NUM
+#undef SIZ
 #undef FIELD
 
 int lvseg_get_property(const struct lv_segment *lvseg,
lib/report/report.c +2 -0
index 6b32bee..2f340ed 100644
@@ -1202,6 +1202,7 @@ static const struct dm_report_object_type _devtypes_report_types[] = {
 
 #define STR DM_REPORT_FIELD_TYPE_STRING
 #define NUM DM_REPORT_FIELD_TYPE_NUMBER
+#define SIZ DM_REPORT_FIELD_TYPE_SIZE
 #define FIELD(type, strct, sorttype, head, field, width, func, id, desc, writeable) \
 	{type, sorttype, offsetof(type_ ## strct, field), width, \
 	 #id, head, &_ ## func ## _disp, desc},
@@ -1227,6 +1228,7 @@ static const struct dm_report_field_type _devtypes_fields[] = {
 
 #undef STR
 #undef NUM
+#undef SIZ
 #undef FIELD
 
 void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
libdm/libdevmapper.h +1 -0
index 386ef07..3a51e14 100644
@@ -1597,6 +1597,7 @@ struct dm_report_field;
 #define DM_REPORT_FIELD_TYPE_MASK	0x000000F0
 #define DM_REPORT_FIELD_TYPE_STRING	0x00000010
 #define DM_REPORT_FIELD_TYPE_NUMBER	0x00000020
+#define DM_REPORT_FIELD_TYPE_SIZE	0x00000040
 
 #define DM_REPORT_FIELD_TYPE_ID_LEN 32
 #define DM_REPORT_FIELD_TYPE_HEADING_LEN 32
libdm/libdm-report.c +4 -2
index bdc293b..e0c6b1d 100644
@@ -862,7 +862,8 @@ static int _row_compare(const void *a, const void *b)
 	for (cnt = 0; cnt < rowa->rh->keys_count; cnt++) {
 		sfa = (*rowa->sort_fields)[cnt];
 		sfb = (*rowb->sort_fields)[cnt];
-		if (sfa->props->flags & DM_REPORT_FIELD_TYPE_NUMBER) {
+		if ((sfa->props->flags & DM_REPORT_FIELD_TYPE_NUMBER) ||
+		    (sfa->props->flags & DM_REPORT_FIELD_TYPE_SIZE)) {
 			const uint64_t numa =
 			    *(const uint64_t *) sfa->sort_value;
 			const uint64_t numb =
@@ -972,7 +973,8 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
 		}
 	} else {
 		if (!(align = field->props->flags & DM_REPORT_FIELD_ALIGN_MASK))
-			align = (field->props->flags & DM_REPORT_FIELD_TYPE_NUMBER) ? 
+			align = ((field->props->flags & DM_REPORT_FIELD_TYPE_NUMBER) ||
+				 (field->props->flags & DM_REPORT_FIELD_TYPE_SIZE)) ? 
 				DM_REPORT_FIELD_ALIGN_RIGHT : DM_REPORT_FIELD_ALIGN_LEFT;
 
 		/* Including trailing '\0'! */
tools/dmsetup.c +2 -0
index f84d1a8..fd87d42 100644
@@ -2786,6 +2786,7 @@ static const struct dm_report_object_type _report_types[] = {
 #define OFFSET_OF(strct, field) (((char*)&((struct strct*)0)->field) - (char*)0)
 #define STR (DM_REPORT_FIELD_TYPE_STRING)
 #define NUM (DM_REPORT_FIELD_TYPE_NUMBER)
+#define SIZ (DM_REPORT_FIELD_TYPE_SIZE)
 #define FIELD_O(type, strct, sorttype, head, field, width, func, id, desc) {DR_ ## type, sorttype, OFFSET_OF(strct, field), width, id, head, &_ ## func ## _disp, desc},
 #define FIELD_F(type, sorttype, head, width, func, id, desc) {DR_ ## type, sorttype, 0, width, id, head, &_ ## func ## _disp, desc},
 
@@ -2833,6 +2834,7 @@ FIELD_O(NAME, dm_split_name, STR, "LVLayer", lv_layer, 7, dm_lv_layer_name, "lv_
 
 #undef STR
 #undef NUM
+#undef SIZ
 #undef FIELD_O
 #undef FIELD_F