Skip to contentSkip to conversation

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

PATCH Peter Rajnoha 1 participant 1 message Jun 6, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=026b9eefe76fe581b6e256b8aebea8742b0da103
Commit:        026b9eefe76fe581b6e256b8aebea8742b0da103
Parent:        f115a4a53fe6c3a3121e200c7f8796fb086c0c6e
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Thu May 29 09:37:22 2014 +0200
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Fri Jun 6 11:11:19 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 681e80c..7a51c81 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 f3395a7..384648e 100644
@@ -858,7 +858,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 =
@@ -968,7 +969,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