Re: Bug in fat-fs code: file date/time wrong

Edgar Toernig (froese@gmx.de)
Sat, 13 Nov 1999 05:08:27 +0100


Peter Daum wrote:
>
> it seems, that the calculation of fat/vfat file times in the
> linux kernel is incorrect. Consider the following DOS directory
> listing:
>
> jan 0 01-01-1999 0:00
> feb 0 02-01-1999 0:00
> mar 0 03-01-1999 0:00
> apr 0 04-01-1999 0:00
>...
> date/time as MS-DOS. When mounted as a msdos or vfat file system,
> Linux reports the following timestamps instead:
>
> FILENAME MTIME
> jan 98-12-31 23:00
> feb 99-01-31 23:00
> mar 99-02-28 23:00
> apr 99-04-01 00:00
>...

Afaics fat uses wall clock time. To convert it to linux's
GMT time you have to know the DST state of the date to convert.
But figuring out if DST was in effect at that date is a very
complicated thing and, I guess, will never be put into the
kernel. The method to use the current DST state is a simple
solution that'll work most of the time.

Unfortunately, the tz_dsttime field does not indicate if DST
is in effect but just says that DST "applies during some part
of the year". The value of tz_dsttime defines which DST rule
should be used. (This is similar to libc's "daylight" var.)

A quick userspace hack that would give you correct results for
the current DST interval would be to call settimeofday and set
tz_dsttime to 1 if DST is in effect and to 0 otherwise. Afaics
only fat and iso9660 use this field and both wrong.

Ciao, ET.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/