summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2020-11-23 17:12:27 +0100
committerJan Kara <jack@suse.cz>2020-11-24 11:23:43 +0100
commit43b6e31f39edbe7de4f4feeef4d0cf6be093e021 (patch)
treee700217173014fbaa8729c2ed7c0c2634919ad8a
parent8a3321627bb9215ed40f8f7036a1e86bcaf10ad1 (diff)
downloadlinuxquota-43b6e31f39edbe7de4f4feeef4d0cf6be093e021.tar.gz
quotaio_xfs: Warn when large kernel timestamps cannot be handled
When time_t is 32-bit, warn if the kernel returns anything that cannot fit in these time stamps. This also fixes a compilation warning that shift exceeds data type size. Similarly when converting data to pass to kernel, just avoid the pointless shift (generating compiler warning) when time_t is 32-bit. Reported-by: "Dmitry V. Levin" <ldv@altlinux.org> Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--configure.ac2
-rw-r--r--quotaio_xfs.c9
2 files changed, 11 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 2239b49..296b77a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,6 +82,8 @@ AS_IF([test x"$enable_werror" != "xno"], [
])
AC_SUBST([WARN_CFLAGS])
+AC_CHECK_SIZEOF([time_t], [], [#include <time.h>])
+
# =========
# Find ldap
# =========
diff --git a/quotaio_xfs.c b/quotaio_xfs.c
index 2db1c0c..5abb2c2 100644
--- a/quotaio_xfs.c
+++ b/quotaio_xfs.c
@@ -45,8 +45,13 @@ report: xfs_report
static inline time_t xfs_kern2utildqblk_ts(const struct xfs_kern_dqblk *k,
__s32 timer, __s8 timer_hi)
{
+#if SIZEOF_TIME_T > 4
if (k->d_fieldmask & FS_DQ_BIGTIME)
return (__u32)timer | (__s64)timer_hi << 32;
+#else
+ if (k->d_fieldmask & FS_DQ_BIGTIME && timer_hi != 0)
+ errstr(_("Truncating kernel returned time stamp."));
+#endif
return timer;
}
@@ -54,10 +59,14 @@ static inline void xfs_util2kerndqblk_ts(const struct xfs_kern_dqblk *k,
__s32 *timer_lo, __s8 *timer_hi, time_t timer)
{
*timer_lo = timer;
+#if SIZEOF_TIME_T > 4
if (k->d_fieldmask & FS_DQ_BIGTIME)
*timer_hi = timer >> 32;
else
*timer_hi = 0;
+#else
+ *timer_hi = 0;
+#endif
}
static inline int want_bigtime(time_t timer)