]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/adjtimex.2
adjtimex.2: ffix
[thirdparty/man-pages.git] / man2 / adjtimex.2
1 .\" Copyright (c) 1995 Michael Chastain (mec@shell.portal.com), 15 April 1995.
2 .\"
3 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\"
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
13 .\"
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 .\" GNU General Public License for more details.
18 .\"
19 .\" You should have received a copy of the GNU General Public
20 .\" License along with this manual; if not, see
21 .\" <http://www.gnu.org/licenses/>.
22 .\" %%%LICENSE_END
23 .\"
24 .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
25 .\" Modified 1997-07-30 by Paul Slootman <paul@wurtel.demon.nl>
26 .\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com>
27 .\"
28 .\" FIXME Document ADJ_MICRO and ADJ_NANO (added in Linux 2.6.26)
29 .\" commit eea83d896e318bda54be2d2770d2c5d6668d11db
30 .\" Author: Roman Zippel <zippel@linux-m68k.org>
31 .\"
32 .\" FIXME Document ADJ_SETOFFSET (added in Linux 2.6.39)
33 .\" commit 094aa1881fdc1b8889b442eb3511b31f3ec2b762
34 .\" Author: Richard Cochran <richardcochran@gmail.com>
35 .\"
36 .TH ADJTIMEX 2 2014-05-28 "Linux" "Linux Programmer's Manual"
37 .SH NAME
38 adjtimex \- tune kernel clock
39 .SH SYNOPSIS
40 .nf
41 .BR "#define _BSD_SOURCE" " /* See feature_test_macros(7) */"
42 .B #include <sys/timex.h>
43
44 .BI "int adjtimex(struct timex *" "buf" );
45 .fi
46 .SH DESCRIPTION
47 Linux uses David L. Mills' clock adjustment algorithm (see RFC\ 1305).
48 The system call
49 .BR adjtimex ()
50 reads and optionally sets adjustment parameters for this algorithm.
51 It takes a pointer to a
52 .I timex
53 structure, updates kernel parameters from field values,
54 and returns the same structure with current kernel values.
55 This structure is declared as follows:
56 .PP
57 .in +4n
58 .nf
59 struct timex {
60 int modes; /* mode selector */
61 long offset; /* time offset (usec) */
62 long freq; /* frequency offset (scaled ppm) */
63 .\" FIXME What is the scaling unit of timex.freq? 2^16 ?
64 long maxerror; /* maximum error (usec) */
65 long esterror; /* estimated error (usec) */
66 int status; /* clock command/status */
67 long constant; /* pll time constant */
68 long precision; /* clock precision (usec) (read-only) */
69 long tolerance; /* clock frequency tolerance (ppm)
70 (read-only) */
71 struct timeval time; /* current time (read-only) */
72 long tick; /* usecs between clock ticks */
73 long ppsfreq; /* pps frequency (scaled ppm) (read-only) */
74 long jitter; /* pps jitter (usec) (read-only) */
75 int shift; /* interval duration (sec) (read-only) */
76 long stabil; /* pps stability (scaled ppm) (read-only) */
77 long jitcnt; /* jitter limit exceeded (read-only) */
78 long calcnt; /* calibration intervals (read-only) */
79 long errcnt; /* calibration errors (read-only) */
80 long stbcnt; /* stability limit exceeded (read-only) */
81 int tai; /* TAI offset (sec) (read-only) */
82 };
83 .fi
84 .in
85 .PP
86 The
87 .I modes
88 field determines which parameters, if any, to set.
89 It may contain a
90 .RI bitwise- or
91 combination of zero or more of the following bits:
92 .PP
93 .in +4n
94 .nf
95 #define ADJ_OFFSET 0x0001 /* time offset */
96 #define ADJ_FREQUENCY 0x0002 /* frequency offset */
97 #define ADJ_MAXERROR 0x0004 /* maximum time error */
98 #define ADJ_ESTERROR 0x0008 /* estimated time error */
99 #define ADJ_STATUS 0x0010 /* clock status */
100 #define ADJ_TIMECONST 0x0020 /* pll time constant */
101 #define ADJ_TAI 0x0080 /* TAI offset (since Linux 2.6.26) */
102 #define ADJ_TICK 0x4000 /* tick value */
103 #define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime() */
104 .fi
105 .in
106 .PP
107 Ordinary users are restricted to a zero value for
108 .IR modes .
109 Only the superuser may set any parameters.
110
111 In the case of
112 .BR ADJ_TAI ,
113 as
114 .I buf->tai
115 is read-only, the new value is passed through
116 .IR buf->constant .
117 Therefore
118 .BR ADJ_TAI
119 should not be used in conjunction with
120 .BR ADJ_TIMECONST ,
121 since the latter mode also employs the
122 .IR buf->constant
123 field.
124 .PP
125 Support for TAI (Atomic International Time)
126 was added
127 .\" commit 153b5d054ac2d98ea0d86504884326b6777f683d
128 in Linux 2.6.26.
129 For a complete explanation of TAI
130 and the difference between TAI and UTC, see
131 .UR http://www.bipm.org/en/bipm/tai/tai.html
132 .I BIPM
133 .UE )
134 .SH RETURN VALUE
135 On success,
136 .BR adjtimex ()
137 returns the clock state:
138 .PP
139 .in +4n
140 .nf
141 #define TIME_OK 0 /* clock synchronized */
142 #define TIME_INS 1 /* insert leap second */
143 #define TIME_DEL 2 /* delete leap second */
144 #define TIME_OOP 3 /* leap second in progress */
145 #define TIME_WAIT 4 /* leap second has occurred */
146 #define TIME_BAD 5 /* clock not synchronized */
147 .fi
148 .in
149 .PP
150 On failure,
151 .BR adjtimex ()
152 returns \-1 and sets
153 .IR errno .
154 .SH ERRORS
155 .TP
156 .B EFAULT
157 .I buf
158 does not point to writable memory.
159 .TP
160 .B EINVAL
161 An attempt is made to set
162 .I buf.offset
163 to a value outside the range \-131071 to +131071,
164 or to set
165 .I buf.status
166 to a value other than those listed above,
167 or to set
168 .I buf.tick
169 to a value outside the range
170 .RB 900000/ HZ
171 to
172 .RB 1100000/ HZ ,
173 where
174 .B HZ
175 is the system timer interrupt frequency.
176 .TP
177 .B EPERM
178 .I buf.modes
179 is nonzero and the caller does not have sufficient privilege.
180 Under Linux the
181 .B CAP_SYS_TIME
182 capability is required.
183 .SH CONFORMING TO
184 .BR adjtimex ()
185 is Linux-specific and should not be used in programs
186 intended to be portable.
187 See
188 .BR adjtime (3)
189 for a more portable, but less flexible,
190 method of adjusting the system clock.
191 .SH SEE ALSO
192 .BR settimeofday (2),
193 .BR adjtime (3),
194 .BR capabilities (7),
195 .BR time (7),
196 .BR adjtimex (8)