new syctl to allow ignoring time from fs if no rtc found

From: Sulev-Madis Silber <madis555_at_hot.ee>
Date: Tue, 20 Jun 2023 23:23:49 UTC
unsure if anybody else needs that functionality. i was suggested to submit
it into actual code review place, but i'm unsure. it's from 2014, it still
cleanly applies. probably because noone needed to touch working code!
anyway, i used it in in arm board development, in bbb, to default system
time to "visually invalid" 1970 when no other source was found. i found
getting time from filesystem causing much confusion when files were created
before ntp sync. so i added this hack

http://ketas.si.pri.ee/bbb/src-patches/debug-no-timestamp-from-filesystem.diff

Index: sys/kern/vfs_mountroot.c
===================================================================
--- sys/kern/vfs_mountroot.c (revision 274644)
+++ sys/kern/vfs_mountroot.c (working copy)
@@ -968,14 +968,16 @@
* timestamps we encounter.
*/
timebase = 0;
- mtx_lock(&mountlist_mtx);
- mp = TAILQ_FIRST(&mountlist);
- while (mp != NULL) {
- if (mp->mnt_time > timebase)
- timebase = mp->mnt_time;
- mp = TAILQ_NEXT(mp, mnt_list);
+ if (kern_getenv("debug.no_timestamp_from_filesystem") == NULL) {
+ mtx_lock(&mountlist_mtx);
+ mp = TAILQ_FIRST(&mountlist);
+ while (mp != NULL) {
+ if (mp->mnt_time > timebase)
+ timebase = mp->mnt_time;
+ mp = TAILQ_NEXT(mp, mnt_list);
+ }
+ mtx_unlock(&mountlist_mtx);
}
- mtx_unlock(&mountlist_mtx);
inittodr(timebase);

/* Keep prison0's root in sync with the global rootvnode. */