1.\" $NetBSD: utimes.2,v 1.17 2002/02/08 01:28:23 ross 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.\" 36.Dd June 4, 1993 37.Dt UTIMES 2 38.Os 39.Sh NAME 40.Nm utimes , 41.Nm lutimes , 42.Nm futimes 43.Nd set file access and modification times 44.Sh LIBRARY 45.Lb libc 46.Sh SYNOPSIS 47.Fd #include \*[Lt]sys/time.h\*[Gt] 48.Ft int 49.Fn utimes "const char *path" "const struct timeval *times" 50.Ft int 51.Fn lutimes "const char *path" "const struct timeval *times" 52.Ft int 53.Fn futimes "int fd" "const struct timeval *times" 54.Sh DESCRIPTION 55The access and modification times of the file named by 56.Fa path 57or referenced by 58.Fa fd 59are changed as specified by the argument 60.Fa times . 61.Pp 62If 63.Fa times 64is 65.Dv NULL , 66the access and modification times are set to the current time. 67The caller must be the owner of the file, have permission to 68write the file, or be the super-user. 69.Pp 70If 71.Fa times 72is 73.Pf non- Dv 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 super-user. 78.Pp 79In either case, the inode-change-time of the file is set to the current 80time. 81.Pp 82.Fn lutimes 83is like 84.Fn utimes 85except in the case where the named file is a symbolic link, 86in which case 87.Fn lutimes 88changes the access and modification times of the link, 89while 90.Fn utimes 91changes the times of the file the link references. 92.Sh RETURN VALUES 93Upon successful completion, a value of 0 is returned. 94Otherwise, a value of -1 is returned and 95.Va errno 96is set to indicate the error. 97.Sh ERRORS 98.Fn utimes 99and 100.Fn lutimes 101will fail if: 102.Bl -tag -width Er 103.It Bq Er EACCES 104Search permission is denied for a component of the path prefix; 105or the 106.Fa times 107argument is 108.Dv NULL 109and the effective user ID of the process does not 110match the owner of the file, and is not the super-user, and write 111access is denied. 112.It Bq Er EFAULT 113.Fa path 114or 115.Fa times 116points outside the process's allocated address space. 117.It Bq Er EIO 118An I/O error occurred while reading or writing the affected inode. 119.It Bq Er ELOOP 120Too many symbolic links were encountered in translating the pathname. 121.It Bq Er ENAMETOOLONG 122A component of a pathname exceeded 123.Dv {NAME_MAX} 124characters, or an entire path name exceeded 125.Dv {PATH_MAX} 126characters. 127.It Bq Er ENOENT 128The named file does not exist. 129.It Bq Er ENOTDIR 130A component of the path prefix is not a directory. 131.It Bq Er EPERM 132The 133.Fa times 134argument is not 135.Dv NULL 136and the calling process's effective user ID 137does not match the owner of the file and is not the super-user. 138.It Bq Er EROFS 139The file system containing the file is mounted read-only. 140.El 141.Pp 142.Fn futimes 143will fail if: 144.Bl -tag -width Er 145.It Bq Er EBADF 146.Fa fd 147does not refer to a valid descriptor. 148.It Bq Er EACCES 149The 150.Fa times 151argument is 152.Dv NULL 153and the effective user ID of the process does not 154match the owner of the file, and is not the super-user, and write 155access is denied. 156.It Bq Er EFAULT 157.Fa times 158points outside the process's allocated address space. 159.It Bq Er EIO 160An I/O error occurred while reading or writing the affected inode. 161.It Bq Er EPERM 162The 163.Fa times 164argument is not 165.Dv NULL 166and the calling process's effective user ID 167does not match the owner of the file and is not the super-user. 168.It Bq Er EROFS 169The file system containing the file is mounted read-only. 170.El 171.Sh SEE ALSO 172.Xr stat 2 , 173.Xr utime 3 , 174.Xr symlink 7 175.Sh HISTORY 176The 177.Fn utimes 178function call appeared in 179.Bx 4.2 . 180The 181.Fn futimes 182function call appeared in 183.Nx 1.2 . 184The 185.Fn lutimes 186function call appeared in 187.Nx 1.3 . 188