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