Re: msdosfs: remove timezone support

2019-08-30 Thread Ted Unangst
Scott Cheloha wrote:
> The FAT file system hails from Redmond and so it tracks a timezone.
> OpenBSD implicitly uses the kernel timezone when selecting which
> timezone to use when mounting a FAT file system.
> 
> This support is undocumented.
> 
> This patch removes that support.
> 
> The upshot is that your timestamps will be off if (a) you were making
> use of the kernel timezone in OpenBSD and (b) the file system in
> question is shared between machines that vary in their support for FAT
> timezones.

oh, and it seems bugged if your uptime crosses a DST transition? good riddance
i guess.



msdosfs: remove timezone support

2019-08-30 Thread Scott Cheloha
The FAT file system hails from Redmond and so it tracks a timezone.
OpenBSD implicitly uses the kernel timezone when selecting which
timezone to use when mounting a FAT file system.

This support is undocumented.

This patch removes that support.

The upshot is that your timestamps will be off if (a) you were making
use of the kernel timezone in OpenBSD and (b) the file system in
question is shared between machines that vary in their support for FAT
timezones.

This is the last use of the kernel timezone I can find in base.  With
this resolved we can move ahead with decoupling the kernel timezone
from gettimeofday/settimeofday(2) and then removing DST/TIMEZONE from
config(8).

ok?

Index: usr.sbin/makefs/msdos/msdosfs_vfsops.c
===
RCS file: /cvs/src/usr.sbin/makefs/msdos/msdosfs_vfsops.c,v
retrieving revision 1.11
diff -u -p -r1.11 msdosfs_vfsops.c
--- usr.sbin/makefs/msdos/msdosfs_vfsops.c  17 Dec 2016 16:43:30 -  
1.11
+++ usr.sbin/makefs/msdos/msdosfs_vfsops.c  30 Aug 2019 12:20:24 -
@@ -48,7 +48,6 @@
  */
 
 #include 
-#include 
 
 #include "ffs/buf.h"
 
@@ -87,7 +86,6 @@ msdosfs_mount(struct mkfsvnode *devvp, i
uint8_t SecPerClust;
int ronly = 0, error;
int bsize;
-   struct timezone tz;
unsigned secsize = 512;
 
DPRINTF(("%s(bread 0)\n", __func__));
@@ -125,12 +123,7 @@ msdosfs_mount(struct mkfsvnode *devvp, i
pmp->pm_SecPerTrack = getushort(b50->bpbSecPerTrack);
pmp->pm_Heads = getushort(b50->bpbHeads);
pmp->pm_Media = b50->bpbMedia;
-
-   if (gettimeofday(NULL, &tz) == -1) {
-   error = errno;
-   goto error_exit;
-   }
-   pmp->pm_minuteswest = tz.tz_minuteswest;
+   pmp->pm_minuteswest = 0;
 
DPRINTF(("%s(BytesPerSec=%u, ResSectors=%u, FATs=%d, RootDirEnts=%u, "
"Sectors=%u, FATsecs=%lu, SecPerTrack=%u, Heads=%u, Media=%u)\n",
Index: sys/msdosfs/msdosfs_conv.c
===
RCS file: /cvs/src/sys/msdosfs/msdosfs_conv.c,v
retrieving revision 1.19
diff -u -p -r1.19 msdosfs_conv.c
--- sys/msdosfs/msdosfs_conv.c  23 Oct 2015 10:45:31 -  1.19
+++ sys/msdosfs/msdosfs_conv.c  30 Aug 2019 12:20:24 -
@@ -108,8 +108,7 @@ unix2dostime(struct timespec *tsp, u_int
 * If the time from the last conversion is the same as now, then
 * skip the computations and use the saved result.
 */
-   t = tsp->tv_sec - (tz.tz_minuteswest * 60)
-/* +- daylight saving time correction */ ;
+   t = tsp->tv_sec;
t &= ~1;
/*
 * Before 1/1/1980 there is only a timeless void. After 12/31/2107
@@ -228,8 +227,7 @@ dos2unixtime(u_int dd, u_int dt, u_int d
days += ((dd & DD_DAY_MASK) >> DD_DAY_SHIFT) - 1;
lastseconds = (days * 24 * 60 * 60) + SECONDSTO1980;
}
-   tsp->tv_sec = seconds + lastseconds + (tz.tz_minuteswest * 60)
-/* -+ daylight saving time correction */ ;
+   tsp->tv_sec = seconds + lastseconds;
tsp->tv_nsec = (dh % 100) * 1000;
 }