From owner-svn-src-head@freebsd.org Wed Dec 5 20:23:13 2018 Return-Path: Delivered-To: svn-src-head@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 F374E1326608; Wed, 5 Dec 2018 20:23:12 +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 798996A384; Wed, 5 Dec 2018 20:23:10 +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 0EE99435E55; Thu, 6 Dec 2018 07:23:02 +1100 (AEDT) Date: Thu, 6 Dec 2018 07:23:01 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Alan Somers cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r341598 - head/lib/libc/sys In-Reply-To: <201812051728.wB5HSes8099327@repo.freebsd.org> Message-ID: <20181206062019.I3775@besplex.bde.org> References: <201812051728.wB5HSes8099327@repo.freebsd.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=P6RKvmIu c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=SbwDSD-lIzFxxfcz6sIA:9 a=CjuIK1q_8ugA:10 X-Rspamd-Queue-Id: 798996A384 X-Spamd-Result: default: False [-5.79 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip4:211.29.132.0/23]; FREEMAIL_FROM(0.00)[optusnet.com.au]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DMARC_NA(0.00)[optusnet.com.au]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE(-2.50)[ip: (-5.08), ipnet: 211.28.0.0/14(-4.10), asn: 4804(-3.28), country: AU(-0.04)]; MX_GOOD(-0.01)[cached: extmail.optusnet.com.au]; NEURAL_HAM_SHORT(-0.97)[-0.975,0]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[optusnet.com.au]; ASN(0.00)[asn:4804, ipnet:211.28.0.0/14, country:AU]; RCVD_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_LOW(-0.10)[246.132.29.211.list.dnswl.org : 127.0.5.1] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Dec 2018 20:23:13 -0000 On Wed, 5 Dec 2018, Alan Somers wrote: > Log: > stat(2): clarify which syscalls modify file timestamps > > The list of syscalls that modify st_atim, st_mtim, and st_ctim was quite out > of date and probably not accurate to begin with. Update it, and make it > clear that the list is open-ended. These fields shouldn't exist. They are misimplemented compatibility cruft. They didn't exist in FreeBSD-4. They were correctly implemented compatibility cruft then. The POSIX fields are still only time_t's with names st_atime, etc., but these fields are timespecs with necessarily different names. In FreeBSD-4, they were named st_atimespec, etc. unless POSIX_SOURCE is defined, which before about 2007 POSIX required struct timespec to not be defined, so the fields were declared as 2 scalars st_atime and st_atimensec, etc. Padding of the scalars caused ABI problems which I fixed in FreeBSD-5 using bit-fields. Now the support for POSIX before about 2007 is broken by declaring struct timespec undonditionally and using it for st_atim, etc. API compatibility with old versions of FreeBSD is broken by renaming st_atimespec to st_atim, etc. All versions that use timespecs use macro hacks of dubious standard conformance to convert from timespecs to POSIX time_t's. All names starting with st_ are reserved if is included. This is what makes it conforming for the implementation to use st_atim, etc. It is less clear if the macros conform because it would be non-conforming for a an application to #undef st_atim or depend on st_atim not being a macro. > Modified: head/lib/libc/sys/stat.2 > ============================================================================== > --- head/lib/libc/sys/stat.2 Wed Dec 5 17:13:33 2018 (r341597) > +++ head/lib/libc/sys/stat.2 Wed Dec 5 17:28:40 2018 (r341598) > ... > @@ -193,45 +193,53 @@ are: > .Bl -tag -width ".Va st_birthtim" > .It Va st_atim > Time when file data was last accessed. > -Changed by the > -.Xr mknod 2 , Not changed by mknod, but set by it. Still set by it. > -.Xr utimes 2 , Not really changed if the change is null, where a null change may be the result of rounding to a representable value. Permissions are still required for making null changes. Similarly for most operations. > +Changed implicitly by syscalls such as > .Xr read 2 > and > -.Xr readv 2 > -system calls. > +.Xr readv 2 , Not changed by reads if the file system is mounted -noatime and the file system supports this (you can't tell if the file system supports this by examining its MNT_NOATIME flag). Not changed if granularity makes the change null. > +and explicitly by > +.Xr utimes 2 . The lists would be even longer if they mentioned utime, lutimes, futimes, futimesat, futimens and futimnsat. > .It Va st_mtim > Time when file data was last modified. > -Changed by the > +Changed implicitly by syscalls such as > +.Xr truncate 2 , > +.Xr write 2 , > +and > +.Xr writev 2 , > +and explicitly by > +.Xr utimes 2 . > +Also, any syscall which modifies directory content changes the > +.Va st_mtim > +for the affected directory. > +For instance, > +.Xr creat 2 , Usually spelled open with O_CREAT. > .Xr mkdir 2 , creat, open with O_CREAT, link, symlink, mkdir and all of the removed mk's also set all times. > -.Xr mkfifo 2 , > -.Xr mknod 2 , > -.Xr utimes 2 , > -.Xr write 2 > +.Xr rename 2 , > +.Xr link 2 , rename to a different directory changes 2 sets of directory times. link is unsorted in this and another list. > ... > +.Xr link 2 , > and > -.Xr writev 2 > -system calls. > +.Xr unlink 2 . > .It Va st_birthtim > Time when the inode was created. > .El st_birthim should be named st_btime. st_birthtim is set by all creation operations. It is changed by changing st_mtim to a value before the current st_birthtim. This is done at the vfs level, so it should work for all file systems that support birthtimes. Changing st_birthtime forwards is not supported by any syscall. There are already about 10 times too many syscalls for setting times, but none of them supports setting birthtimes or ctimes. I use a sysctl hack to set ctimes, as needed to back up and restore them, but don't do anything special for birthtimes. Bruce