The time_t type and the structure timeval were removed for use in kernel
space code in Linux commits:
412c53a680a97cb1ae2c0ab60230e193bee86387
y2038: remove unused time32 interfaces
c766d1472c70d25ad475cf56042af1652e792b23
y2038: hide timeval/timespec/itimerval/itimerspec types
Add an autoconf test for the time_t type.
If time_t is missing, define the time_t type when building the kernel
module.
Change the vattr structure in LINUX/osi_vfs.h to use timespec/timespec64
instead of the timeval structure.
Conditionalize the definition of gettimeofday (needed by rand-fortuna.c) in
crypto/hcrypto/kernel/config.h. It is unused by the Linux kernel module
and the function uses struct timeval that is no longer available.
Change-Id: Idc9a1ded748f833d804164d29c49c9aee26ae8f5
Reviewed-on: https://gerrit.openafs.org/14083
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
#include "h/cred.h"
#endif
+#if !defined(HAVE_LINUX_TIME_T)
+typedef time64_t time_t;
+#endif
+
#if defined(HAVE_LINUX_KTIME_GET_COARSE_REAL_TS64)
static inline time_t osi_Time(void) {
struct timespec64 xtime;
dev_t va_rdev;
ino_t va_nodeid; /* Inode number */
nlink_t va_nlink; /* link count for file. */
- struct timeval va_atime;
- struct timeval va_mtime;
- struct timeval va_ctime;
+#if defined(IATTR_TAKES_64BIT_TIME)
+ struct timespec64 va_atime;
+ struct timespec64 va_mtime;
+ struct timespec64 va_ctime;
+#else
+ struct timespec va_atime;
+ struct timespec va_mtime;
+ struct timespec va_ctime;
+#endif
} vattr_t;
#define VATTR_NULL(A) memset(A, 0, sizeof(struct vattr))
vattrp->va_size = iattrp->ia_size;
if (iattrp->ia_valid & ATTR_ATIME) {
vattrp->va_atime.tv_sec = iattrp->ia_atime.tv_sec;
- vattrp->va_atime.tv_usec = 0;
+ vattrp->va_atime.tv_nsec = 0;
}
if (iattrp->ia_valid & ATTR_MTIME) {
vattrp->va_mtime.tv_sec = iattrp->ia_mtime.tv_sec;
- vattrp->va_mtime.tv_usec = 0;
+ vattrp->va_mtime.tv_nsec = 0;
}
if (iattrp->ia_valid & ATTR_CTIME) {
vattrp->va_ctime.tv_sec = iattrp->ia_ctime.tv_sec;
- vattrp->va_ctime.tv_usec = 0;
+ vattrp->va_ctime.tv_nsec = 0;
}
}
attrs->va_atime.tv_nsec = attrs->va_mtime.tv_nsec =
attrs->va_ctime.tv_nsec = 0;
attrs->va_gen = hgetlo(avc->f.m.DataVersion);
-#elif defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_OBSD_ENV) || defined(AFS_NBSD_ENV)
+#elif defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_OBSD_ENV) || defined(AFS_NBSD_ENV) || defined(AFS_LINUX26_ENV)
attrs->va_atime.tv_nsec = attrs->va_mtime.tv_nsec =
attrs->va_ctime.tv_nsec =
(hgetlo(avc->f.m.DataVersion) & 0x7ffff) * 1000;
#endif
mask |= AFS_SETMODTIME;
#ifndef AFS_SGI_ENV
-#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) || defined(AFS_LINUX26_ENV)
if (av->va_mtime.tv_nsec == -1)
#else
if (av->va_mtime.tv_usec == -1)
AC_CHECK_LINUX_TYPE([struct vfs_path], [dcache.h])
AC_CHECK_LINUX_TYPE([kuid_t], [uidgid.h])
AC_CHECK_LINUX_TYPE([struct proc_ops], [proc_fs.h])
+AC_CHECK_LINUX_TYPE([time_t], [types.h])
])
#ifdef HAVE_ARC4RANDOM
# undef HAVE_ARC4RANDOM
#endif
+
+#if !defined(AFS_LINUX26_ENV)
+/*
+ * gettimeofday is only used in rand-fortuna.c, not built for Linux.
+ * Linux 5.6 removes the native struct timeval, so this stub would not build.
+ */
static_inline int gettimeofday(struct timeval *tp, void *tzp)
{if (tp == NULL) return -1; tp->tv_sec = osi_Time(); tp->tv_usec = 0; return 0;}
+#endif
#if defined(KERNEL) && (defined(AFS_SUN5_ENV) || defined(AFS_ARM64_LINUX26_ENV))
/*