OSDN Git Service

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