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