xref: /dflybsd-src/share/man/man9/inittodr.9 (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino.\"	$NetBSD: inittodr.9,v 1.2 1996/03/27 21:16:06 jtc Exp $
286d7f5d3SJohn Marino.\"
386d7f5d3SJohn Marino.\" Copyright (c) 1994 Christopher G. Demetriou
486d7f5d3SJohn Marino.\" All rights reserved.
586d7f5d3SJohn Marino.\"
686d7f5d3SJohn Marino.\" Redistribution and use in source and binary forms, with or without
786d7f5d3SJohn Marino.\" modification, are permitted provided that the following conditions
886d7f5d3SJohn Marino.\" are met:
986d7f5d3SJohn Marino.\" 1. Redistributions of source code must retain the above copyright
1086d7f5d3SJohn Marino.\"    notice, this list of conditions and the following disclaimer.
1186d7f5d3SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright
1286d7f5d3SJohn Marino.\"    notice, this list of conditions and the following disclaimer in the
1386d7f5d3SJohn Marino.\"    documentation and/or other materials provided with the distribution.
1486d7f5d3SJohn Marino.\" 3. All advertising materials mentioning features or use of this software
1586d7f5d3SJohn Marino.\"    must display the following acknowledgement:
1686d7f5d3SJohn Marino.\"      This product includes software developed by Christopher G. Demetriou
1786d7f5d3SJohn Marino.\"      for the NetBSD Project.
1886d7f5d3SJohn Marino.\" 3. The name of the author may not be used to endorse or promote products
1986d7f5d3SJohn Marino.\"    derived from this software without specific prior written permission
2086d7f5d3SJohn Marino.\"
2186d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2286d7f5d3SJohn Marino.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2386d7f5d3SJohn Marino.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2486d7f5d3SJohn Marino.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2586d7f5d3SJohn Marino.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2686d7f5d3SJohn Marino.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2786d7f5d3SJohn Marino.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2886d7f5d3SJohn Marino.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2986d7f5d3SJohn Marino.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3086d7f5d3SJohn Marino.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3186d7f5d3SJohn Marino.\"
3286d7f5d3SJohn Marino.\" $FreeBSD: src/share/man/man9/inittodr.9,v 1.4.2.4 2001/12/17 11:30:18 ru Exp $
3386d7f5d3SJohn Marino.\" $DragonFly: src/share/man/man9/inittodr.9,v 1.3 2004/03/11 12:28:57 hmp Exp $
3486d7f5d3SJohn Marino.\"
3586d7f5d3SJohn Marino.Dd March 22, 1997
3686d7f5d3SJohn Marino.Dt INITTODR 9
3786d7f5d3SJohn Marino.Os
3886d7f5d3SJohn Marino.Sh NAME
3986d7f5d3SJohn Marino.Nm inittodr
4086d7f5d3SJohn Marino.Nd initialize system time
4186d7f5d3SJohn Marino.Sh SYNOPSIS
4286d7f5d3SJohn Marino.In sys/types.h
4386d7f5d3SJohn Marino.In sys/systm.h
4486d7f5d3SJohn Marino.Ft void
4586d7f5d3SJohn Marino.Fn inittodr "time_t base"
4686d7f5d3SJohn Marino.Sh DESCRIPTION
4786d7f5d3SJohn MarinoThe
4886d7f5d3SJohn Marino.Fn inittodr
4986d7f5d3SJohn Marinofunction determines the time and sets the system clock.
5086d7f5d3SJohn MarinoIt tries to pick the correct time using a set of heuristics that examine
5186d7f5d3SJohn Marinothe system's battery backed clock and the time obtained from the root
5286d7f5d3SJohn Marinofile system, as given in
5386d7f5d3SJohn Marino.Fa base .
5486d7f5d3SJohn MarinoHow the
5586d7f5d3SJohn Marino.Fa base
5686d7f5d3SJohn Marinovalue is obtained will vary depending on the
5786d7f5d3SJohn Marinoroot file system type.
5886d7f5d3SJohn MarinoThe heuristics used include:
5986d7f5d3SJohn Marino.Bl -bullet
6086d7f5d3SJohn Marino.It
6186d7f5d3SJohn MarinoIf the battery-backed clock has a valid time, it is used.
6286d7f5d3SJohn Marino.\" .It
6386d7f5d3SJohn Marino.\" If the battery-backed clock does not have a valid time, and
6486d7f5d3SJohn Marino.\" the time provided in
6586d7f5d3SJohn Marino.\" .Fa base
6686d7f5d3SJohn Marino.\" is within reason,
6786d7f5d3SJohn Marino.\" .Fa base
6886d7f5d3SJohn Marino.\" is used as the current time.
6986d7f5d3SJohn Marino.\" .It
7086d7f5d3SJohn Marino.\" If the battery-backed clock appears invalid, and
7186d7f5d3SJohn Marino.\" .Fa base
7286d7f5d3SJohn Marino.\" appears non-sensical or was not provided (was given as zero),
7386d7f5d3SJohn Marino.\" a arbitrary base (typically some time in the late 1970s)
7486d7f5d3SJohn Marino.\" will be used.
7586d7f5d3SJohn Marino.It
7686d7f5d3SJohn MarinoIf the battery-backed clock does not have a valid time,
7786d7f5d3SJohn Marinothe time provided in
7886d7f5d3SJohn Marino.Fa base
7986d7f5d3SJohn Marinowill be used.
8086d7f5d3SJohn Marino.El
8186d7f5d3SJohn Marino.Pp
8286d7f5d3SJohn MarinoOnce a system time has been determined, it is stored in the
8386d7f5d3SJohn Marino.Va time
8486d7f5d3SJohn Marinovariable.
8586d7f5d3SJohn Marino.Sh DIAGNOSTICS
8686d7f5d3SJohn MarinoThe
8786d7f5d3SJohn Marino.Fn inittodr
8886d7f5d3SJohn Marinofunction prints diagnostic messages if it has trouble figuring
8986d7f5d3SJohn Marinoout the system time.  Conditions that can cause diagnostic
9086d7f5d3SJohn Marinomessages to be printed include:
9186d7f5d3SJohn Marino.Bl -bullet
9286d7f5d3SJohn Marino.It
9386d7f5d3SJohn MarinoThe battery-backed clock's time appears nonsensical.
9486d7f5d3SJohn Marino.\" .It
9586d7f5d3SJohn Marino.\" The
9686d7f5d3SJohn Marino.\" .Fa base
9786d7f5d3SJohn Marino.\" time appears nonsensical.
9886d7f5d3SJohn Marino.\" .It
9986d7f5d3SJohn Marino.\" The
10086d7f5d3SJohn Marino.\" .Fa base
10186d7f5d3SJohn Marino.\" time and the battery-backed clock's time differ by a large amount.
10286d7f5d3SJohn Marino.El
10386d7f5d3SJohn Marino.Sh SEE ALSO
10486d7f5d3SJohn Marino.Xr resettodr 9 ,
10586d7f5d3SJohn Marino.Xr time 9
10686d7f5d3SJohn Marino.Sh BUGS
10786d7f5d3SJohn MarinoOn many systems,
10886d7f5d3SJohn Marino.Fn inittodr
10986d7f5d3SJohn Marinohas to convert from
11086d7f5d3SJohn Marinoa time expressed in terms of year, month, day, hours, minutes,
11186d7f5d3SJohn Marinoand seconds to
11286d7f5d3SJohn Marino.Va time ,
11386d7f5d3SJohn Marinoexpressed in seconds.  Many of the implementations could share code,
11486d7f5d3SJohn Marinobut do not.
11586d7f5d3SJohn Marino.Pp
11686d7f5d3SJohn MarinoEach system's heuristics for picking the correct time are slightly
11786d7f5d3SJohn Marinodifferent.
11886d7f5d3SJohn Marino.Pp
11986d7f5d3SJohn MarinoThe
12086d7f5d3SJohn Marino.Dx
12186d7f5d3SJohn Marinoimplementation should do a better job of validating the time provided in
12286d7f5d3SJohn Marino.Fa base
12386d7f5d3SJohn Marinowhen the battery-backed clock is unusable.  Currently it unconditionally
12486d7f5d3SJohn Marinosets the system clock to this value.
125