mount_setattr.2: Further tweaks after feedback from Christian Brauner
[man-pages.git] / man3 / adjtime.3
blob549064520d9f62c3865570856c6e072c006f91f4
1 .\" Copyright (c) 2006 by Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH ADJTIME 3 2021-03-22 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 adjtime \- correct the time to synchronize the system clock
28 .SH SYNOPSIS
29 .nf
30 .B #include <sys/time.h>
31 .PP
32 .BI "int adjtime(const struct timeval *" delta ", struct timeval *" olddelta );
33 .fi
34 .PP
35 .RS -4
36 Feature Test Macro Requirements for glibc (see
37 .BR feature_test_macros (7)):
38 .RE
39 .PP
40 .BR adjtime ():
41 .nf
42     Since glibc 2.19:
43         _DEFAULT_SOURCE
44     Glibc 2.19 and earlier:
45         _BSD_SOURCE
46 .fi
47 .SH DESCRIPTION
48 The
49 .BR adjtime ()
50 function gradually adjusts the system clock (as returned by
51 .BR gettimeofday (2)).
52 The amount of time by which the clock is to be adjusted is specified
53 in the structure pointed to by
54 .IR delta .
55 This structure has the following form:
56 .PP
57 .in +4n
58 .EX
59 struct timeval {
60     time_t      tv_sec;     /* seconds */
61     suseconds_t tv_usec;    /* microseconds */
63 .EE
64 .in
65 .PP
66 If the adjustment in
67 .I delta
68 is positive, then the system clock is speeded up by some
69 small percentage (i.e., by adding a small
70 amount of time to the clock value in each second) until the adjustment
71 has been completed.
72 If the adjustment in
73 .I delta
74 is negative, then the clock is slowed down in a similar fashion.
75 .PP
76 If a clock adjustment from an earlier
77 .BR adjtime ()
78 call is already in progress
79 at the time of a later
80 .BR adjtime ()
81 call, and
82 .I delta
83 is not NULL for the later call, then the earlier adjustment is stopped,
84 but any already completed part of that adjustment is not undone.
85 .PP
87 .I olddelta
88 is not NULL, then the buffer that it points to is used to return
89 the amount of time remaining from any previous adjustment that
90 has not yet been completed.
91 .SH RETURN VALUE
92 On success,
93 .BR adjtime ()
94 returns 0.
95 On failure, \-1 is returned, and
96 .I errno
97 is set to indicate the error.
98 .SH ERRORS
99 .TP
100 .B EINVAL
101 The adjustment in
102 .I delta
103 is outside the permitted range.
105 .B EPERM
106 The caller does not have sufficient privilege to adjust the time.
107 Under Linux, the
108 .B CAP_SYS_TIME
109 capability is required.
110 .SH ATTRIBUTES
111 For an explanation of the terms used in this section, see
112 .BR attributes (7).
113 .ad l
116 allbox;
117 lbx lb lb
118 l l l.
119 Interface       Attribute       Value
121 .BR adjtime ()
122 T}      Thread safety   MT-Safe
126 .sp 1
127 .SH CONFORMING TO
128 4.3BSD, System V.
129 .SH NOTES
130 The adjustment that
131 .BR adjtime ()
132 makes to the clock is carried out in such a manner that the clock
133 is always monotonically increasing.
134 Using
135 .BR adjtime ()
136 to adjust the time prevents the problems that can be caused for certain
137 applications (e.g.,
138 .BR make (1))
139 by abrupt positive or negative jumps in the system time.
141 .BR adjtime ()
142 is intended to be used to make small adjustments to the system time.
143 Most systems impose a limit on the adjustment that can be specified in
144 .IR delta .
145 In the glibc implementation,
146 .I delta
147 must be less than or equal to (INT_MAX / 1000000 \- 2)
148 and greater than or equal to (INT_MIN / 1000000 + 2)
149 (respectively 2145 and \-2145 seconds on i386).
150 .SH BUGS
151 A longstanding bug
152 .\" http://sourceware.org/bugzilla/show_bug?id=2449
153 .\" http://bugzilla.kernel.org/show_bug.cgi?id=6761
154 meant that if
155 .I delta
156 was specified as NULL,
157 no valid information about the outstanding clock adjustment was returned in
158 .IR olddelta .
159 (In this circumstance,
160 .BR adjtime ()
161 should return the outstanding clock adjustment, without changing it.)
162 This bug is fixed
163 .\" Thanks to the new adjtimex() ADJ_OFFSET_SS_READ flag
164 on systems with glibc 2.8 or later and
165 Linux kernel 2.6.26 or later.
166 .SH SEE ALSO
167 .BR adjtimex (2),
168 .BR gettimeofday (2),
169 .BR time (7)