device-mapper ./WHATS_NEW dmsetup/dmsetup.c li ...
Subsystems (2)
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: [email protected] 2007-01-18 17:47:59
Modified files:
. : WHATS_NEW dmsetup : dmsetup.c lib : libdevmapper.h libdm-report.c
Log message:
Some internal renaming.
Add --separator and --sort to dmsetup (unused as yet). Make alignment flag optional when specifying report fields.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.151&r2=1.152
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.76&r2=1.77
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdevmapper.h.diff?cvsroot=dm&r1=1.64&r2=1.65
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-report.c.diff?cvsroot=dm&r1=1.2&r2=1.3
WHATS_NEW +3 -0
@@ -1,5 +1,8 @@ Version 1.02.16 - =================================== + Add --separator and --sort to dmsetup (unused). + Make alignment flag optional when specifying report fields. + Version 1.02.15 - 17th January 2007 =================================== Add basic reporting functions to libdevmapper.
dmsetup/dmsetup.c +40 -28
188 lines not on this page · raw message
lib/libdevmapper.h +6 -4
@@ -646,11 +646,13 @@/* * dm_report_field_type flags */ -#define DM_REPORT_FIELD_MASK 0x0000000F +#define DM_REPORT_FIELD_MASK 0x000000FF +#define DM_REPORT_FIELD_ALIGN_MASK 0x0000000F#define DM_REPORT_FIELD_ALIGN_LEFT 0x00000001#define DM_REPORT_FIELD_ALIGN_RIGHT 0x00000002 -#define DM_REPORT_FIELD_STRING 0x00000004 -#define DM_REPORT_FIELD_NUMBER 0x00000008 +#define DM_REPORT_FIELD_TYPE_MASK 0x000000F0 +#define DM_REPORT_FIELD_TYPE_STRING 0x00000010 +#define DM_REPORT_FIELD_TYPE_NUMBER 0x00000020struct dm_report ;struct dm_report_field_type {
@@ -668,7 +670,7 @@/* * dm_report_init output_flags */ -#define DM_REPORT_OUTPUT_MASK 0x00000007 +#define DM_REPORT_OUTPUT_MASK 0x000000FF#define DM_REPORT_OUTPUT_ALIGNED 0x00000001#define DM_REPORT_OUTPUT_BUFFERED 0x00000002#define DM_REPORT_OUTPUT_HEADINGS 0x00000004
lib/libdm-report.c +20 -14
@@ -672,7 +672,7 @@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_NUMBER ) { +if (sfa->props->flags &DM_REPORT_FIELD_TYPE_NUMBER ) {const uint64_t numa = *(const uint64_t *) sfa->sort_value; const uint64_t numb =
@@ -686,7 +686,7 @@ }else {/* FLD_DESCENDING */ return (numa < numb) ?1 :-1 ; } - }else {/* DM_REPORT_FIELD_STRING */ + }else {/* DM_REPORT_FIELD_TYPE_STRING */ const char *stra = (const char *) sfa->sort_value;const char *strb = (const char *) sfb->sort_value;int cmp =strcmp (stra, strb);
@@ -740,6 +740,7 @@const char *repstr;char buf[4096 ];unsigned width; +uint32_t align;if (list_empty (&rh->rows))return 1 ;
@@ -771,18 +772,23 @@if (!dm_pool_grow_object (rh->mem, repstr,strlen (repstr))) goto bad_grow; - }else if (field->props->flags &DM_REPORT_FIELD_ALIGN_LEFT ) { -if (dm_snprintf (buf,sizeof (buf),"%-*.*s" , - width, width, repstr) <0 ) - goto bad_snprintf; -if (!dm_pool_grow_object (rh->mem, buf, width)) - goto bad_grow; - }else if (field->props->flags &DM_REPORT_FIELD_ALIGN_RIGHT ) { -if (dm_snprintf (buf,sizeof (buf),"%*.*s" , - width, width, repstr) <0 ) - goto bad_snprintf; -if (!dm_pool_grow_object (rh->mem, buf, width)) - goto bad_grow; + }else { +if (!(align = field->props->flags &DM_REPORT_FIELD_ALIGN_MASK )) + align = (field->props->flags &DM_REPORT_FIELD_TYPE_NUMBER ) ? +DM_REPORT_FIELD_ALIGN_RIGHT :DM_REPORT_FIELD_ALIGN_LEFT ; +if (align &DM_REPORT_FIELD_ALIGN_LEFT ) { +if (dm_snprintf (buf,sizeof (buf),"%-*.*s" , + width, width, repstr) <0 ) + goto bad_snprintf; +if (!dm_pool_grow_object (rh->mem, buf, width)) + goto bad_grow; + }else if (field->props->flags &DM_REPORT_FIELD_ALIGN_RIGHT ) { +if (dm_snprintf (buf,sizeof (buf),"%*.*s" , + width, width, repstr) <0 ) + goto bad_snprintf; +if (!dm_pool_grow_object (rh->mem, buf, width)) + goto bad_grow; + } }if (!list_end (&row->fields, fh))