master - report: select: add handler to recognize fuzzy time specification
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9cee94372a7e45b6a40478ec17de1c142ed268d4 Commit: 9cee94372a7e45b6a40478ec17de1c142ed268d4 Parent: 3b1422c45c6c782f5134e74439ccdd6766085d4c Author: Peter Rajnoha <[email protected]> AuthorDate: Fri Jul 3 10:43:07 2015 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Fri Jul 3 10:51:31 2015 +0200
report: select: add handler to recognize fuzzy time specification
Recognize date and time specification within selection criteria that is formulated in a more free-form way besides to the original basic YYYY-MM-DD HH:MM format that libdevmapper supports.
Currently, this free-form format is recognized for lv_time field.
Users are able to use expressions from this set:
- weekday names ("Sunday" - "Saturday" or abbreviated as "Sun" - "Sat")
- labels for points in time ("noon", "midnight")
- labels for a day relative to current day ("today", "yesterday")
- points back in time with relative offset from today (N is a number)
( "N" "seconds"/"minutes"/"hours"/"days"/"weeks"/"years" "ago")
( "N" "secs"/"mins"/"hrs" ... "ago")
( "N" "s"/"m"/"h" ... "ago") - time specification either in hh:mm:ss format or with AM/PM suffixes
- month names ("January" - "December" or abbreviated as "Jan" - "Dec")
For example:
$ date Fri Jul 3 10:11:13 CEST 2015
$ lvmconfig --type full report/time_format time_format="%a %Y-%m-%d %T %z %Z [%s]"
$ lvs LV VG Time lvol0 vg Fri 2014-08-22 21:25:41 +0200 CEST [1408735541] lvol2 vg Sun 2015-04-26 14:52:20 +0200 CEST [1430052740] root fedora Wed 2015-05-27 08:09:21 +0200 CEST [1432706961] swap fedora Wed 2015-05-27 08:09:21 +0200 CEST [1432706961] lvol1 vg Tue 2015-06-30 03:25:43 +0200 CEST [1435627543] lvol3 vg Tue 2015-06-30 14:52:23 +0200 CEST [1435668743] lvol6 vg Wed 2015-07-01 13:35:56 +0200 CEST [1435750556] lvol4 vg Thu 2015-07-02 12:12:02 +0200 CEST [1435831922] lvol5 vg Thu 2015-07-02 14:30:32 +0200 CEST [1435840232]
$ lvs -S 'time=yesterday' LV VG Time lvol4 vg Thu 2015-07-02 12:12:02 +0200 CEST [1435831922] lvol5 vg Thu 2015-07-02 14:30:32 +0200 CEST [1435840232]
$ lvs -S 'time since "June 30"' LV VG Time lvol1 vg Tue 2015-06-30 03:25:43 +0200 CEST [1435627543] lvol3 vg Tue 2015-06-30 14:52:23 +0200 CEST [1435668743] lvol6 vg Wed 2015-07-01 13:35:56 +0200 CEST [1435750556] lvol4 vg Thu 2015-07-02 12:12:02 +0200 CEST [1435831922] lvol5 vg Thu 2015-07-02 14:30:32 +0200 CEST [1435840232]
$ lvs -S 'time since "noon June 30"' LV VG Time lvol3 vg Tue 2015-06-30 14:52:23 +0200 CEST [1435668743] lvol6 vg Wed 2015-07-01 13:35:56 +0200 CEST [1435750556] lvol4 vg Thu 2015-07-02 12:12:02 +0200 CEST [1435831922] lvol5 vg Thu 2015-07-02 14:30:32 +0200 CEST [1435840232]
$ lvs -S 'time since "2 July 9AM"' LV VG Time lvol4 vg Thu 2015-07-02 12:12:02 +0200 CEST [1435831922] lvol5 vg Thu 2015-07-02 14:30:32 +0200 CEST [1435840232]
$ lvs -S 'time since "2 July 1PM"' LV VG Time lvol5 vg Thu 2015-07-02 14:30:32 +0200 CEST [1435840232]
...and so on.
--- WHATS_NEW | 1 + lib/report/report.c | 1034 ++++++++++++++++++++++++++++++++++++++++++++++++++ lib/report/values.h | 1 + libdm/libdm-report.c | 6 +- 4 files changed, 1040 insertions(+), 2 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.124 - ================================= + Recognize free-form date/time values for lv_time field in selection criteria. Fix regression in select to match string fields if using synonyms (2.02.123). Fix regression when printing more lv names via display_lvname (2.02.122). Add missing error logging to unlock_vg and sync_local_dev_names callers.
lib/report/report.c +1034 -0
1,046 lines not on this page · raw message
lib/report/values.h +1 -0
@@ -87,6 +87,7 @@ FIELD_RESERVED_VALUE(NOFLAG, lv_read_ahead, lv_read_ahead_auto, "", &_siz_max, " FIELD_RESERVED_VALUE(NAMED, lv_when_full, lv_when_full_error, "", "error", "error", "error when full", "error if no space") FIELD_RESERVED_VALUE(NAMED, lv_when_full, lv_when_full_queue, "", "queue", "queue", "queue when full", "queue if no space") FIELD_RESERVED_VALUE(NOFLAG, lv_when_full, lv_when_full_undef, "", "", "", "undefined") +FIELD_RESERVED_VALUE (NAMED |RANGE |FUZZY |DYNAMIC , lv_time, lv_time_fuzzy,"" , lv_time_handler,NULL ) /* Reserved values for SEG fields */FIELD_RESERVED_VALUE (NOFLAG , cache_policy, cache_policy_undef,"" ,"" ,"" ,"undefined" )
libdm/libdm-report.c +4 -2
@@ -2273,11 +2273,13 @@ static int _check_reserved_values_supported(const struct dm_report_field_type fistatic uint32_t supported_reserved_types =DM_REPORT_FIELD_TYPE_NUMBER |DM_REPORT_FIELD_TYPE_SIZE |DM_REPORT_FIELD_TYPE_PERCENT | -DM_REPORT_FIELD_TYPE_STRING ; +DM_REPORT_FIELD_TYPE_STRING | +DM_REPORT_FIELD_TYPE_TIME ;static uint32_t supported_reserved_types_with_range =DM_REPORT_FIELD_RESERVED_VALUE_RANGE |DM_REPORT_FIELD_TYPE_NUMBER |DM_REPORT_FIELD_TYPE_SIZE | -DM_REPORT_FIELD_TYPE_PERCENT ; +DM_REPORT_FIELD_TYPE_PERCENT | +DM_REPORT_FIELD_TYPE_TIME ;if (!reserved_values)