From: Sebastien GODARD Date: Fri, 5 Feb 2016 08:02:09 +0000 (+0100) Subject: Add new flag to read_next_sample() function X-Git-Tag: v11.3.1~17^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f603e8e76e34c6ab29fd0ea32ed8ecdec1b7e35;p=sysstat Add new flag to read_next_sample() function read_next_sample() function didn't fill the timestamp for special records (COMMENT or RESTART ones) that had to be ignored. So add a new flag (SET_TIMESTAMPS) to tell read_next_sample() function to set the timestamps for special records when this is needed. Signed-off-by: Sebastien GODARD --- diff --git a/sadf.c b/sadf.c index e0fa3ca..54e0541 100644 --- a/sadf.c +++ b/sadf.c @@ -239,16 +239,16 @@ void xprintf(int nr_tab, const char *fmtf, ...) /* *************************************************************************** - * Read next sample statistics. If it's a special record (RESTART or COMMENT) - * then display it if requested. Also fill timestamps structures. + * Read next sample statistics. If it's a special record (R_RESTART or + * R_COMMENT) then display it if requested. Also fill timestamps structures. * * IN: * @ifd File descriptor - * @action Flags indicating if special records should be displayed or not. + * @action Flags indicating if special records should be displayed or + * not. * * @curr Index in array for current sample statistics. * @file System activity data file name (name of file being read). - * @rtype Record type (RESTART, COMMENT, etc.) * @tab Number of tabulations to print. * @file_actlst List of (known or unknown) activities in file. * @file_magic System activity file magic header. @@ -259,11 +259,17 @@ void xprintf(int nr_tab, const char *fmtf, ...) * saved for current record. * * OUT: - * @rectime Structure where timestamp (expressed in local time or in UTC - * depending on whether options -T/-t have been used or not) has - * been saved for current record. - * @loctime Structure where timestamp (expressed in local time) has been - * saved for current record. + * @rtype Type of record read (R_RESTART, R_COMMENT, etc.) + * @rectime Structure where timestamp (expressed in local time or in UTC + * depending on options used) has been saved for current record. + * If current record was a special one (RESTART or COMMENT) and + * noted to be ignored, then the timestamp is saved only if + * explicitly told to do so with the SET_TIMESTAMPS action flag. + * @loctime Structure where timestamp (expressed in local time) has been + * saved for current record. + * If current record was a special one (RESTART or COMMENT) and + * noted to be ignored, then the timestamp is saved only if + * explicitly told to do so with the SET_TIMESTAMPS action flag. * * RETURNS: * TRUE if end of file has been reached. @@ -286,6 +292,10 @@ int read_next_sample(int ifd, int action, int curr, char *file, int *rtype, int if (lseek(ifd, MAX_COMMENT_LEN, SEEK_CUR) < MAX_COMMENT_LEN) { perror("lseek"); } + if (action & SET_TIMESTAMPS) { + sa_get_record_timestamp_struct(flags, &record_hdr[curr], + rectime, loctime); + } } else { /* Display COMMENT record */ @@ -306,6 +316,10 @@ int read_next_sample(int ifd, int action, int curr, char *file, int *rtype, int read_vol_act_structures(ifd, act, file, file_magic, file_hdr.sa_vol_act_nr); } + if (action & SET_TIMESTAMPS) { + sa_get_record_timestamp_struct(flags, &record_hdr[curr], + rectime, loctime); + } } else { /* Display RESTART record */ diff --git a/sadf.h b/sadf.h index b94ac09..1c69fa2 100644 --- a/sadf.h +++ b/sadf.h @@ -19,6 +19,7 @@ #define IGNORE_RESTART 1 #define DONT_READ_VOLATILE 2 #define IGNORE_COMMENT 4 +#define SET_TIMESTAMPS 8 /* ***************************************************************************