From owner-svn-src-all@freebsd.org Mon Aug 6 00:46:56 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D0C3D1064468; Mon, 6 Aug 2018 00:46:55 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id 1BA5B7FAB1; Mon, 6 Aug 2018 00:46:54 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id E104E42B63E; Mon, 6 Aug 2018 10:46:42 +1000 (AEST) Date: Mon, 6 Aug 2018 10:46:42 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Bruce Evans cc: Ian Lepore , Warner Losh , "Rodney W. Grimes" , Conrad Meyer , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r337334 - head/lib/libc/sys In-Reply-To: <20180806074507.E920@besplex.bde.org> Message-ID: <20180806095604.J860@besplex.bde.org> References: <201808042208.w74M8OmD057603@repo.freebsd.org> <201808042224.w74MOgLi095274@pdx.rh.CN85.dnsmgr.net> <1533478958.9860.18.camel@freebsd.org> <20180806074507.E920@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=EseilWUA c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=IfFsZ5XXtjUjwcPZAScA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Aug 2018 00:46:56 -0000 On Mon, 6 Aug 2018, Bruce Evans wrote: > ... > I forgot about FAT times, and only remembered that utc_offset() was used > for RTC drivers. I thought that utc_offset() is 0 unless something sets > the timezone to nonzero or the RTC is on local time (wall_cmos_clock case). > However, since the kernel needs the timezone for FAT times, it must be > known even if the RTC is on UTC time. Now I don't see how FAT times can > even work unless the wall_cmos_clock. They are just the UTC minus > utc_offset(), where utc_offset() is > > (tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0)) > > Here wall_cmos_clock is only for managing the RTC offset. It must be 0 > unless the RTC is on local time. But then either FAT times or RTC times > must be broken except in the Greenwich meridian. Otherwise, tz_minuteswest > must be nonzero to ajust FAT times right, but this makes utc_offset() > unusable for the RTC offset. I verified the brokenness: - adjkerntz() normally leaves tz_minuteswest as 0. I verified that it does this when there is a nonzero dst adjustment. dst adjustments are folded into machdep.adjkerntz. - when wall_cmos_clock == 0, adjkerntz(8) does little or nothing, so all adjustments are 0, so utc_offset() is 0, so FAT times are broken except in the Greenwich meridian. The broken FAT times are not completely obvious, since getting and setting them use the same wrong offset of 0, so the times appear to be correct when displayed on FreeBSD. The are only obviously wrong when displayed on another system with non-broken FAT times, perhaps by rebooting to the other system or by moving removable media to such a system. FAT times are used by other file systems. I checked this in FreeBSD-9 so as to find axed file systems. The were used by smbfs, nwfs and msdosfs. Now they are only used by msdosfs. I never liked de-deduplicating their implementation into an over-engineered version with especially excessive handling for leap years. Leap year handling is unimportant compared with offset handling. tz_minuteswest is used by compatibility code. It cannot usefully be removed from the native version, since non-native syscalls use it and non-native applications might use it. Of course, it must have a correct value to work in compatibility. Its normal value of 0 breaks compatibility code much like the bugs in utc_offset() breaks FAT time. It is used in the following compatibility code: - amd64 linux32 linux_gettimeofday(). Like native gettimeofday(). It also reconstructs the dstflag part of the timezone struct. If linux drops this, then strict compatiility requires the support to depend on the linux version. - amd64 linux32 linux_settimeofday(). Like native settimeofday(). Has invisible reference to tz_minuteswest hidden in assignment of timezones. I only grepped for tz_minuteswest and only checked this indirect reference. - freebsd32 freebsd32_gettimeofday(). Similarly, except we control it, so can avoid needing version checks by not dropping support. - dev/tws/tws_services.h. This uses utc_offset() for FreeBSD-7 and later, and its reference to tz_minuteswest is only explicit for older versions where it open-codes utc_offset() with bug for bug compatibility except for adding style bugs. - smbfs. This uses FAT times, and in nearby code it uses tzoff for the offset and has commented-out code with an open-coded fully-buggy utc_offset(). - ibcs2 xenix_ftime(). This is similar to gettimeofday(). Bruce