]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Hey Emacs! This file is -*- nroff -*- source. |
2 | .\" | |
3 | .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992 | |
4 | .\" | |
5 | .\" Permission is granted to make and distribute verbatim copies of this | |
6 | .\" manual provided the copyright notice and this permission notice are | |
7 | .\" preserved on all copies. | |
8 | .\" | |
9 | .\" Permission is granted to copy and distribute modified versions of this | |
10 | .\" manual under the conditions for verbatim copying, provided that the | |
11 | .\" entire resulting derived work is distributed under the terms of a | |
12 | .\" permission notice identical to this one. | |
c13182ef | 13 | .\" |
fea681da MK |
14 | .\" Since the Linux kernel and libraries are constantly changing, this |
15 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
16 | .\" responsibility for errors or omissions, or for damages resulting from | |
17 | .\" the use of the information contained herein. The author(s) may not | |
18 | .\" have taken the same level of care in the production of this manual, | |
19 | .\" which is licensed free of charge, as they might when working | |
20 | .\" professionally. | |
c13182ef | 21 | .\" |
fea681da MK |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
24 | .\" | |
25 | .\" Modified by Michael Haardt <michael@moria.de> | |
26 | .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu> | |
27 | .\" Modified 1995-06-10 by Andries Brouwer <aeb@cwi.nl> | |
305a0578 | 28 | .\" Modified 2004-06-23 by Michael Kerrisk <mtk-manpages@gmx.net> |
fea681da MK |
29 | .\" Modified 2004-10-10 by Andries Brouwer <aeb@cwi.nl> |
30 | .\" | |
d9343c5c | 31 | .TH UTIME 2 2004-10-10 "Linux" "Linux Programmer's Manual" |
fea681da MK |
32 | .SH NAME |
33 | utime, utimes \- change access and/or modification times of an inode | |
34 | .SH SYNOPSIS | |
35 | .nf | |
36 | .B #include <sys/types.h> | |
37 | .br | |
38 | .B #include <utime.h> | |
39 | .sp | |
40 | .BI "int utime(const char *" filename ", const struct utimbuf *" buf ); | |
521bf584 | 41 | .sp |
fea681da MK |
42 | .B #include <sys/time.h> |
43 | .sp | |
69b7b9e5 | 44 | .BI "int utimes(const char *" filename ", const struct timeval " times [2]); |
fea681da MK |
45 | .fi |
46 | .SH DESCRIPTION | |
e511ffb6 | 47 | .BR utime () |
fea681da MK |
48 | changes the access and modification times of the inode specified by |
49 | .I filename | |
50 | to the | |
51 | .IR actime " and " modtime | |
c13182ef | 52 | fields of |
fea681da MK |
53 | .I buf |
54 | respectively. | |
55 | ||
56 | If | |
57 | .I buf | |
58 | is NULL, then the access and modification times of the file are set | |
59 | to the current time. | |
60 | ||
61 | Changing time stamps is permitted when: either | |
62 | the process has appropriate privileges (Linux: has the | |
63 | .B CAP_FOWNER | |
64 | capability), or the effective user ID equals the user ID | |
65 | of the file, or | |
66 | .I buf | |
67 | must is NULL and the process has write permission to the file. | |
68 | ||
69 | The | |
70 | .I utimbuf | |
71 | structure is: | |
72 | ||
73 | .RS | |
74 | .nf | |
75 | struct utimbuf { | |
69b7b9e5 MK |
76 | time_t actime; /* access time */ |
77 | time_t modtime; /* modification time */ | |
fea681da MK |
78 | }; |
79 | .fi | |
80 | .RE | |
81 | ||
82 | The function | |
e511ffb6 | 83 | .BR utime () |
fea681da MK |
84 | allows specification of time stamps with a resolution of 1 second. |
85 | The function | |
e511ffb6 | 86 | .BR utimes () |
fea681da MK |
87 | is similar, but allows a resolution of 1 microsecond. |
88 | Here | |
69b7b9e5 | 89 | .IR times [0] |
fea681da | 90 | refers to access time, and |
69b7b9e5 | 91 | .IR times [1] |
fea681da MK |
92 | to modification time. |
93 | ||
94 | The | |
95 | .I timeval | |
96 | structure is: | |
97 | ||
98 | .RS | |
99 | .nf | |
100 | struct timeval { | |
69b7b9e5 MK |
101 | long tv_sec; /* seconds */ |
102 | long tv_usec; /* microseconds */ | |
fea681da MK |
103 | }; |
104 | .fi | |
105 | .RE | |
106 | .SH "RETURN VALUE" | |
c13182ef MK |
107 | On success, zero is returned. |
108 | On error, \-1 is returned, and | |
fea681da MK |
109 | .I errno |
110 | is set appropriately. | |
111 | .SH ERRORS | |
112 | .TP | |
113 | .B EACCES | |
114 | Search permission is denied for one of the directories in | |
115 | the path prefix of | |
116 | .I path | |
117 | (see also | |
ad7cc990 | 118 | .BR path_resolution (7)), |
fea681da MK |
119 | or |
120 | .I buf | |
121 | is NULL and the process does not have permission to change the time stamps | |
122 | (see above). | |
123 | .TP | |
124 | .B ENOENT | |
125 | .I filename | |
126 | does not exist. | |
127 | .TP | |
128 | .B EPERM | |
129 | .I buf | |
130 | is not NULL and the process does not have permission to change the time stamps. | |
131 | .TP | |
132 | .B EROFS | |
133 | .I path | |
134 | resides on a read-only file system. | |
2dd578fd MK |
135 | .SH "CONFORMING TO" |
136 | .BR utime (): | |
137 | SVr4, POSIX.1-2001. | |
138 | .\" SVr4 documents additional error conditions EFAULT, | |
139 | .\" EINTR, ELOOP, EMULTIHOP, ENAMETOOLONG, ENOLINK, ENOLINK, ENOTDIR. | |
140 | .br | |
141 | .BR utimes (): | |
142 | 4.3BSD | |
fea681da MK |
143 | .SH NOTES |
144 | Linux does not allow changing the time stamps on an immutable file, | |
145 | or setting the time stamps to something other than the current time | |
146 | on an append-only file. | |
147 | ||
148 | In libc4 and libc5, | |
e511ffb6 | 149 | .BR utimes () |
fea681da | 150 | is just a wrapper for |
e511ffb6 | 151 | .BR utime () |
fea681da MK |
152 | and hence does not allow a subsecond resolution. |
153 | ||
69b7b9e5 | 154 | POSIX.1-2001 marks |
e511ffb6 | 155 | .BR utimes () |
69b7b9e5 MK |
156 | legacy, which is strange since it provides more functionality than |
157 | .BR utime (). | |
fea681da | 158 | .SH BUGS |
1274071a MK |
159 | Linux is not careful to distinguish between the |
160 | .B EACCES | |
2f0af33b MK |
161 | and |
162 | .B EPERM | |
163 | error returns. | |
97c1eac8 | 164 | On the other hand, POSIX.1-2001 is buggy in its error description for |
e511ffb6 | 165 | .BR utimes (). |
fea681da MK |
166 | .SH "SEE ALSO" |
167 | .BR chattr (1), | |
22e3b8b1 | 168 | .BR futimesat (2), |
51fa356e MK |
169 | .BR stat (2), |
170 | .BR futimes (3) |