xref: /freebsd/share/man/man9/inittodr.9 (revision 4035c9100d44c4f0676708ca86174c132392aed6)
14035c910SMike Pritchard.\"	$NetBSD: inittodr.9,v 1.2 1996/03/27 21:16:06 jtc Exp $
24035c910SMike Pritchard.\"
34035c910SMike Pritchard.\" Copyright (c) 1994 Christopher G. Demetriou
44035c910SMike Pritchard.\" All rights reserved.
54035c910SMike Pritchard.\"
64035c910SMike Pritchard.\" Redistribution and use in source and binary forms, with or without
74035c910SMike Pritchard.\" modification, are permitted provided that the following conditions
84035c910SMike Pritchard.\" are met:
94035c910SMike Pritchard.\" 1. Redistributions of source code must retain the above copyright
104035c910SMike Pritchard.\"    notice, this list of conditions and the following disclaimer.
114035c910SMike Pritchard.\" 2. Redistributions in binary form must reproduce the above copyright
124035c910SMike Pritchard.\"    notice, this list of conditions and the following disclaimer in the
134035c910SMike Pritchard.\"    documentation and/or other materials provided with the distribution.
144035c910SMike Pritchard.\" 3. All advertising materials mentioning features or use of this software
154035c910SMike Pritchard.\"    must display the following acknowledgement:
164035c910SMike Pritchard.\"      This product includes software developed by Christopher G. Demetriou
174035c910SMike Pritchard.\"      for the NetBSD Project.
184035c910SMike Pritchard.\" 3. The name of the author may not be used to endorse or promote products
194035c910SMike Pritchard.\"    derived from this software without specific prior written permission
204035c910SMike Pritchard.\"
214035c910SMike Pritchard.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
224035c910SMike Pritchard.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
234035c910SMike Pritchard.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
244035c910SMike Pritchard.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
254035c910SMike Pritchard.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
264035c910SMike Pritchard.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
274035c910SMike Pritchard.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
284035c910SMike Pritchard.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
294035c910SMike Pritchard.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
304035c910SMike Pritchard.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
314035c910SMike Pritchard.\"
324035c910SMike Pritchard.Dd March 22, 1997
334035c910SMike Pritchard.Dt INITTODR 9
344035c910SMike Pritchard.Os FreeBSD
354035c910SMike Pritchard.Sh NAME
364035c910SMike Pritchard.Nm inittodr
374035c910SMike Pritchard.Nd initialize system time
384035c910SMike Pritchard.Sh SYNOPSIS
394035c910SMike Pritchard.Ft void
404035c910SMike Pritchard.Fn inittodr "time_t base"
414035c910SMike Pritchard.Sh DESCRIPTION
424035c910SMike PritchardThe
434035c910SMike Pritchard.Fn inittodr
444035c910SMike Pritchardfunction determines the time and sets the system clock.
454035c910SMike PritchardIt tries to pick the correct time using a set of heuristics that examine
464035c910SMike Pritchardthe system's battery backed clock and the time obtained from the root
474035c910SMike Pritchardfile system, as given in
484035c910SMike Pritchard.Fa base .
494035c910SMike PritchardHow the
504035c910SMike Pritchard.Fa base
514035c910SMike Pritchardvalue is obtained will vary depending on the
524035c910SMike Pritchardroot file system type.
534035c910SMike PritchardThe heuristics used include:
544035c910SMike Pritchard.Bl -bullet
554035c910SMike Pritchard.It
564035c910SMike PritchardIf the battery-backed clock has a valid time, it is used.
574035c910SMike Pritchard.\" .It
584035c910SMike Pritchard.\" If the battery-backed clock does not have a valid time, and
594035c910SMike Pritchard.\" the time provided in
604035c910SMike Pritchard.\" .Fa base
614035c910SMike Pritchard.\" is within reason,
624035c910SMike Pritchard.\" .Fa base
634035c910SMike Pritchard.\" is used as the current time.
644035c910SMike Pritchard.\" .It
654035c910SMike Pritchard.\" If the battery-backed clock appears invalid, and
664035c910SMike Pritchard.\" .Fa base
674035c910SMike Pritchard.\" appears non-sensical or was not provided (was given as zero),
684035c910SMike Pritchard.\" a arbitrary base (typically some time in the late 1970s)
694035c910SMike Pritchard.\" will be used.
704035c910SMike Pritchard.It
714035c910SMike PritchardIf the battery-backed clock does not have a valid time,
724035c910SMike Pritchardthe time provided in
734035c910SMike Pritchard.Fa base
744035c910SMike Pritchardwill be used.
754035c910SMike Pritchard.El
764035c910SMike Pritchard.Pp
774035c910SMike PritchardOnce a system time has been determined, it is stored in the
784035c910SMike Pritchard.Va time
794035c910SMike Pritchardvariable.
804035c910SMike Pritchard.Sh DIAGNOSTICS
814035c910SMike PritchardThe
824035c910SMike Pritchard.Fn inittodr
834035c910SMike Pritchardfunction prints diagnostic messages if it has trouble figuring
844035c910SMike Pritchardout the system time.  Conditions that can cause diagnostic
854035c910SMike Pritchardmessages to be printed include:
864035c910SMike Pritchard.Bl -bullet
874035c910SMike Pritchard.It
884035c910SMike PritchardThe battery-backed clock's time appears nonsensical.
894035c910SMike Pritchard.\" .It
904035c910SMike Pritchard.\" The
914035c910SMike Pritchard.\" .Fa base
924035c910SMike Pritchard.\" time appears nonsensical.
934035c910SMike Pritchard.\" .It
944035c910SMike Pritchard.\" The
954035c910SMike Pritchard.\" .Fa base
964035c910SMike Pritchard.\" time and the battery-backed clock's time differ by a large amount.
974035c910SMike Pritchard.El
984035c910SMike Pritchard.Sh SEE ALSO
994035c910SMike Pritchard.Xr resettodr 9 ,
1004035c910SMike Pritchard.Xr time 9
1014035c910SMike Pritchard.Sh BUGS
1024035c910SMike PritchardOn many systems,
1034035c910SMike Pritchard.Fn inittodr
1044035c910SMike Pritchardhas to convert from
1054035c910SMike Pritcharda time expressed in terms of year, month, day, hours, minutes,
1064035c910SMike Pritchardand seconds to
1074035c910SMike Pritchard.Va time ,
1084035c910SMike Pritchardexpressed in seconds.  Many of the implementations could share code,
1094035c910SMike Pritchardbut do not.
1104035c910SMike Pritchard.Pp
1114035c910SMike PritchardEach system's heuristics for picking the correct time are slightly
1124035c910SMike Pritcharddifferent.
1134035c910SMike Pritchard.Pp
1144035c910SMike PritchardThe
1154035c910SMike Pritchard.Tn FreeBSD
1164035c910SMike Pritchardimplementation should do a better job of validating the time provided in
1174035c910SMike Pritchard.Fa base
1184035c910SMike Pritchardwhen the battery-backed clock is unusable.  Currently it unconditionally
1194035c910SMike Pritchardsets the system clock to this value.
120