xref: /freebsd/share/man/man9/inittodr.9 (revision 32eef9aeb1f39a1623cea55da147c89abbd5b9a5)
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.\"
327f3dea24SPeter Wemm.\" $FreeBSD$
335bf6ab83SNik Clayton.\"
344035c910SMike Pritchard.Dd March 22, 1997
354035c910SMike Pritchard.Dt INITTODR 9
363d45e180SRuslan Ermilov.Os
374035c910SMike Pritchard.Sh NAME
384035c910SMike Pritchard.Nm inittodr
394035c910SMike Pritchard.Nd initialize system time
404035c910SMike Pritchard.Sh SYNOPSIS
4132eef9aeSRuslan Ermilov.In sys/types.h
4232eef9aeSRuslan Ermilov.In sys/systm.h
434035c910SMike Pritchard.Ft void
444035c910SMike Pritchard.Fn inittodr "time_t base"
454035c910SMike Pritchard.Sh DESCRIPTION
464035c910SMike PritchardThe
474035c910SMike Pritchard.Fn inittodr
484035c910SMike Pritchardfunction determines the time and sets the system clock.
494035c910SMike PritchardIt tries to pick the correct time using a set of heuristics that examine
504035c910SMike Pritchardthe system's battery backed clock and the time obtained from the root
514035c910SMike Pritchardfile system, as given in
524035c910SMike Pritchard.Fa base .
534035c910SMike PritchardHow the
544035c910SMike Pritchard.Fa base
554035c910SMike Pritchardvalue is obtained will vary depending on the
564035c910SMike Pritchardroot file system type.
574035c910SMike PritchardThe heuristics used include:
584035c910SMike Pritchard.Bl -bullet
594035c910SMike Pritchard.It
604035c910SMike PritchardIf the battery-backed clock has a valid time, it is used.
614035c910SMike Pritchard.\" .It
624035c910SMike Pritchard.\" If the battery-backed clock does not have a valid time, and
634035c910SMike Pritchard.\" the time provided in
644035c910SMike Pritchard.\" .Fa base
654035c910SMike Pritchard.\" is within reason,
664035c910SMike Pritchard.\" .Fa base
674035c910SMike Pritchard.\" is used as the current time.
684035c910SMike Pritchard.\" .It
694035c910SMike Pritchard.\" If the battery-backed clock appears invalid, and
704035c910SMike Pritchard.\" .Fa base
714035c910SMike Pritchard.\" appears non-sensical or was not provided (was given as zero),
724035c910SMike Pritchard.\" a arbitrary base (typically some time in the late 1970s)
734035c910SMike Pritchard.\" will be used.
744035c910SMike Pritchard.It
754035c910SMike PritchardIf the battery-backed clock does not have a valid time,
764035c910SMike Pritchardthe time provided in
774035c910SMike Pritchard.Fa base
784035c910SMike Pritchardwill be used.
794035c910SMike Pritchard.El
804035c910SMike Pritchard.Pp
814035c910SMike PritchardOnce a system time has been determined, it is stored in the
824035c910SMike Pritchard.Va time
834035c910SMike Pritchardvariable.
844035c910SMike Pritchard.Sh DIAGNOSTICS
854035c910SMike PritchardThe
864035c910SMike Pritchard.Fn inittodr
874035c910SMike Pritchardfunction prints diagnostic messages if it has trouble figuring
884035c910SMike Pritchardout the system time.  Conditions that can cause diagnostic
894035c910SMike Pritchardmessages to be printed include:
904035c910SMike Pritchard.Bl -bullet
914035c910SMike Pritchard.It
924035c910SMike PritchardThe battery-backed clock's time appears nonsensical.
934035c910SMike Pritchard.\" .It
944035c910SMike Pritchard.\" The
954035c910SMike Pritchard.\" .Fa base
964035c910SMike Pritchard.\" time appears nonsensical.
974035c910SMike Pritchard.\" .It
984035c910SMike Pritchard.\" The
994035c910SMike Pritchard.\" .Fa base
1004035c910SMike Pritchard.\" time and the battery-backed clock's time differ by a large amount.
1014035c910SMike Pritchard.El
1024035c910SMike Pritchard.Sh SEE ALSO
1034035c910SMike Pritchard.Xr resettodr 9 ,
1044035c910SMike Pritchard.Xr time 9
1054035c910SMike Pritchard.Sh BUGS
1064035c910SMike PritchardOn many systems,
1074035c910SMike Pritchard.Fn inittodr
1084035c910SMike Pritchardhas to convert from
1094035c910SMike Pritcharda time expressed in terms of year, month, day, hours, minutes,
1104035c910SMike Pritchardand seconds to
1114035c910SMike Pritchard.Va time ,
1124035c910SMike Pritchardexpressed in seconds.  Many of the implementations could share code,
1134035c910SMike Pritchardbut do not.
1144035c910SMike Pritchard.Pp
1154035c910SMike PritchardEach system's heuristics for picking the correct time are slightly
1164035c910SMike Pritcharddifferent.
1174035c910SMike Pritchard.Pp
1184035c910SMike PritchardThe
119b5c508fbSRuslan Ermilov.Fx
1204035c910SMike Pritchardimplementation should do a better job of validating the time provided in
1214035c910SMike Pritchard.Fa base
1224035c910SMike Pritchardwhen the battery-backed clock is unusable.  Currently it unconditionally
1234035c910SMike Pritchardsets the system clock to this value.
124