Subject: port-i386/1413: inittodr() now requires the disk time
To: None <gnats-bugs@gnats.netbsd.org>
From: None <carrel@cisco.com>
List: netbsd-bugs
Date: 08/27/1995 12:40:26
>Number:         1413
>Category:       port-i386
>Synopsis:       inittodr() now requires the disk time
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Aug 27 15:50:01 1995
>Last-Modified:
>Originator:     David Carrel
>Organization:
	Just me!
>Release:        NetBSD-current sup-ed 18 August 1995
>Environment:
	i386 port, intel 486 in a gateway 2000 laptop.  Kernel contains
personal modifications for APM development.

System: NetBSD spy 1.0A NetBSD 1.0A (DAVE) #15: Fri Aug 18 09:19:25 PDT 1995 carrel@spy:/home/haydon/NetBSD/src/sys/arch/i386/compile/DAVE i386


>Description:
	The routine inittodr() in sys/arch/i386/isa/clock.c used to not use
the parameter that was passed in.  It is now used to provide the time-stamp
from the disk and warnings are printed/logged if the value differs
significantly from the real time clock value.  But this routine should
allow itself to be called without having to pass in the filesystem
timestamp.  If the value passed in is zero, it should not be assumed to be
a valid time and the comparisons should not be done.
	This should probably be fixed in other ports, but I'm not doing
work with that routine in any other ports so I haven't looked into it.
>How-To-Repeat:
	Call inittodr() with a value of zero.  See sys/mfs/mfs_vfsops.c
I am using this in my APM code and I don't believe that this should be
concerned with the file-system time.  I just want the real-time clock time.
>Fix:
	The following patch fixes this:

*** clock.c.orig	Wed Aug 16 08:55:59 1995
--- clock.c	Fri Aug 25 09:15:16 1995
***************
*** 400,406 ****
  	 * the latter case, it's likely that the CMOS battery has died.)
  	 */
  
! 	if (base < 15*SECYR) {	/* if before 1985, something's odd... */
  		printf("WARNING: preposterous time in file system\n");
  		/* read the system clock anyway */
  		base = 17*SECYR + 186*SECDAY + SECDAY/2;
--- 400,406 ----
  	 * the latter case, it's likely that the CMOS battery has died.)
  	 */
  
! 	if (base && base < 15*SECYR) { /* if before 1985, something's odd... */
  		printf("WARNING: preposterous time in file system\n");
  		/* read the system clock anyway */
  		base = 17*SECYR + 186*SECDAY + SECDAY/2;
***************
*** 438,449 ****
  	if (tz.tz_dsttime)
  		n -= 3600;
  
! 	if (base < n - 5*SECYR)
! 		printf("WARNING: file system time much less than clock time\n");
! 	else if (base > n + 5*SECYR) {
! 		printf("WARNING: clock time much less than file system time\n");
! 		printf("WARNING: using file system time\n");
! 		goto fstime;
  	}
  
  	timeset = 1;
--- 438,453 ----
  	if (tz.tz_dsttime)
  		n -= 3600;
  
! 	if (base) {
! 		if (base < n - 5*SECYR)
! 			printf("WARNING: file system time much less than "
! 			       "clock time\n");
! 		else if (base > n + 5*SECYR) {
! 			printf("WARNING: clock time much less than file "
! 			       "system time\n");
! 			printf("WARNING: using file system time\n");
! 			goto fstime;
! 		}
  	}
  
  	timeset = 1;

>Audit-Trail:
>Unformatted: