Re: Timekeeping problem in /usr/src on new RPI aarch64 snapshot

From: Ronald Klop <ronald-lists_at_klop.ws>
Date: Fri, 24 Feb 2023 23:21:09 UTC
Van: bob prohaska <fbsd@www.zefox.net>
Datum: 24 februari 2023 22:05
Aan: freebsd-current@freebsd.org
CC: freebsd-arm@freebsd.org
Onderwerp: Timekeeping problem in /usr/src on new RPI aarch64 snapshot

> 
> 
> After installing 
> FreeBSD-14.0-CURRENT-arm64-aarch64-RPI-20230223-fe5c211ba873-261074.img
> on a Pi3 and setting up the hard disk to use separate swap and /usr partitions
> an oddity came to light regarding dates.
> 
> The image file was written to disk the night of the 23rd, from a Pi3 with
> a correctly-set time and date. It was left idle overnight, configured the
> morning of the 24th and booted without issue. It then cloned -current into
> /usr/src, at which point the time was noticed to be wrong, apparently fast.
> 
> It turned out ntpdate wasn't running, so it was started and then tzsetup
> run. After a reboot the time reported correctly. 
> 
> However, make buildworld in /usr/src triggers an exhortation to "check
> your time" and refuses run further. 
> 
> running date on the system reports
> Fri Feb 24 12:49:41 PST 2023
> but ls -l /usr/src reports time around 
> Feb 24 19:10
> an obvious inconsistency.
>  
> Presumably just waiting until the system clock catches
> up with the /usr/src timestamps will fix the error. Is
> there a better method?
> 
> Still, the date and time handling don't seem quite right. 
> In at least one earlier instance it appeared that tzsetup 
> altered the reported timeszone without shifting the time
> stamp by the UTC/PDT offset. I always thought timestamps
> were internally in UTC+timezone, displayed with the right
> offset. It looks to a casual observer like something else
> is going on. 
> 
> An earlier fiasco (on this same Pi3) included wildly wrong
> timestamps in a filesystem. The Pi3 has no hardware clock,
> how does it set time when booted without a reference?
> 
> Thanks for reading,
> 
> bob prohaska
> 
> 
> 
> 
> 
> 

UFS stores the current timestamp in the superblock of the FS on clean shutdown/unmount. On boot it reads the time from the timestamp in the superblock of the root FS. Of coarse this timestamp is behind for the duration that the machine was off or rebooting so you need to adjust that using ntp. 
For ZFS root you can use the fakertc port to do something similar. 


You can use the command “touch“ to manipulate the time of your /usr/src dir. 


Regards,
Ronald