PERFORCE change 93918 for review

Warner Losh imp at FreeBSD.org
Fri Mar 24 06:45:07 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=93918

Change 93918 by imp at imp_Speedy on 2006/03/24 06:44:52

	If mnt_time is set, use it in preference to the RTC clock if
	they are more than 2 days off.  This restores 4.2 behavior that
	was lost along the way.
	
	# alas, nfs doesn't set this.

Affected files ...

.. //depot/projects/arm/src/sys/kern/subr_clock.c#2 edit

Differences ...

==== //depot/projects/arm/src/sys/kern/subr_clock.c#2 (text+ko) ====

@@ -254,7 +254,8 @@
 void
 inittodr(time_t base)
 {
-	struct timespec diff, ref, ts;
+	time_t		deltat;
+	struct timespec ref, ts;
 	int error;
 
 	if (base) {
@@ -282,17 +283,18 @@
 	ts.tv_sec += tz_minuteswest * 60 +
 	    (wall_cmos_clock ? adjkerntz : 0);
 
-	if (timespeccmp(&ref, &ts, >)) {
-		diff = ref;
-		timespecsub(&ref, &ts);
-	} else {
-		diff = ts;
-		timespecsub(&diff, &ref);
-	}
-	if (ts.tv_sec >= 2) {
-		/* badly off, adjust it */
+	deltat = ts.tv_sec - base;
+	if (deltat < 0)
+		deltat = -deltat;
+	if (deltat < 2 * SECDAY || base == 0) {
 		tc_setclock(&ts);
+		return;
 	}
+
+	printf("WARNING: clock %s %d days",
+	    ts.tv_sec < base ? "lost" : "gained", (int)(deltat / SECDAY));
+
+	printf(" -- CHECK AND RESET THE DATE!\n");
 }
 
 /*


More information about the p4-projects mailing list