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

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