From c582fe48d920f8d0d8bf8afdaa1a014f03ab7c8a Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Tue, 1 Oct 2019 16:57:49 +0200 Subject: [PATCH] sar/sadf: Add timezone value in binary data file Signed-off-by: Sebastien GODARD --- sa.h | 5 +++++ sadc.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/sa.h b/sa.h index df46db1..3c3a0c7 100644 --- a/sa.h +++ b/sa.h @@ -259,6 +259,7 @@ #define DEF_TMEND "18:00:00" #define UTSNAME_LEN 65 +#define TZNAME_LEN 8 #define HEADER_LINE_LEN 512 /* @@ -584,6 +585,10 @@ struct file_header { * Machine architecture. */ char sa_machine[UTSNAME_LEN]; + /* + * Timezone value. + */ + char sa_tzname[TZNAME_LEN]; }; #define FILE_HEADER_SIZE (sizeof(struct file_header)) diff --git a/sadc.c b/sadc.c index 022af00..22e259c 100644 --- a/sadc.c +++ b/sadc.c @@ -59,6 +59,8 @@ char *sccsid(void) { return (SCCSID); } extern time_t __unix_time; #endif +extern char *tzname[2]; + long interval = 0; uint64_t flags = 0; @@ -518,6 +520,11 @@ void setup_file_hdr(int fd) strncpy(file_hdr.sa_machine, header.machine, UTSNAME_LEN); file_hdr.sa_machine[UTSNAME_LEN - 1] = '\0'; + /* Get timezone value and save it */ + tzset(); + strncpy(file_hdr.sa_tzname, tzname[0], TZNAME_LEN); + file_hdr.sa_tzname[TZNAME_LEN - 1] = '\0'; + /* Write file header */ if (write_all(fd, &file_hdr, FILE_HEADER_SIZE) != FILE_HEADER_SIZE) { p_write_error(); -- 2.40.0