]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/adjtimex.2
intro.1, time.1, adjtimex.2, capget.2, eventfd.2, fcntl.2, getrlimit.2, getsockopt...
[thirdparty/man-pages.git] / man2 / adjtimex.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (c) 1995 Michael Chastain (mec@shell.portal.com), 15 April 1995.
4 .\"
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
9 .\"
10 .\" The GNU General Public License's references to "object code"
11 .\" and "executables" are to be interpreted as the output of any
12 .\" document formatting or typesetting system, including
13 .\" intermediate and printed output.
14 .\"
15 .\" This manual is distributed in the hope that it will be useful,
16 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 .\" GNU General Public License for more details.
19 .\"
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual; if not, write to the Free
22 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
23 .\" USA.
24 .\"
25 .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
26 .\" Modified 1997-07-30 by Paul Slootman <paul@wurtel.demon.nl>
27 .\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com>
28 .\"
29 .TH ADJTIMEX 2 2004-05-27 "Linux" "Linux Programmer's Manual"
30 .SH NAME
31 adjtimex \- tune kernel clock
32 .SH SYNOPSIS
33 .B #include <sys/timex.h>
34 .sp
35 .BI "int adjtimex(struct timex *" "buf" );
36 .SH DESCRIPTION
37 Linux uses David L. Mills' clock adjustment algorithm (see RFC\ 1305).
38 The system call
39 .BR adjtimex ()
40 reads and optionally sets adjustment parameters for this algorithm.
41 It takes a pointer to a
42 .I timex
43 structure, updates kernel parameters from field values,
44 and returns the same structure with current kernel values.
45 This structure is declared as follows:
46 .PP
47 .in +4n
48 .nf
49 struct timex {
50 int modes; /* mode selector */
51 long offset; /* time offset (usec) */
52 long freq; /* frequency offset (scaled ppm) */
53 .\" FIXME -- what is the scaling unit? 2^16 ?
54 long maxerror; /* maximum error (usec) */
55 long esterror; /* estimated error (usec) */
56 int status; /* clock command/status */
57 long constant; /* pll time constant */
58 long precision; /* clock precision (usec) (read-only) */
59 long tolerance; /* clock frequency tolerance (ppm)
60 (read-only) */
61 struct timeval time; /* current time (read-only) */
62 long tick; /* usecs between clock ticks */
63 };
64 .fi
65 .in
66 .PP
67 The
68 .I modes
69 field determines which parameters, if any, to set.
70 It may contain a
71 .RI bitwise- or
72 combination of zero or more of the following bits:
73 .PP
74 .in +4n
75 .nf
76 #define ADJ_OFFSET 0x0001 /* time offset */
77 #define ADJ_FREQUENCY 0x0002 /* frequency offset */
78 #define ADJ_MAXERROR 0x0004 /* maximum time error */
79 #define ADJ_ESTERROR 0x0008 /* estimated time error */
80 #define ADJ_STATUS 0x0010 /* clock status */
81 #define ADJ_TIMECONST 0x0020 /* pll time constant */
82 #define ADJ_TICK 0x4000 /* tick value */
83 #define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime() */
84 .fi
85 .in
86 .PP
87 Ordinary users are restricted to a zero value for
88 .IR mode .
89 Only the superuser may set any parameters.
90 .br
91 .ne 12v
92 .SH "RETURN VALUE"
93 On success,
94 .BR adjtimex ()
95 returns the clock state:
96 .PP
97 .in +4n
98 .nf
99 #define TIME_OK 0 /* clock synchronized */
100 #define TIME_INS 1 /* insert leap second */
101 #define TIME_DEL 2 /* delete leap second */
102 #define TIME_OOP 3 /* leap second in progress */
103 #define TIME_WAIT 4 /* leap second has occurred */
104 #define TIME_BAD 5 /* clock not synchronized */
105 .fi
106 .in
107 .PP
108 On failure,
109 .BR adjtimex ()
110 returns \-1 and sets
111 .IR errno .
112 .SH ERRORS
113 .TP
114 .B EFAULT
115 .I buf
116 does not point to writable memory.
117 .TP
118 .B EINVAL
119 An attempt is made to set
120 .I buf.offset
121 to a value outside the range \-131071 to +131071,
122 or to set
123 .I buf.status
124 to a value other than those listed above,
125 or to set
126 .I buf.tick
127 to a value outside the range
128 .RB 900000/ HZ
129 to
130 .RB 1100000/ HZ ,
131 where
132 .B HZ
133 is the system timer interrupt frequency.
134 .TP
135 .B EPERM
136 .I buf.mode
137 is nonzero and the caller does not have sufficient privilege.
138 Under Linux the
139 .B CAP_SYS_TIME
140 capability is required.
141 .SH "CONFORMING TO"
142 .BR adjtimex ()
143 is Linux-specific and should not be used in programs
144 intended to be portable.
145 See
146 .BR adjtime (3)
147 for a more portable, but less flexible,
148 method of adjusting the system clock.
149 .SH "SEE ALSO"
150 .BR settimeofday (2),
151 .BR adjtime (3),
152 .BR capabilities (7),
153 .BR time (7)