]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/adjtimex.2
sigaction.2: Fix bad cross reference (times(2) not time(2))
[thirdparty/man-pages.git] / man2 / adjtimex.2
CommitLineData
fea681da
MK
1.\" Copyright (c) 1995 Michael Chastain (mec@shell.portal.com), 15 April 1995.
2.\"
1dd72f9c 3.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
fea681da
MK
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
c715f741
MK
20.\" License along with this manual; if not, see
21.\" <http://www.gnu.org/licenses/>.
6a8d8745 22.\" %%%LICENSE_END
fea681da
MK
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>
c11b1abf 26.\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com>
fea681da 27.\"
65cee725
MK
28.\" FIXME 2.6.29 added ADJ_SETOFFSET
29.\"
bd641654 30.TH ADJTIMEX 2 2013-08-07 "Linux" "Linux Programmer's Manual"
fea681da
MK
31.SH NAME
32adjtimex \- tune kernel clock
33.SH SYNOPSIS
34.B #include <sys/timex.h>
35.sp
36.BI "int adjtimex(struct timex *" "buf" );
37.SH DESCRIPTION
331da7c3 38Linux uses David L. Mills' clock adjustment algorithm (see RFC\ 1305).
fea681da 39The system call
e511ffb6 40.BR adjtimex ()
fea681da
MK
41reads and optionally sets adjustment parameters for this algorithm.
42It takes a pointer to a
c13182ef 43.I timex
fea681da
MK
44structure, updates kernel parameters from field values,
45and returns the same structure with current kernel values.
46This structure is declared as follows:
47.PP
bd191423 48.in +4n
fea681da
MK
49.nf
50struct timex {
51 int modes; /* mode selector */
52 long offset; /* time offset (usec) */
53 long freq; /* frequency offset (scaled ppm) */
cfc621b5 54.\" FIXME -- what is the scaling unit? 2^16 ?
fea681da
MK
55 long maxerror; /* maximum error (usec) */
56 long esterror; /* estimated error (usec) */
57 int status; /* clock command/status */
58 long constant; /* pll time constant */
972a8ec7 59 long precision; /* clock precision (usec) (read-only) */
fea681da 60 long tolerance; /* clock frequency tolerance (ppm)
972a8ec7
MK
61 (read-only) */
62 struct timeval time; /* current time (read-only) */
fea681da
MK
63 long tick; /* usecs between clock ticks */
64};
65.fi
bd191423 66.in
fea681da
MK
67.PP
68The
69.I modes
70field determines which parameters, if any, to set.
71It may contain a
72.RI bitwise- or
73combination of zero or more of the following bits:
74.PP
bd191423 75.in +4n
fea681da
MK
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 */
1e321034 84#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime() */
fea681da 85.fi
bd191423 86.in
fea681da
MK
87.PP
88Ordinary users are restricted to a zero value for
89.IR mode .
90Only the superuser may set any parameters.
91.br
92.ne 12v
47297adb 93.SH RETURN VALUE
fea681da 94On success,
e511ffb6 95.BR adjtimex ()
fea681da
MK
96returns the clock state:
97.PP
bd191423 98.in +4n
fea681da
MK
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
bd191423 107.in
fea681da
MK
108.PP
109On failure,
e511ffb6 110.BR adjtimex ()
fea681da
MK
111returns \-1 and sets
112.IR errno .
113.SH ERRORS
114.TP
115.B EFAULT
116.I buf
117does not point to writable memory.
118.TP
119.B EINVAL
120An attempt is made to set
121.I buf.offset
122to a value outside the range \-131071 to +131071,
123or to set
124.I buf.status
125to a value other than those listed above,
126or to set
127.I buf.tick
c13182ef 128to a value outside the range
fea681da 129.RB 900000/ HZ
c13182ef 130to
fea681da
MK
131.RB 1100000/ HZ ,
132where
133.B HZ
134is the system timer interrupt frequency.
135.TP
136.B EPERM
137.I buf.mode
c7094399 138is nonzero and the caller does not have sufficient privilege.
fea681da
MK
139Under Linux the
140.B CAP_SYS_TIME
141capability is required.
47297adb 142.SH CONFORMING TO
60a90ecd 143.BR adjtimex ()
8382f16d 144is Linux-specific and should not be used in programs
dffb0109
MK
145intended to be portable.
146See
147.BR adjtime (3)
c13182ef 148for a more portable, but less flexible,
dffb0109 149method of adjusting the system clock.
47297adb 150.SH SEE ALSO
fea681da 151.BR settimeofday (2),
dffb0109 152.BR adjtime (3),
1d7c4d16 153.BR capabilities (7),
bd641654
MK
154.BR time (7),
155.BR adjtimex (8)