xref: /minix/lib/libc/gen/utime.3 (revision 0a6a1f1d)
1.\"	$NetBSD: utime.3,v 1.22 2014/10/19 16:47:51 njoly 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.\"     @(#)utime.3	8.1 (Berkeley) 6/4/93
31.\"
32.Dd April 29, 2010
33.Dt UTIME 3
34.Os
35.Sh NAME
36.Nm utime
37.Nd set file times
38.Sh LIBRARY
39.Lb libc
40.Sh SYNOPSIS
41.In utime.h
42.Ft int
43.Fn utime "const char *file" "const struct utimbuf *timep"
44.Sh DESCRIPTION
45.Bf -symbolic
46This interface is obsoleted by
47.Xr utimes 2 .
48.Ef
49.Pp
50The
51.Fn utime
52function sets the access and modification times of the named file.
53.Pp
54If
55.Fa timep
56is
57.Dv NULL ,
58the access and modification times are set to the current time.
59The calling process must be the owner of the file or have permission to
60write the file.
61.Pp
62If
63.Fa timep
64is
65.Pf non- Dv NULL ,
66.Fa time
67is assumed to be a pointer to a utimbuf structure, as defined in
68.In utime.h :
69.Bd -literal -offset indent
70struct utimbuf {
71	time_t actime;          /* Access time */
72	time_t modtime;         /* Modification time */
73};
74.Ed
75.Pp
76The access time is set to the value of the actime member, and the
77modification time is set to the value of the modtime member.
78The times are measured in seconds since 0 hours, 0 minutes, 0
79seconds, January 1, 1970 Coordinated Universal Time (UTC).
80The calling process must be the owner of the file or be the super-user.
81.Pp
82In either case, the inode-change-time of the file is set to the current
83time.
84.Sh RETURN VALUES
85Upon successful completion, a value of 0 is returned.
86Otherwise, a value of \-1 is returned and
87.Va errno
88is set to indicate the error.
89.Sh ERRORS
90.Fn utime
91will fail if:
92.Bl -tag -width Er
93.It Bq Er EACCES
94Search permission is denied for a component of the path prefix;
95or the
96.Fa times
97argument is
98.Dv NULL
99and the effective user ID of the process does not
100match the owner of the file, and is not the super-user, and write
101access is denied.
102.It Bq Er EFAULT
103.Fa file
104or
105.Fa times
106points outside the process's allocated address space.
107.It Bq Er EINVAL
108The pathname contains a character with the high-order bit set.
109.It Bq Er EIO
110An I/O error occurred while reading or writing the affected inode.
111.It Bq Er ELOOP
112Too many symbolic links were encountered in translating the pathname.
113.It Bq Er ENAMETOOLONG
114A component of a pathname exceeded
115.Brq Dv NAME_MAX
116characters,
117or an entire path name exceeded
118.Brq Dv PATH_MAX
119characters.
120.It Bq Er ENOENT
121The named file does not exist.
122.It Bq Er ENOTDIR
123A component of the path prefix is not a directory.
124.It Bq Er EPERM
125The
126.Fa times
127argument is not
128.Dv NULL
129and the calling process's effective user ID
130does not match the owner of the file and is not the super-user.
131.It Bq Er EROFS
132The file system containing the file is mounted read-only.
133.El
134.Sh SEE ALSO
135.Xr stat 2 ,
136.Xr utimes 2
137.Sh STANDARDS
138The
139.Fn utime
140function conforms to
141.St -p1003.1-90 .
142It was however marked as legacy in the
143.St -p1003.1-2008
144revision of the standard.
145.Sh HISTORY
146A
147.Fn utime
148function appeared in
149.At v7 .
150