1.\"	$OpenBSD: utime.3,v 1.22 2015/01/29 01:46:30 schwarze Exp $
2.\"
3.\" Copyright (c) 1980, 1991, 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. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.Dd $Mdocdate: January 29 2015 $
31.Dt UTIME 3
32.Os
33.Sh NAME
34.Nm utime
35.Nd set file times
36.Sh SYNOPSIS
37.In sys/types.h
38.In utime.h
39.Ft int
40.Fn utime "const char *file" "const struct utimbuf *timep"
41.Sh DESCRIPTION
42.Bf -symbolic
43This interface is obsoleted by
44.Xr utimes 2 .
45.Ef
46.Pp
47The
48.Fn utime
49function sets the access and modification times of the named file.
50.Pp
51If
52.Fa timep
53is
54.Dv NULL ,
55the access and modification times are set to the current time.
56The calling process must be the owner of the file or have permission to
57write the file.
58.Pp
59If
60.Fa timep
61is non-null, it specifies a pointer to a
62.Li utimbuf
63structure, as defined in
64.In utime.h :
65.Bd -literal -offset indent
66struct utimbuf {
67	time_t actime;		/* Access time */
68	time_t modtime;		/* Modification time */
69};
70.Ed
71.Pp
72The access time is set to the value of the
73.Fa actime
74member, and the modification
75time is set to the value of the
76.Fa modtime
77member.
78The times are measured in
79seconds since 0 hours, 0 minutes, 0 seconds, January 1, 1970, Coordinated
80Universal Time (UTC).
81The calling process must be the owner of the file or be the superuser.
82.Pp
83In either case, the inode change-time of the file is set to the current
84time.
85.Sh RETURN VALUES
86.Rv -std
87.Sh ERRORS
88.Fn utime
89will fail if:
90.Bl -tag -width Er
91.It Bq Er EACCES
92Search permission is denied for a component of the path prefix;
93or the
94.Fa timep
95argument is
96.Dv NULL
97and the effective user ID of the process does not
98match the owner of the file, the effective user ID is not that of the
99superuser,
100and write access is denied.
101.It Bq Er EFAULT
102.Fa file
103or
104.Fa timep
105points outside the process's allocated address space.
106.It Bq Er EINVAL
107The pathname contains a character with the high-order bit set.
108.It Bq Er EIO
109An I/O error occurred while reading or writing the affected inode.
110.It Bq Er ELOOP
111Too many symbolic links were encountered in translating the pathname.
112.It Bq Er ENAMETOOLONG
113A component of a pathname exceeded
114.Dv NAME_MAX
115characters, or an entire pathname (including the terminating NUL)
116exceeded
117.Dv PATH_MAX
118bytes.
119.It Bq Er ENOENT
120The named file does not exist.
121.It Bq Er ENOTDIR
122A component of the path prefix is not a directory.
123.It Bq Er EPERM
124The
125.Fa timep
126argument is not
127.Dv NULL
128and the calling process's effective user ID
129does not match the owner of the file and is not the superuser.
130.It Bq Er EROFS
131The file system containing the file is mounted read-only.
132.El
133.Sh SEE ALSO
134.Xr stat 2 ,
135.Xr utimes 2
136.Sh STANDARDS
137The
138.Fn utime
139function conforms to
140.St -p1003.1-88 .
141.Sh HISTORY
142A
143.Fn utime
144function appeared in
145.At v7 .
146