1 .\" 2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for 3 .\" permission to reproduce portions of its copyrighted documentation. 4 .\" Original documentation from The Open Group can be obtained online at 5 .\" http://www.opengroup.org/bookstore/. 6 .\" 7 .\" The Institute of Electrical and Electronics Engineers and The Open 8 .\" Group, have given us permission to reprint portions of their 9 .\" documentation. 10 .\" 11 .\" In the following statement, the phrase ``this text'' refers to portions 12 .\" of the system documentation. 13 .\" 14 .\" Portions of this text are reprinted and reproduced in electronic form 15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition, 16 .\" Standard for Information Technology -- Portable Operating System 17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6, 18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics 19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy 20 .\" between these versions and the original IEEE and The Open Group 21 .\" Standard, the original IEEE and The Open Group Standard is the referee 22 .\" document. The original Standard can be obtained online at 23 .\" http://www.opengroup.org/unix/online.html. 24 .\" 25 .\" This notice shall appear on any product containing this material. 26 .\" 27 .\" The contents of this file are subject to the terms of the 28 .\" Common Development and Distribution License (the "License"). 29 .\" You may not use this file except in compliance with the License. 30 .\" 31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 32 .\" or http://www.opensolaris.org/os/licensing. 33 .\" See the License for the specific language governing permissions 34 .\" and limitations under the License. 35 .\" 36 .\" When distributing Covered Code, include this CDDL HEADER in each 37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. 38 .\" If applicable, add the following below this CDDL HEADER, with the 39 .\" fields enclosed by brackets "[]" replaced with your own identifying 40 .\" information: Portions Copyright [yyyy] [name of copyright owner] 41 .\" 42 .\" 43 .\" Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved. 44 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved. 45 .\" Copyright (c) 2014, Joyent, Inc. 46 .\" Copyright 2020 OmniOS Community Edition (OmniOSce) Association. 47 .\" 48 .TH UTIMES 2 "Sep 06, 2020" 49 .SH NAME 50 utimes, lutimes, futimes, futimesat, utimens, utimensat \- set file access and modification times 51 .SH SYNOPSIS 52 .nf 53 #include <sys/time.h> 54 55 \fBint\fR \fButimes\fR(\fBconst char *\fR\fIpath\fR, \fBconst struct timeval\fR \fItimes\fR[2]); 56 .fi 57 58 .LP 59 .nf 60 \fBint\fR \fBlutimes\fR(\fBconst char *\fR\fIpath\fR, \fBconst struct timeval\fR \fItimes\fR[2]); 61 .fi 62 63 .LP 64 .nf 65 \fBint\fR \fBfutimes\fR(\fBint\fR \fIfildes\fR, \fBconst struct timeval\fR \fItimes\fR[2]); 66 .fi 67 68 .LP 69 .nf 70 \fBint\fR \fBfutimesat\fR(\fBint\fR \fIfildes\fR, \fBconst char *\fR\fIpath\fR, 71 \fBconst struct timeval\fR \fItimes\fR[2]); 72 .fi 73 74 .LP 75 .nf 76 #include <sys/stat.h> 77 78 \fBint\fR \fBfutimens\fR(\fBint\fR \fIfildes\fR, \fBconst timespec_t\fR \fInstimes[2]\fR); 79 80 \fBint\fR \fButimensat\fR(\fBint\fR \fIfildes\fR, \fBconst char *\fR\fIpath\fR, 81 \fBconst timespec_t\fR \fInstimes[2]\fR, \fBint\fR \fIflag\fR); 82 83 .SH DESCRIPTION 84 The \fButimes()\fR function sets the access and modification times of the file 85 pointed to by the \fIpath\fR argument to the value of the \fItimes\fR argument. 86 It allows time specifications accurate to the microsecond. 87 .sp 88 .LP 89 The \fBlutimes()\fR function operates like \fButimes()\fR except if \fIpath\fR 90 points to a symbolic link; in that case \fBlutimes()\fR changes the access and 91 modifications times of the link, while \fButimes()\fR changes the file that 92 is referenced by the link. 93 .sp 94 .LP 95 The \fBfutimes()\fR function sets the access and modification times of the 96 file referenced by the file descriptor \fIfildes\fR. 97 .sp 98 .LP 99 The \fBfutimesat()\fR function also sets access and modification times. See 100 \fBfsattr\fR(5). If \fIpath\fR is a relative path name, however, 101 \fBfutimesat()\fR resolves the path relative to the \fIfildes\fR argument 102 rather than the current working directory. If \fIfildes\fR is set to 103 \fBAT_FDCWD\fR, defined in <\fBfcntl.h\fR>, \fBfutimesat()\fR resolves the path 104 relative to the current working directory. If \fIpath\fR is a null pointer, 105 \fBfutimesat()\fR sets the access and modification times on the file referenced 106 by \fIfildes\fR. The \fIfildes\fR argument is ignored if 107 \fBfutimesat()\fR is provided with an absolute path. 108 .sp 109 .LP 110 The \fItimes\fR argument is an array of \fBtimeval\fR structures. The first 111 array member represents the date and time of last access, and the second member 112 represents the date and time of last modification. The times in the 113 \fBtimeval\fR structure are measured in seconds and microseconds since the 114 Epoch, although rounding toward the nearest second may occur. 115 .sp 116 .LP 117 If the \fItimes\fR argument is a null pointer, the access and modification 118 times of the file are set to the current time. The effective user \fBID\fR of 119 the process must be the same as the owner of the file, or must have write 120 access to the file or the {\fBPRIV_FILE_OWNER\fR} privilege to use this call in 121 this manner. Upon completion, \fButimes()\fR will mark the time of the last 122 file status change, \fBst_ctime\fR, for update. 123 .sp 124 .LP 125 The \fBfutimens()\fR and \fButimensat()\fR functions also set access and 126 modification times; however, instead of taking \fBstruct timeval\fR, they take 127 \fBtimespec_t\fR which allows for nanosecond granularity. The \fBfutimens()\fR 128 function sets the access and modification times on the file descriptor 129 referenced by \fIfildes\fR. 130 .sp 131 .LP 132 The \fButimensat()\fR function determines the file to set the access and 133 modification times in an similar way to \fBfutimesat()\fR. If the argument 134 \fIpath\fR is an absolute path, then the argument \fIfildes\fR is ignored; 135 otherwise, \fIpath\fR is interpreted as a path relative to the directory 136 specified by \fIfildes\fR. If \fIfildes\fR is set to \fBAT_FDCWD\fR, then 137 \fIpath\fR is resolved relative to the current working directory. The behavior 138 when encountering symbolic links may be controlled by the value of the 139 \fIflag\fR argument. If the value of flag is the constant 140 \fBAT_SYMLINK_NOFOLLOW\fR, then when a symbolic link is encountered while 141 resolving a path, it will not be followed. Otherwise, the value of \fIflag\fR 142 should be \fB0\fR. Note that, unlike \fBfutimesat()\fR, \fButimensat()\fR 143 does not accept a null pointer for the \fIpath\fR argument. 144 .SH RETURN VALUES 145 Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is 146 returned, \fBerrno\fR is set to indicate the error, and the file times will not 147 be affected. 148 .SH ERRORS 149 The \fButimes()\fR, \fBlutimes()\fR, \fBfutimes()\fR, \fBfutimesat()\fR, 150 \fBfutimens()\fR, and \fButimensat()\fR 151 functions will fail if: 152 .sp 153 .ne 2 154 .na 155 \fB\fBEACCES\fR\fR 156 .ad 157 .RS 16n 158 Search permission is denied by a component of the path prefix; or the 159 \fItimes\fR argument is a null pointer and the effective user \fBID\fR of the 160 process does not match the owner of the file and write access is denied. 161 .RE 162 163 .sp 164 .ne 2 165 .na 166 \fB\fBEFAULT\fR\fR 167 .ad 168 .RS 16n 169 The \fIpath\fR or \fItimes\fR argument points to an illegal address. 170 .RE 171 172 .sp 173 .ne 2 174 .na 175 \fB\fBEINTR\fR\fR 176 .ad 177 .RS 16n 178 A signal was caught during the execution of the \fButimes()\fR, 179 \fBlutimes()\fR, \fBfutimes()\fR, 180 \fBfutimesat()\fR, \fBfutimens()\fR, or \fButimensat()\fR functions. 181 .RE 182 183 .sp 184 .ne 2 185 .na 186 \fB\fBEINVAL\fR\fR 187 .ad 188 .RS 16n 189 The number of microseconds specified in one or both of the \fBtimeval\fR 190 structures pointed to by \fItimes\fR was greater than or equal to 1,000,000 or 191 less than 0. The number of nanoseconds specified in one or both of the 192 \fBtimespec_t\fR structures pointed to by \fInstimes\fR was greater than or 193 equal to 1,000,000,000 or less than 0. 194 .RE 195 196 .sp 197 .ne 2 198 .na 199 \fB\fBEIO\fR\fR 200 .ad 201 .RS 16n 202 An I/O error occurred while reading from or writing to the file system. 203 .RE 204 205 .sp 206 .ne 2 207 .na 208 \fB\fBELOOP\fR\fR 209 .ad 210 .RS 16n 211 Too many symbolic links were encountered in resolving \fIpath\fR. 212 .RE 213 214 .sp 215 .ne 2 216 .na 217 \fB\fBENAMETOOLONG\fR\fR 218 .ad 219 .RS 16n 220 The length of the \fIpath\fR argument exceeds {\fIPATH_MAX\fR} or a pathname 221 component is longer than {\fINAME_MAX\fR}. 222 .RE 223 224 .sp 225 .ne 2 226 .na 227 \fB\fBENOLINK\fR\fR 228 .ad 229 .RS 16n 230 The \fIpath\fR argument points to a remote machine and the link to that machine 231 is no longer active. 232 .RE 233 234 .sp 235 .ne 2 236 .na 237 \fB\fBENOENT\fR\fR 238 .ad 239 .RS 16n 240 A component of \fIpath\fR does not name an existing file or \fIpath\fR is an 241 empty string. 242 .RE 243 244 .sp 245 .ne 2 246 .na 247 \fB\fBENOTDIR\fR\fR 248 .ad 249 .RS 16n 250 A component of the path prefix is not a directory or the \fIpath\fR argument is 251 relative and the \fIfildes\fR argument is not \fBAT_FDCWD\fR or does not refer 252 to a valid directory. 253 .RE 254 255 .sp 256 .ne 2 257 .na 258 \fB\fBEPERM\fR\fR 259 .ad 260 .RS 16n 261 The \fItimes\fR argument is not a null pointer and the calling process's 262 effective user \fBID\fR has write access to the file but does not match the 263 owner of the file and the calling process does not have the appropriate 264 privileges. 265 .RE 266 267 .sp 268 .ne 2 269 .na 270 \fB\fBEROFS\fR\fR 271 .ad 272 .RS 16n 273 The file system containing the file is read-only. 274 .RE 275 276 .sp 277 .LP 278 The \fButimes()\fR, \fBfutimesat()\fR, and \fButimensat()\fR functions may fail 279 if: 280 .sp 281 .ne 2 282 .na 283 \fB\fBENAMETOOLONG\fR\fR 284 .ad 285 .RS 16n 286 Path name resolution of a symbolic link produced an intermediate result whose 287 length exceeds {\fIPATH_MAX\fR}. 288 .RE 289 290 .SH ATTRIBUTES 291 See \fBattributes\fR(5) for descriptions of the following attributes: 292 .sp 293 294 .sp 295 .TS 296 box; 297 c | c 298 l | l . 299 ATTRIBUTE TYPE ATTRIBUTE VALUE 300 _ 301 Interface Stability Committed 302 _ 303 Standard See below. 304 .TE 305 306 .sp 307 .LP 308 For \fButimes()\fR, \fButimensat()\fR and \fBfutimensat()\fR, see \fBstandards\fR(5). 309 .SH SEE ALSO 310 fBstat\fR(2), \fButime\fR(2), \fBattributes\fR(5), 311 \fBfsattr\fR(5), \fBstandards\fR(5)