File 0008-LU-13665-lfs-use-correct-DST-setting-for-mktime.patch of Package lustre_2_15

From 9a54c409635a52f30a6894a5be16328819a0fbe6 Mon Sep 17 00:00:00 2001
From: Mr NeilBrown <neilb@suse.de>
Date: Tue, 22 Nov 2022 16:09:59 +1100
Subject: [PATCH 08/30] LU-13665 lfs: use correct DST setting for mktime()

When lfs is passed a "-newerXY" arg when Y=='t' and the arg doesn't
start %H, it leaves ->tm_isdst set to 0 which tells mktime() to assume
that DST is not active.
This means that it produces incorrect results for times when DST is
active.

We should set ->tm_isdst to -1 to tell mktime() that it is not known
whether DST is active.  Then mktime() will use the timezone database
to determine the correct DST setting.

This allows us to re-enable test 56oc on all platforms.

Test-Parameters: trivial clientdistro=sles15sp3 env=ONLY=56
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I94afba96e2563442786726096501c5ec0b40a881
---
 lustre/tests/sanity.sh | 3 ---
 lustre/utils/lfs.c     | 6 ++++--
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh
index c7a801552431..abf4570eac9d 100755
--- a/lustre/tests/sanity.sh
+++ b/lustre/tests/sanity.sh
@@ -6537,9 +6537,6 @@ test_56oc() {
 	test_newerXY_base "c" "m"
 	test_newerXY_base "c" "c"
 
-	[[ -n "$sles_version" ]] &&
-		echo "skip timestamp tests on SLES, LU-13665" && return 0
-
 	test_newerXY_base "a" "t"
 	test_newerXY_base "m" "t"
 	test_newerXY_base "c" "t"
diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c
index 7946d9e050a7..f8b7241e1eb1 100644
--- a/lustre/utils/lfs.c
+++ b/lustre/utils/lfs.c
@@ -5251,10 +5251,12 @@ static int lfs_find(int argc, char **argv)
 					char *ptr;
 
 					/* Init for times relative to today */
-					if (strncmp(fmts[i], "%H", 2) == 0)
+					if (strncmp(fmts[i], "%H", 2) == 0) {
 						localtime_r(&ref, &tm);
-					else
+					} else {
 						memset(&tm, 0, sizeof(tm));
+						tm.tm_isdst = -1;
+					}
 					ptr = strptime(optarg, fmts[i], &tm);
 					/* Skip spaces */
 					while (ptr && isspace(*ptr))
-- 
2.38.1

openSUSE Build Service is sponsored by