xref: /dragonfly/lib/libc/sys/utimes.2 (revision 984263bc)
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
56The access and modification times of the file named by
57.Fa path
58or referenced by
59.Fa fd
60are changed as specified by the argument
61.Fa times .
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 super-user.
70.Pp
71If
72.Fa times
73is
74.Pf non- Dv NULL ,
75it is assumed to point to an array of two timeval structures.
76The access time is set to the value of the first element, and the
77modification time is set to the value of the second element.
78The caller must be the owner of the file or be the super-user.
79.Pp
80In either case, the inode-change-time of the file is set to the current
81time.
82.Pp
83.Fn lutimes
84is like
85.Fn utimes
86except in the case where the named file is a symbolic link,
87in which case
88.Fn lutimes
89changes the access and modification times of the link,
90while
91.Fn utimes
92changes the times of the file the link references.
93.Sh RETURN VALUES
94.Rv -std
95.Sh ERRORS
96.Fn utimes
97and
98.Fn lutimes
99will fail if:
100.Bl -tag -width Er
101.It Bq Er EACCES
102Search permission is denied for a component of the path prefix;
103or the
104.Fa times
105argument is
106.Dv NULL
107and the effective user ID of the process does not
108match the owner of the file, and is not the super-user, and write
109access is denied.
110.It Bq Er EFAULT
111.Fa path
112or
113.Fa times
114points outside the process's allocated address space.
115.It Bq Er EIO
116An I/O error occurred while reading or writing the affected inode.
117.It Bq Er ELOOP
118Too many symbolic links were encountered in translating the pathname.
119.It Bq Er ENAMETOOLONG
120A component of a pathname exceeded
121.Dv NAME_MAX
122characters, or an entire path name exceeded
123.Dv PATH_MAX
124characters.
125.It Bq Er ENOENT
126The named file does not exist.
127.It Bq Er ENOTDIR
128A component of the path prefix is not a directory.
129.It Bq Er EPERM
130The
131.Fa times
132argument is not
133.Dv NULL
134and the calling process's effective user ID
135does not match the owner of the file and is not the super-user.
136.It Bq Er EROFS
137The file system containing the file is mounted read-only.
138.El
139.Pp
140.Fn futimes
141will fail if:
142.Bl -tag -width Er
143.It Bq Er EBADF
144.Fa fd
145does not refer to a valid descriptor.
146.El
147.Pp
148All of the functions will fail if:
149.Bl -tag -width Er
150.It Bq Er EACCES
151The
152.Fa times
153argument is
154.Dv NULL
155and the effective user ID of the process does not
156match the owner of the file, and is not the super-user, and write
157access is denied.
158.It Bq Er EFAULT
159.Fa times
160points outside the process's allocated address space.
161.It Bq Er EIO
162An I/O error occurred while reading or writing the affected inode.
163.It Bq Er EPERM
164The
165.Fa times
166argument is not
167.Dv NULL
168and the calling process's effective user ID
169does not match the owner of the file and is not the super-user.
170.It Bq Er EROFS
171The 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
177The
178.Fn utimes
179function call appeared in
180.Bx 4.2 .
181The
182.Fn futimes
183and
184.Fn lutimes
185function calls first appeared in
186.Fx 3.0 .
187