]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/adjtimex.2
Maintenance scripts
[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@gmx.net>
28 .\"
29 .TH ADJTIMEX 2 2004-05-27 "Linux 2.6.6" "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 .B 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 .RS
48 .nf
49 struct timex {
50 int modes; /* mode selector */
51 long offset; /* time offset (usec) */
52 long freq; /* frequency offset (scaled ppm) */
53 long maxerror; /* maximum error (usec) */
54 long esterror; /* estimated error (usec) */
55 int status; /* clock command/status */
56 long constant; /* pll time constant */
57 long precision; /* clock precision (usec) (read only) */
58 long tolerance; /* clock frequency tolerance (ppm)
59 (read only) */
60 struct timeval time; /* current time (read only) */
61 long tick; /* usecs between clock ticks */
62 };
63 .fi
64 .RE
65 .PP
66 The
67 .I modes
68 field determines which parameters, if any, to set.
69 It may contain a
70 .RI bitwise- or
71 combination of zero or more of the following bits:
72 .PP
73 .RS
74 .nf
75 #define ADJ_OFFSET 0x0001 /* time offset */
76 #define ADJ_FREQUENCY 0x0002 /* frequency offset */
77 #define ADJ_MAXERROR 0x0004 /* maximum time error */
78 #define ADJ_ESTERROR 0x0008 /* estimated time error */
79 #define ADJ_STATUS 0x0010 /* clock status */
80 #define ADJ_TIMECONST 0x0020 /* pll time constant */
81 #define ADJ_TICK 0x4000 /* tick value */
82 #define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
83 .fi
84 .RE
85 .PP
86 Ordinary users are restricted to a zero value for
87 .IR mode .
88 Only the superuser may set any parameters.
89 .br
90 .ne 12v
91 .SH "RETURN VALUE"
92 On success,
93 .B adjtimex
94 returns the clock state:
95 .PP
96 .RS
97 .nf
98 #define TIME_OK 0 /* clock synchronized */
99 #define TIME_INS 1 /* insert leap second */
100 #define TIME_DEL 2 /* delete leap second */
101 #define TIME_OOP 3 /* leap second in progress */
102 #define TIME_WAIT 4 /* leap second has occurred */
103 #define TIME_BAD 5 /* clock not synchronized */
104 .fi
105 .RE
106 .PP
107 On failure,
108 .B adjtimex
109 returns \-1 and sets
110 .IR errno .
111 .SH ERRORS
112 .TP
113 .B EFAULT
114 .I buf
115 does not point to writable memory.
116 .TP
117 .B EINVAL
118 An attempt is made to set
119 .I buf.offset
120 to a value outside the range \-131071 to +131071,
121 or to set
122 .I buf.status
123 to a value other than those listed above,
124 or to set
125 .I buf.tick
126 to a value outside the range
127 .RB 900000/ HZ
128 to
129 .RB 1100000/ HZ ,
130 where
131 .B HZ
132 is the system timer interrupt frequency.
133 .TP
134 .B EPERM
135 .I buf.mode
136 is non-zero and the caller does not have sufficient privilege.
137 Under Linux the
138 .B CAP_SYS_TIME
139 capability is required.
140 .SH "CONFORMING TO"
141 \fBadjtimex\fP is Linux specific and should not be used in programs
142 intended to be portable. There is a similar but less general call
143 \fBadjtime\fR in SVr4.
144 .SH "SEE ALSO"
145 .BR settimeofday (2),
146 .BR capabilities (7)