Blame SOURCES/quota-4.06-quotaio_xfs-Warn-when-large-kernel-timestamps-cannot.patch

97c04e
From 43b6e31f39edbe7de4f4feeef4d0cf6be093e021 Mon Sep 17 00:00:00 2001
97c04e
From: Jan Kara <jack@suse.cz>
97c04e
Date: Mon, 23 Nov 2020 17:12:27 +0100
97c04e
Subject: [PATCH] quotaio_xfs: Warn when large kernel timestamps cannot be
97c04e
 handled
97c04e
MIME-Version: 1.0
97c04e
Content-Type: text/plain; charset=UTF-8
97c04e
Content-Transfer-Encoding: 8bit
97c04e
97c04e
When time_t is 32-bit, warn if the kernel returns anything that cannot
97c04e
fit in these time stamps. This also fixes a compilation warning that
97c04e
shift exceeds data type size. Similarly when converting data to pass to
97c04e
kernel, just avoid the pointless shift (generating compiler warning)
97c04e
when time_t is 32-bit.
97c04e
97c04e
Reported-by: "Dmitry V. Levin" <ldv@altlinux.org>
97c04e
Signed-off-by: Jan Kara <jack@suse.cz>
97c04e
Signed-off-by: Petr Písař <ppisar@redhat.com>
97c04e
---
97c04e
 configure.ac  | 2 ++
97c04e
 quotaio_xfs.c | 9 +++++++++
97c04e
 2 files changed, 11 insertions(+)
97c04e
97c04e
diff --git a/configure.ac b/configure.ac
97c04e
index 2239b49..296b77a 100644
97c04e
--- a/configure.ac
97c04e
+++ b/configure.ac
97c04e
@@ -82,6 +82,8 @@ AS_IF([test x"$enable_werror" != "xno"], [
97c04e
 ])
97c04e
 AC_SUBST([WARN_CFLAGS])
97c04e
 
97c04e
+AC_CHECK_SIZEOF([time_t], [], [#include <time.h>])
97c04e
+
97c04e
 # =========
97c04e
 # Find ldap
97c04e
 # =========
97c04e
diff --git a/quotaio_xfs.c b/quotaio_xfs.c
97c04e
index 2db1c0c..5abb2c2 100644
97c04e
--- a/quotaio_xfs.c
97c04e
+++ b/quotaio_xfs.c
97c04e
@@ -45,8 +45,13 @@ report:		xfs_report
97c04e
 static inline time_t xfs_kern2utildqblk_ts(const struct xfs_kern_dqblk *k,
97c04e
 		__s32 timer, __s8 timer_hi)
97c04e
 {
97c04e
+#if SIZEOF_TIME_T > 4
97c04e
 	if (k->d_fieldmask & FS_DQ_BIGTIME)
97c04e
 		return (__u32)timer | (__s64)timer_hi << 32;
97c04e
+#else
97c04e
+	if (k->d_fieldmask & FS_DQ_BIGTIME && timer_hi != 0)
97c04e
+		errstr(_("Truncating kernel returned time stamp."));
97c04e
+#endif
97c04e
 	return timer;
97c04e
 }
97c04e
 
97c04e
@@ -54,10 +59,14 @@ static inline void xfs_util2kerndqblk_ts(const struct xfs_kern_dqblk *k,
97c04e
 		__s32 *timer_lo, __s8 *timer_hi, time_t timer)
97c04e
 {
97c04e
 	*timer_lo = timer;
97c04e
+#if SIZEOF_TIME_T > 4
97c04e
 	if (k->d_fieldmask & FS_DQ_BIGTIME)
97c04e
 		*timer_hi = timer >> 32;
97c04e
 	else
97c04e
 		*timer_hi = 0;
97c04e
+#else
97c04e
+	*timer_hi = 0;
97c04e
+#endif
97c04e
 }
97c04e
 
97c04e
 static inline int want_bigtime(time_t timer)
97c04e
-- 
97c04e
2.26.2
97c04e