1*86d7f5d3SJohn Marino.\" $NetBSD: inittodr.9,v 1.2 1996/03/27 21:16:06 jtc Exp $ 2*86d7f5d3SJohn Marino.\" 3*86d7f5d3SJohn Marino.\" Copyright (c) 1994 Christopher G. Demetriou 4*86d7f5d3SJohn Marino.\" All rights reserved. 5*86d7f5d3SJohn Marino.\" 6*86d7f5d3SJohn Marino.\" Redistribution and use in source and binary forms, with or without 7*86d7f5d3SJohn Marino.\" modification, are permitted provided that the following conditions 8*86d7f5d3SJohn Marino.\" are met: 9*86d7f5d3SJohn Marino.\" 1. Redistributions of source code must retain the above copyright 10*86d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer. 11*86d7f5d3SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright 12*86d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer in the 13*86d7f5d3SJohn Marino.\" documentation and/or other materials provided with the distribution. 14*86d7f5d3SJohn Marino.\" 3. All advertising materials mentioning features or use of this software 15*86d7f5d3SJohn Marino.\" must display the following acknowledgement: 16*86d7f5d3SJohn Marino.\" This product includes software developed by Christopher G. Demetriou 17*86d7f5d3SJohn Marino.\" for the NetBSD Project. 18*86d7f5d3SJohn Marino.\" 3. The name of the author may not be used to endorse or promote products 19*86d7f5d3SJohn Marino.\" derived from this software without specific prior written permission 20*86d7f5d3SJohn Marino.\" 21*86d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22*86d7f5d3SJohn Marino.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23*86d7f5d3SJohn Marino.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24*86d7f5d3SJohn Marino.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25*86d7f5d3SJohn Marino.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26*86d7f5d3SJohn Marino.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27*86d7f5d3SJohn Marino.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28*86d7f5d3SJohn Marino.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29*86d7f5d3SJohn Marino.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30*86d7f5d3SJohn Marino.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31*86d7f5d3SJohn Marino.\" 32*86d7f5d3SJohn Marino.\" $FreeBSD: src/share/man/man9/inittodr.9,v 1.4.2.4 2001/12/17 11:30:18 ru Exp $ 33*86d7f5d3SJohn Marino.\" $DragonFly: src/share/man/man9/inittodr.9,v 1.3 2004/03/11 12:28:57 hmp Exp $ 34*86d7f5d3SJohn Marino.\" 35*86d7f5d3SJohn Marino.Dd March 22, 1997 36*86d7f5d3SJohn Marino.Dt INITTODR 9 37*86d7f5d3SJohn Marino.Os 38*86d7f5d3SJohn Marino.Sh NAME 39*86d7f5d3SJohn Marino.Nm inittodr 40*86d7f5d3SJohn Marino.Nd initialize system time 41*86d7f5d3SJohn Marino.Sh SYNOPSIS 42*86d7f5d3SJohn Marino.In sys/types.h 43*86d7f5d3SJohn Marino.In sys/systm.h 44*86d7f5d3SJohn Marino.Ft void 45*86d7f5d3SJohn Marino.Fn inittodr "time_t base" 46*86d7f5d3SJohn Marino.Sh DESCRIPTION 47*86d7f5d3SJohn MarinoThe 48*86d7f5d3SJohn Marino.Fn inittodr 49*86d7f5d3SJohn Marinofunction determines the time and sets the system clock. 50*86d7f5d3SJohn MarinoIt tries to pick the correct time using a set of heuristics that examine 51*86d7f5d3SJohn Marinothe system's battery backed clock and the time obtained from the root 52*86d7f5d3SJohn Marinofile system, as given in 53*86d7f5d3SJohn Marino.Fa base . 54*86d7f5d3SJohn MarinoHow the 55*86d7f5d3SJohn Marino.Fa base 56*86d7f5d3SJohn Marinovalue is obtained will vary depending on the 57*86d7f5d3SJohn Marinoroot file system type. 58*86d7f5d3SJohn MarinoThe heuristics used include: 59*86d7f5d3SJohn Marino.Bl -bullet 60*86d7f5d3SJohn Marino.It 61*86d7f5d3SJohn MarinoIf the battery-backed clock has a valid time, it is used. 62*86d7f5d3SJohn Marino.\" .It 63*86d7f5d3SJohn Marino.\" If the battery-backed clock does not have a valid time, and 64*86d7f5d3SJohn Marino.\" the time provided in 65*86d7f5d3SJohn Marino.\" .Fa base 66*86d7f5d3SJohn Marino.\" is within reason, 67*86d7f5d3SJohn Marino.\" .Fa base 68*86d7f5d3SJohn Marino.\" is used as the current time. 69*86d7f5d3SJohn Marino.\" .It 70*86d7f5d3SJohn Marino.\" If the battery-backed clock appears invalid, and 71*86d7f5d3SJohn Marino.\" .Fa base 72*86d7f5d3SJohn Marino.\" appears non-sensical or was not provided (was given as zero), 73*86d7f5d3SJohn Marino.\" a arbitrary base (typically some time in the late 1970s) 74*86d7f5d3SJohn Marino.\" will be used. 75*86d7f5d3SJohn Marino.It 76*86d7f5d3SJohn MarinoIf the battery-backed clock does not have a valid time, 77*86d7f5d3SJohn Marinothe time provided in 78*86d7f5d3SJohn Marino.Fa base 79*86d7f5d3SJohn Marinowill be used. 80*86d7f5d3SJohn Marino.El 81*86d7f5d3SJohn Marino.Pp 82*86d7f5d3SJohn MarinoOnce a system time has been determined, it is stored in the 83*86d7f5d3SJohn Marino.Va time 84*86d7f5d3SJohn Marinovariable. 85*86d7f5d3SJohn Marino.Sh DIAGNOSTICS 86*86d7f5d3SJohn MarinoThe 87*86d7f5d3SJohn Marino.Fn inittodr 88*86d7f5d3SJohn Marinofunction prints diagnostic messages if it has trouble figuring 89*86d7f5d3SJohn Marinoout the system time. Conditions that can cause diagnostic 90*86d7f5d3SJohn Marinomessages to be printed include: 91*86d7f5d3SJohn Marino.Bl -bullet 92*86d7f5d3SJohn Marino.It 93*86d7f5d3SJohn MarinoThe battery-backed clock's time appears nonsensical. 94*86d7f5d3SJohn Marino.\" .It 95*86d7f5d3SJohn Marino.\" The 96*86d7f5d3SJohn Marino.\" .Fa base 97*86d7f5d3SJohn Marino.\" time appears nonsensical. 98*86d7f5d3SJohn Marino.\" .It 99*86d7f5d3SJohn Marino.\" The 100*86d7f5d3SJohn Marino.\" .Fa base 101*86d7f5d3SJohn Marino.\" time and the battery-backed clock's time differ by a large amount. 102*86d7f5d3SJohn Marino.El 103*86d7f5d3SJohn Marino.Sh SEE ALSO 104*86d7f5d3SJohn Marino.Xr resettodr 9 , 105*86d7f5d3SJohn Marino.Xr time 9 106*86d7f5d3SJohn Marino.Sh BUGS 107*86d7f5d3SJohn MarinoOn many systems, 108*86d7f5d3SJohn Marino.Fn inittodr 109*86d7f5d3SJohn Marinohas to convert from 110*86d7f5d3SJohn Marinoa time expressed in terms of year, month, day, hours, minutes, 111*86d7f5d3SJohn Marinoand seconds to 112*86d7f5d3SJohn Marino.Va time , 113*86d7f5d3SJohn Marinoexpressed in seconds. Many of the implementations could share code, 114*86d7f5d3SJohn Marinobut do not. 115*86d7f5d3SJohn Marino.Pp 116*86d7f5d3SJohn MarinoEach system's heuristics for picking the correct time are slightly 117*86d7f5d3SJohn Marinodifferent. 118*86d7f5d3SJohn Marino.Pp 119*86d7f5d3SJohn MarinoThe 120*86d7f5d3SJohn Marino.Dx 121*86d7f5d3SJohn Marinoimplementation should do a better job of validating the time provided in 122*86d7f5d3SJohn Marino.Fa base 123*86d7f5d3SJohn Marinowhen the battery-backed clock is unusable. Currently it unconditionally 124*86d7f5d3SJohn Marinosets the system clock to this value. 125