Subject: kern/9497: incorrect timestamp handling on msdosfs (/sys/msdosfs/msdosfs_conv.c)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <naoki@fukaumi.org>
List: netbsd-bugs
Date: 02/27/2000 03:30:41
>Number:         9497
>Category:       kern
>Synopsis:       incorrect timestamp handling on msdosfs (/sys/msdosfs/msdosfs_conv.c)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 27 03:30:00 2000
>Last-Modified:
>Originator:     Naoki FUKAUMI
>Organization:
Personal
>Release:        NetBSD-1.4.1/i386 and NetBSD-release source (2000/02/27)
>Environment:
>Description:
In /sys/msdosfs/msdosfs_conv.c, tz.tz_minuteswest was used and
commented out now. But, the kernel which have non zero RTC_OFFSET value
report wrong timestamp on msdosfs.

>How-To-Repeat:
Compile kernel which have RTC_OFFSET=-540 option. Boot new kernel.
Exec "mount_msdos /somewhere" and "ls -l /somewhere".
Compare DIR result on MSDOS and ls -l result on NetBSD.

>Fix:
Use rtc_offset instead of tz.tz_minuteswest.

--- sys/msdosfs/msdosfs_conv.c.orig     Sun Mar 28 20:05:43 1999
+++ sys/msdosfs/msdosfs_conv.c  Thu Jan  6 01:49:35 2000
@@ -53,7 +53,7 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/time.h>
-#include <sys/kernel.h>                /* defines tz XXX */
+#include <sys/kernel.h>
 #include <sys/dirent.h>
 #include <sys/vnode.h>

@@ -110,8 +110,7 @@
         * If the time from the last conversion is the same as now, then
         * skip the computations and use the saved result.
         */
-       /* XXX NOTE: Removed tz, which is obsolete. Must replace!!! */
-       t = tsp->tv_sec /* - (tz.tz_minuteswest * 60) */
+       t = tsp->tv_sec - (rtc_offset * 60)
             /* +- daylight savings time correction */ ;
        t &= ~1;
        if (lasttime != t) {
@@ -225,8 +224,7 @@
                days += ((dd & DD_DAY_MASK) >> DD_DAY_SHIFT) - 1;
                lastseconds = (days * 24 * 60 * 60) + SECONDSTO1980;
        }
-       /* XXX NOTE: Removed tz, which is obsolete. Must replace!!! */
-       tsp->tv_sec = seconds + lastseconds /* + (tz.tz_minuteswest * 60) */
+       tsp->tv_sec = seconds + lastseconds + (rtc_offset * 60)
             /* -+ daylight savings time correction */ ;
        tsp->tv_nsec = (dh % 100) * 10000000;
 }

>Audit-Trail:
>Unformatted: