time: Introduce do_sys_settimeofday64()
authorBaolin Wang <baolin.wang@linaro.org>
Fri, 8 Apr 2016 06:02:12 +0000 (14:02 +0800)
committerJohn Stultz <john.stultz@linaro.org>
Fri, 22 Apr 2016 18:49:04 +0000 (11:49 -0700)
The do_sys_settimeofday() function uses a timespec, which is not year
2038 safe on 32bit systems.

Thus this patch introduces do_sys_settimeofday64(), which allows us to
transition users of do_sys_settimeofday() to using 64bit time types.

Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
[jstultz: Include errno-base.h to avoid build issue on some arches]
Signed-off-by: John Stultz <john.stultz@linaro.org>
include/linux/timekeeping.h
kernel/time/time.c

index 96f37bee3bc13b96f3ddd9a27657e6d64340ceb3..37dbacf84849add3a31b410ee06d26ec08c56a07 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _LINUX_TIMEKEEPING_H
 #define _LINUX_TIMEKEEPING_H
 
+#include <asm-generic/errno-base.h>
+
 /* Included from linux/ktime.h */
 
 void timekeeping_init(void);
@@ -11,8 +13,19 @@ extern int timekeeping_suspended;
  */
 extern void do_gettimeofday(struct timeval *tv);
 extern int do_settimeofday64(const struct timespec64 *ts);
-extern int do_sys_settimeofday(const struct timespec *tv,
-                              const struct timezone *tz);
+extern int do_sys_settimeofday64(const struct timespec64 *tv,
+                                const struct timezone *tz);
+static inline int do_sys_settimeofday(const struct timespec *tv,
+                                     const struct timezone *tz)
+{
+       struct timespec64 ts64;
+
+       if (!tv)
+               return -EINVAL;
+
+       ts64 = timespec_to_timespec64(*tv);
+       return do_sys_settimeofday64(&ts64, tz);
+}
 
 /*
  * Kernel time accessors
index be115b020d2772ae6794320cf79499723137411d..a4064b6120664c0cb87b553cba3dc8c454dec997 100644 (file)
@@ -160,15 +160,15 @@ static inline void warp_clock(void)
  * various programs will get confused when the clock gets warped.
  */
 
-int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
+int do_sys_settimeofday64(const struct timespec64 *tv, const struct timezone *tz)
 {
        static int firsttime = 1;
        int error = 0;
 
-       if (tv && !timespec_valid(tv))
+       if (tv && !timespec64_valid(tv))
                return -EINVAL;
 
-       error = security_settime(tv, tz);
+       error = security_settime64(tv, tz);
        if (error)
                return error;
 
@@ -186,7 +186,7 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
                }
        }
        if (tv)
-               return do_settimeofday(tv);
+               return do_settimeofday64(tv);
        return 0;
 }
 
This page took 0.026896 seconds and 5 git commands to generate.