Skip to contentSkip to conversation

time:Introduce the do_sys_settimeofday64() function with timespec64 type

PATCH Superseded Baolin Wang 2 participants 2 messages Jun 1, 2015 – Jun 2, 2015 Timekeeping, clocksource core, NTP, alarmtimer

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 5/25 time:Introduce the do_sys_settimeofday64() function with timespec64 type

Introduce the do_sys_settimeofday64() function with timespec64 type to make it is ready for 2038 issue when setting the time of day.

And move the do_sys_settimeofday() function to the timekeeping.h file, that it is convenient to delete it later.

---
 include/linux/timekeeping.h |   12 ++++++++++--
 kernel/time/time.c          |    8 ++++----
 2 files changed, 14 insertions(+), 6 deletions(-)
include/linux/timekeeping.h +10 -2
index c6d5ae9..89beb62 100644
@@ -11,8 +11,16 @@ 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;
+
+	ts64 = timespec_to_timespec64(*tv);
+	return do_sys_settimeofday64(&ts64, tz);
+}
 
 /*
  * Kernel time accessors
kernel/time/time.c +4 -4
index 2c85b77..33c539b 100644
@@ -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;
 
@@ -182,7 +182,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;
 }
 
Signature · 1 line
1.7.9.5
#1 lore raw

On Mon, 1 Jun 2015, Baolin Wang wrote:

Subject line sucks.

Quoted 5 lines

Introduce the do_sys_settimeofday64() function with timespec64 type to make it is ready for 2038 issue when setting the time of day.

And move the do_sys_settimeofday() function to the timekeeping.h file, that it is convenient to delete it later.

See other mails.

include/linux/timekeeping.h extern int timekeeping_suspended; · line 22

Quoted 13 lines

extern void do_gettimeofday(struct timeval *tv); extern int do_settimeofday64(const struct timespec64 *ts);

include/linux/timekeeping.h +9 -2
-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;
+
+	ts64 = timespec_to_timespec64(*tv);
+	return do_sys_settimeofday64(&ts64, tz);

If you write it:

	struct timespec64 ts64 = timespec_to_timespec64(*tv);

	return do_sys_settimeofday64(&ts64, tz);

You spare a line per inline function. Applies to the other patches as well.

kernel/time/time.c static inline void warp_clock(void) · line 171

Quoted 13 lines
kernel/time/time.c +3 -3
-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);

No such function. Fails to build.

Thanks,

tglx