This patch introduces the do_sys_settimeofday64() function with timespec64
type, that makes this function ready for 2038 issue when setting the time of 
day.

Signed-off-by: Baolin Wang <[email protected]>
---
 include/linux/timekeeping.h |    2 ++
 kernel/time/time.c          |   18 ++++++++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index c6d5ae9..6a79df4 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -13,6 +13,8 @@ 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);
 
 /*
  * Kernel time accessors
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 2c85b77..fe65e7d 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -160,15 +160,17 @@ 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;
+       struct timespec ts;
 
-       if (tv && !timespec_valid(tv))
+       if (tv && !timespec64_valid(tv))
                return -EINVAL;
 
-       error = security_settime(tv, tz);
+       ts = timespec64_to_timespec(*tv);
+       error = security_settime(&ts, tz);
        if (error)
                return error;
 
@@ -182,10 +184,18 @@ int do_sys_settimeofday(const struct timespec *tv, const 
struct timezone *tz)
                }
        }
        if (tv)
-               return do_settimeofday(tv);
+               return do_settimeofday64(tv);
        return 0;
 }
 
+int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
+{
+       struct timespec64 ts64;
+
+       ts64 = timespec_to_timespec64(*tv);
+       return do_sys_settimeofday64(&ts64, tz);
+}
+
 SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
                struct timezone __user *, tz)
 {
-- 
1.7.9.5

_______________________________________________
Y2038 mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/y2038

Reply via email to