Initial import from FreeBSD RELENG_4:
[dragonfly.git] / lib / libcr / sys / utimes.2
1 .\"     $NetBSD: utimes.2,v 1.13 1999/03/22 19:45:11 garbled Exp $
2 .\"
3 .\" Copyright (c) 1990, 1993
4 .\"     The Regents of the University of California.  All rights reserved.
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\" 3. All advertising materials mentioning features or use of this software
15 .\"    must display the following acknowledgement:
16 .\"     This product includes software developed by the University of
17 .\"     California, Berkeley and its contributors.
18 .\" 4. Neither the name of the University nor the names of its contributors
19 .\"    may be used to endorse or promote products derived from this software
20 .\"    without specific prior written permission.
21 .\"
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" SUCH DAMAGE.
33 .\"
34 .\"     @(#)utimes.2    8.1 (Berkeley) 6/4/93
35 .\" $FreeBSD: src/lib/libc/sys/utimes.2,v 1.8.2.4 2001/12/14 18:34:02 ru Exp $
36 .\"
37 .Dd June 4, 1993
38 .Dt UTIMES 2
39 .Os
40 .Sh NAME
41 .Nm utimes ,
42 .Nm lutimes ,
43 .Nm futimes
44 .Nd set file access and modification times
45 .Sh LIBRARY
46 .Lb libc
47 .Sh SYNOPSIS
48 .In sys/time.h
49 .Ft int
50 .Fn utimes "const char *path" "const struct timeval *times"
51 .Ft int
52 .Fn lutimes "const char *path" "const struct timeval *times"
53 .Ft int
54 .Fn futimes "int fd" "const struct timeval *times"
55 .Sh DESCRIPTION
56 The access and modification times of the file named by
57 .Fa path
58 or referenced by
59 .Fa fd
60 are changed as specified by the argument
61 .Fa times .
62 .Pp
63 If
64 .Fa times
65 is
66 .Dv NULL ,
67 the access and modification times are set to the current time.
68 The caller must be the owner of the file, have permission to
69 write the file, or be the super-user.
70 .Pp
71 If
72 .Fa times
73 is
74 .Pf non- Dv NULL ,
75 it is assumed to point to an array of two timeval structures.
76 The access time is set to the value of the first element, and the
77 modification time is set to the value of the second element.
78 The caller must be the owner of the file or be the super-user.
79 .Pp
80 In either case, the inode-change-time of the file is set to the current
81 time.
82 .Pp
83 .Fn lutimes
84 is like
85 .Fn utimes
86 except in the case where the named file is a symbolic link,
87 in which case
88 .Fn lutimes
89 changes the access and modification times of the link,
90 while
91 .Fn utimes
92 changes the times of the file the link references.
93 .Sh RETURN VALUES
94 .Rv -std
95 .Sh ERRORS
96 .Fn utimes
97 and
98 .Fn lutimes
99 will fail if:
100 .Bl -tag -width Er
101 .It Bq Er EACCES
102 Search permission is denied for a component of the path prefix;
103 or the
104 .Fa times
105 argument is
106 .Dv NULL
107 and the effective user ID of the process does not
108 match the owner of the file, and is not the super-user, and write
109 access is denied.
110 .It Bq Er EFAULT
111 .Fa path
112 or
113 .Fa times
114 points outside the process's allocated address space.
115 .It Bq Er EIO
116 An I/O error occurred while reading or writing the affected inode.
117 .It Bq Er ELOOP
118 Too many symbolic links were encountered in translating the pathname.
119 .It Bq Er ENAMETOOLONG
120 A component of a pathname exceeded
121 .Dv NAME_MAX
122 characters, or an entire path name exceeded
123 .Dv PATH_MAX
124 characters.
125 .It Bq Er ENOENT
126 The named file does not exist.
127 .It Bq Er ENOTDIR
128 A component of the path prefix is not a directory.
129 .It Bq Er EPERM
130 The
131 .Fa times
132 argument is not
133 .Dv NULL
134 and the calling process's effective user ID
135 does not match the owner of the file and is not the super-user.
136 .It Bq Er EROFS
137 The file system containing the file is mounted read-only.
138 .El
139 .Pp
140 .Fn futimes
141 will fail if:
142 .Bl -tag -width Er
143 .It Bq Er EBADF
144 .Fa fd
145 does not refer to a valid descriptor.
146 .El
147 .Pp
148 All of the functions will fail if:
149 .Bl -tag -width Er
150 .It Bq Er EACCES
151 The
152 .Fa times
153 argument is
154 .Dv NULL
155 and the effective user ID of the process does not
156 match the owner of the file, and is not the super-user, and write
157 access is denied.
158 .It Bq Er EFAULT
159 .Fa times
160 points outside the process's allocated address space.
161 .It Bq Er EIO
162 An I/O error occurred while reading or writing the affected inode.
163 .It Bq Er EPERM
164 The
165 .Fa times
166 argument is not
167 .Dv NULL
168 and the calling process's effective user ID
169 does not match the owner of the file and is not the super-user.
170 .It Bq Er EROFS
171 The file system containing the file is mounted read-only.
172 .El
173 .Sh SEE ALSO
174 .Xr stat 2 ,
175 .Xr utime 3
176 .Sh HISTORY
177 The
178 .Fn utimes
179 function call appeared in
180 .Bx 4.2 .
181 The
182 .Fn futimes
183 and
184 .Fn lutimes
185 function calls first appeared in
186 .Fx 3.0 .