]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
LINUX 5.6: define time_t and use timespec/timespec64
authorCheyenne Wills <cwills@sinenomine.net>
Tue, 3 Mar 2020 22:39:49 +0000 (15:39 -0700)
committerStephan Wiesand <stephan.wiesand@desy.de>
Wed, 18 Mar 2020 19:17:16 +0000 (15:17 -0400)
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.

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>
(cherry picked from commit 78049987aa3e84865e2e7e0f3dd3b54d66258e74)

Change-Id: Iff80c161441356d19b5962956dd524792b7bf629
Reviewed-on: https://gerrit.openafs.org/14095
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/afs/LINUX/osi_machdep.h
src/afs/LINUX/osi_vfs.h
src/afs/LINUX/osi_vnodeops.c
src/afs/VNOPS/afs_vnop_attrs.c
src/cf/linux-kernel-type.m4
src/crypto/hcrypto/kernel/config.h

index 6832c3ee0869dedb40e305c9445b4bc1558d6be6..1864cec6e4279c06042ad173f15cc4fc7f17dfda 100644 (file)
 #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;
index f771dad38cca5aa70f16edbb85889936ecd07663..b3006796e2fc38affb0805065640156323595db9 100644 (file)
@@ -70,9 +70,15 @@ typedef struct vattr {
     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))
index d8487afb33964117d8dbdd6e6c551de6aa1b9a26..03635212cdd791be345cff9080e8f651a3e67e5d 100644 (file)
@@ -1008,15 +1008,15 @@ iattr2vattr(struct vattr *vattrp, struct iattr *iattrp)
        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;
     }
 }
 
index 05a38ce969f63f6133d7490f3f83de03915df55f..a22331a5b10285f65efca508b178dcb303d18a25 100644 (file)
@@ -141,7 +141,7 @@ afs_CopyOutAttrs(struct vcache *avc, struct vattr *attrs)
     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;
@@ -433,7 +433,7 @@ afs_VAttrToAS(struct vcache *avc, struct vattr *av,
 #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)
index ae59fccfb975735c358ef721c7e568df4f9607f5..444317da5717a889133d114ca341afe703aa1267 100644 (file)
@@ -3,4 +3,5 @@ dnl Type existence checks
 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])
 ])
index 6fec83da0f4e3375004eb0cfd2d819a306aaaeca..dd7608daef0fa6f41e4025a776e2b58301d7bba1 100644 (file)
@@ -98,8 +98,15 @@ static_inline int close(int d) {return -1;}
 #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))
 /*