Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Mar 2006 06:45:06 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 93918 for review
Message-ID:  <200603240645.k2O6j61I058328@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=93918

Change 93918 by imp@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");
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603240645.k2O6j61I058328>