OSDN Git Service

0951fc31878fd473122941d3c5e0812689edb5c3
[linuxjm/LDP_man-pages.git] / original / 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 2.6.26 added ADJ_TAI
29 .\"             commit 153b5d054ac2d98ea0d86504884326b6777f683d
30 .\" FIXME 2.6.26 added ADJ_MICOR and ADJ_NANO
31 .\"             commit eea83d896e318bda54be2d2770d2c5d6668d11db
32 .\"             Author: Roman Zippel <zippel@linux-m68k.org>
33 .\" FIXME 2.6.39 added ADJ_SETOFFSET
34 .\"             commit 094aa1881fdc1b8889b442eb3511b31f3ec2b762
35 .\"             Author: Richard Cochran <richardcochran@gmail.com>
36 .\"
37 .TH ADJTIMEX 2 2013-08-07 "Linux" "Linux Programmer's Manual"
38 .SH NAME
39 adjtimex \- tune kernel clock
40 .SH SYNOPSIS
41 .B #include <sys/timex.h>
42 .sp
43 .BI "int adjtimex(struct timex *" "buf" );
44 .SH DESCRIPTION
45 Linux uses David L. Mills' clock adjustment algorithm (see RFC\ 1305).
46 The system call
47 .BR adjtimex ()
48 reads and optionally sets adjustment parameters for this algorithm.
49 It takes a pointer to a
50 .I timex
51 structure, updates kernel parameters from field values,
52 and returns the same structure with current kernel values.
53 This structure is declared as follows:
54 .PP
55 .in +4n
56 .nf
57 struct timex {
58     int modes;           /* mode selector */
59     long offset;         /* time offset (usec) */
60     long freq;           /* frequency offset (scaled ppm) */
61 .\" FIXME -- what is the scaling unit?  2^16 ?
62     long maxerror;       /* maximum error (usec) */
63     long esterror;       /* estimated error (usec) */
64     int status;          /* clock command/status */
65     long constant;       /* pll time constant */
66     long precision;      /* clock precision (usec) (read-only) */
67     long tolerance;      /* clock frequency tolerance (ppm)
68                             (read-only) */
69     struct timeval time; /* current time (read-only) */
70     long tick;           /* usecs between clock ticks */
71 };
72 .fi
73 .in
74 .PP
75 The
76 .I modes
77 field determines which parameters, if any, to set.
78 It may contain a
79 .RI bitwise- or
80 combination of zero or more of the following bits:
81 .PP
82 .in +4n
83 .nf
84 #define ADJ_OFFSET            0x0001 /* time offset */
85 #define ADJ_FREQUENCY         0x0002 /* frequency offset */
86 #define ADJ_MAXERROR          0x0004 /* maximum time error */
87 #define ADJ_ESTERROR          0x0008 /* estimated time error */
88 #define ADJ_STATUS            0x0010 /* clock status */
89 #define ADJ_TIMECONST         0x0020 /* pll time constant */
90 #define ADJ_TICK              0x4000 /* tick value */
91 #define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime() */
92 .fi
93 .in
94 .PP
95 Ordinary users are restricted to a zero value for
96 .IR modes .
97 Only the superuser may set any parameters.
98 .br
99 .ne 12v
100 .SH RETURN VALUE
101 On success,
102 .BR adjtimex ()
103 returns the clock state:
104 .PP
105 .in +4n
106 .nf
107 #define TIME_OK   0 /* clock synchronized */
108 #define TIME_INS  1 /* insert leap second */
109 #define TIME_DEL  2 /* delete leap second */
110 #define TIME_OOP  3 /* leap second in progress */
111 #define TIME_WAIT 4 /* leap second has occurred */
112 #define TIME_BAD  5 /* clock not synchronized */
113 .fi
114 .in
115 .PP
116 On failure,
117 .BR adjtimex ()
118 returns \-1 and sets
119 .IR errno .
120 .SH ERRORS
121 .TP
122 .B EFAULT
123 .I buf
124 does not point to writable memory.
125 .TP
126 .B EINVAL
127 An attempt is made to set
128 .I buf.offset
129 to a value outside the range \-131071 to +131071,
130 or to set
131 .I buf.status
132 to a value other than those listed above,
133 or to set
134 .I buf.tick
135 to a value outside the range
136 .RB 900000/ HZ
137 to
138 .RB 1100000/ HZ ,
139 where
140 .B HZ
141 is the system timer interrupt frequency.
142 .TP
143 .B EPERM
144 .I buf.modes
145 is nonzero and the caller does not have sufficient privilege.
146 Under Linux the
147 .B CAP_SYS_TIME
148 capability is required.
149 .SH CONFORMING TO
150 .BR adjtimex ()
151 is Linux-specific and should not be used in programs
152 intended to be portable.
153 See
154 .BR adjtime (3)
155 for a more portable, but less flexible,
156 method of adjusting the system clock.
157 .SH SEE ALSO
158 .BR settimeofday (2),
159 .BR adjtime (3),
160 .BR capabilities (7),
161 .BR time (7),
162 .BR adjtimex (8)
163 .SH COLOPHON
164 This page is part of release 3.67 of the Linux
165 .I man-pages
166 project.
167 A description of the project,
168 information about reporting bugs,
169 and the latest version of this page,
170 can be found at
171 \%http://www.kernel.org/doc/man\-pages/.