]>
Commit | Line | Data |
---|---|---|
fea681da MK |
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> | |
c11b1abf | 27 | .\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 28 | .\" |
d9343c5c | 29 | .TH ADJTIMEX 2 2004-05-27 "Linux" "Linux Programmer's Manual" |
fea681da MK |
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 | |
331da7c3 | 37 | Linux uses David L. Mills' clock adjustment algorithm (see RFC\ 1305). |
fea681da | 38 | The system call |
e511ffb6 | 39 | .BR adjtimex () |
fea681da MK |
40 | reads and optionally sets adjustment parameters for this algorithm. |
41 | It takes a pointer to a | |
c13182ef | 42 | .I timex |
fea681da MK |
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 | |
bd191423 | 47 | .in +4n |
fea681da MK |
48 | .nf |
49 | struct timex { | |
50 | int modes; /* mode selector */ | |
51 | long offset; /* time offset (usec) */ | |
52 | long freq; /* frequency offset (scaled ppm) */ | |
cfc621b5 | 53 | .\" FIXME -- what is the scaling unit? 2^16 ? |
fea681da MK |
54 | long maxerror; /* maximum error (usec) */ |
55 | long esterror; /* estimated error (usec) */ | |
56 | int status; /* clock command/status */ | |
57 | long constant; /* pll time constant */ | |
972a8ec7 | 58 | long precision; /* clock precision (usec) (read-only) */ |
fea681da | 59 | long tolerance; /* clock frequency tolerance (ppm) |
972a8ec7 MK |
60 | (read-only) */ |
61 | struct timeval time; /* current time (read-only) */ | |
fea681da MK |
62 | long tick; /* usecs between clock ticks */ |
63 | }; | |
64 | .fi | |
bd191423 | 65 | .in |
fea681da MK |
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 | |
bd191423 | 74 | .in +4n |
fea681da MK |
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 */ | |
1e321034 | 83 | #define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime() */ |
fea681da | 84 | .fi |
bd191423 | 85 | .in |
fea681da MK |
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, | |
e511ffb6 | 94 | .BR adjtimex () |
fea681da MK |
95 | returns the clock state: |
96 | .PP | |
bd191423 | 97 | .in +4n |
fea681da MK |
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 | |
bd191423 | 106 | .in |
fea681da MK |
107 | .PP |
108 | On failure, | |
e511ffb6 | 109 | .BR adjtimex () |
fea681da MK |
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 | |
c13182ef | 127 | to a value outside the range |
fea681da | 128 | .RB 900000/ HZ |
c13182ef | 129 | to |
fea681da MK |
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 | |
eba72288 | 137 | is non-zero and the caller does not have sufficient privilege. |
fea681da MK |
138 | Under Linux the |
139 | .B CAP_SYS_TIME | |
140 | capability is required. | |
141 | .SH "CONFORMING TO" | |
60a90ecd | 142 | .BR adjtimex () |
8382f16d | 143 | is Linux-specific and should not be used in programs |
dffb0109 MK |
144 | intended to be portable. |
145 | See | |
146 | .BR adjtime (3) | |
c13182ef | 147 | for a more portable, but less flexible, |
dffb0109 | 148 | method of adjusting the system clock. |
fea681da MK |
149 | .SH "SEE ALSO" |
150 | .BR settimeofday (2), | |
dffb0109 | 151 | .BR adjtime (3), |
1d7c4d16 MK |
152 | .BR capabilities (7), |
153 | .BR time (7) |