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