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