Skip to contentSkip to conversation

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

PATCH Peter Rajnoha 1 participant 1 message May 9, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=929a4515fe7aff7daa3a7521b0c98789c0c99a8f
Commit:        929a4515fe7aff7daa3a7521b0c98789c0c99a8f
Parent:        e416d84e1093655786b09450154779ee7896f11d
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Mon Apr 28 11:55:31 2014 +0200
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Fri May 9 08:51:00 2014 +0200

selout: add DM_REPORT_FIELD_TYPE_SIZE to make a difference between NUMBER and SIZE

---
 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 8ffa145..f5a1cc7 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 7e8484e..d71a8c7 100644
@@ -853,7 +853,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 =
@@ -963,7 +964,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 4433571..9131e67 100644
@@ -2778,6 +2778,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},
 
@@ -2825,6 +2826,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