| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | | - |
| 22 | #include <config.h> | - |
| 23 | | - |
| 24 | #define _GL_UTIMENS_INLINE _GL_EXTERN_INLINE | - |
| 25 | #include "utimens.h" | - |
| 26 | | - |
| 27 | #include <errno.h> | - |
| 28 | #include <fcntl.h> | - |
| 29 | #include <stdbool.h> | - |
| 30 | #include <sys/stat.h> | - |
| 31 | #include <sys/time.h> | - |
| 32 | #include <unistd.h> | - |
| 33 | #include <utime.h> | - |
| 34 | | - |
| 35 | #include "stat-time.h" | - |
| 36 | #include "timespec.h" | - |
| 37 | | - |
| 38 | | - |
| 39 | | - |
| 40 | | - |
| 41 | | - |
| 42 | #if ((defined _WIN32 || defined __WIN32__) \ | - |
| 43 | && ! defined __CYGWIN__ && ! defined EMACS_CONFIGURATION) | - |
| 44 | # define USE_SETFILETIME | - |
| 45 | # define WIN32_LEAN_AND_MEAN | - |
| 46 | # include <windows.h> | - |
| 47 | # if GNULIB_MSVC_NOTHROW | - |
| 48 | # include "msvc-nothrow.h" | - |
| 49 | # else | - |
| 50 | # include <io.h> | - |
| 51 | # endif | - |
| 52 | #endif | - |
| 53 | | - |
| 54 | | - |
| 55 | #undef futimens | - |
| 56 | #undef utimensat | - |
| 57 | | - |
| 58 | | - |
| 59 | | - |
| 60 | #ifndef REPLACE_FUNC_STAT_FILE | - |
| 61 | # define REPLACE_FUNC_STAT_FILE 0 | - |
| 62 | #endif | - |
| 63 | | - |
| 64 | #if HAVE_UTIMENSAT || HAVE_FUTIMENS | - |
| 65 | | - |
| 66 | | - |
| 67 | | - |
| 68 | | - |
| 69 | | - |
| 70 | | - |
| 71 | | - |
| 72 | | - |
| 73 | | - |
| 74 | | - |
| 75 | | - |
| 76 | static int utimensat_works_really; | - |
| 77 | static int lutimensat_works_really; | - |
| 78 | #endif /* HAVE_UTIMENSAT || HAVE_FUTIMENS */ | - |
| 79 | | - |
| 80 | | - |
| 81 | | - |
| 82 | | - |
| 83 | | - |
| 84 | | - |
| 85 | | - |
| 86 | | - |
| 87 | static int | - |
| 88 | validate_timespec (struct timespec timespec[2]) | - |
| 89 | { | - |
| 90 | int result = 0; | - |
| 91 | int utime_omit_count = 0; | - |
| 92 | if ((timespec[0].tv_nsec != UTIME_NOW| TRUE | evaluated 37881 times by 2 tests | | FALSE | never evaluated |
| 0-37881 |
| 93 | && timespec[0].tv_nsec != UTIME_OMIT| TRUE | evaluated 37881 times by 2 tests | | FALSE | never evaluated |
| 0-37881 |
| 94 | && ! (0 <= timespec[0].tv_nsec| TRUE | evaluated 37881 times by 2 tests | | FALSE | never evaluated |
| 0-37881 |
| 95 | && timespec[0].tv_nsec < TIMESPEC_RESOLUTION))| TRUE | evaluated 37881 times by 2 tests | | FALSE | never evaluated |
| 0-37881 |
| 96 | || (timespec[1].tv_nsec != UTIME_NOW| TRUE | evaluated 37881 times by 2 tests | | FALSE | never evaluated |
| 0-37881 |
| 97 | && timespec[1].tv_nsec != UTIME_OMIT| TRUE | evaluated 37881 times by 2 tests | | FALSE | never evaluated |
| 0-37881 |
| 98 | && ! (0 <= timespec[1].tv_nsec| TRUE | evaluated 37881 times by 2 tests | | FALSE | never evaluated |
| 0-37881 |
| 99 | && timespec[1].tv_nsec < TIMESPEC_RESOLUTION)))| TRUE | evaluated 37881 times by 2 tests | | FALSE | never evaluated |
| 0-37881 |
| 100 | { | - |
| 101 | errno = EINVAL; | - |
| 102 | return -1; never executed: return -1; | 0 |
| 103 | } | - |
| 104 | | - |
| 105 | | - |
| 106 | | - |
| 107 | | - |
| 108 | if (timespec[0].tv_nsec == UTIME_NOW| TRUE | never evaluated | | FALSE | evaluated 37881 times by 2 tests |
| 0-37881 |
| 109 | || timespec[0].tv_nsec == UTIME_OMIT)| TRUE | never evaluated | | FALSE | evaluated 37881 times by 2 tests |
| 0-37881 |
| 110 | { | - |
| 111 | timespec[0].tv_sec = 0; | - |
| 112 | result = 1; | - |
| 113 | if (timespec[0].tv_nsec == UTIME_OMIT)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 114 | utime_omit_count++; never executed: utime_omit_count++; | 0 |
| 115 | } never executed: end of block | 0 |
| 116 | if (timespec[1].tv_nsec == UTIME_NOW| TRUE | never evaluated | | FALSE | evaluated 37881 times by 2 tests |
| 0-37881 |
| 117 | || timespec[1].tv_nsec == UTIME_OMIT)| TRUE | never evaluated | | FALSE | evaluated 37881 times by 2 tests |
| 0-37881 |
| 118 | { | - |
| 119 | timespec[1].tv_sec = 0; | - |
| 120 | result = 1; | - |
| 121 | if (timespec[1].tv_nsec == UTIME_OMIT)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 122 | utime_omit_count++; never executed: utime_omit_count++; | 0 |
| 123 | } never executed: end of block | 0 |
| 124 | return result + (utime_omit_count == 1);executed 37881 times by 2 tests: return result + (utime_omit_count == 1); | 37881 |
| 125 | } | - |
| 126 | | - |
| 127 | | - |
| 128 | | - |
| 129 | | - |
| 130 | | - |
| 131 | | - |
| 132 | | - |
| 133 | static bool | - |
| 134 | update_timespec (struct stat const *statbuf, struct timespec *ts[2]) | - |
| 135 | { | - |
| 136 | struct timespec *timespec = *ts; | - |
| 137 | if (timespec[0].tv_nsec == UTIME_OMIT| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 138 | && timespec[1].tv_nsec == UTIME_OMIT)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 139 | return true; never executed: return 1 ; | 0 |
| 140 | if (timespec[0].tv_nsec == UTIME_NOW| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 141 | && timespec[1].tv_nsec == UTIME_NOW)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 142 | { | - |
| 143 | *ts = NULL; | - |
| 144 | return false; never executed: return 0 ; | 0 |
| 145 | } | - |
| 146 | | - |
| 147 | if (timespec[0].tv_nsec == UTIME_OMIT)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 148 | timespec[0] = get_stat_atime (statbuf); never executed: timespec[0] = get_stat_atime (statbuf); | 0 |
| 149 | else if (timespec[0].tv_nsec == UTIME_NOW)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 150 | gettime (×pec[0]); never executed: gettime (×pec[0]); | 0 |
| 151 | | - |
| 152 | if (timespec[1].tv_nsec == UTIME_OMIT)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 153 | timespec[1] = get_stat_mtime (statbuf); never executed: timespec[1] = get_stat_mtime (statbuf); | 0 |
| 154 | else if (timespec[1].tv_nsec == UTIME_NOW)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 155 | gettime (×pec[1]); never executed: gettime (×pec[1]); | 0 |
| 156 | | - |
| 157 | return false; never executed: return 0 ; | 0 |
| 158 | } | - |
| 159 | | - |
| 160 | | - |
| 161 | | - |
| 162 | | - |
| 163 | | - |
| 164 | | - |
| 165 | | - |
| 166 | | - |
| 167 | | - |
| 168 | | - |
| 169 | | - |
| 170 | int | - |
| 171 | fdutimens (int fd, char const *file, struct timespec const timespec[2]) | - |
| 172 | { | - |
| 173 | struct timespec adjusted_timespec[2]; | - |
| 174 | struct timespec *ts = timespec ? adjusted_timespec : NULL;| TRUE | evaluated 37878 times by 2 tests | | FALSE | never evaluated |
| 0-37878 |
| 175 | int adjustment_needed = 0; | - |
| 176 | struct stat st; | - |
| 177 | | - |
| 178 | if (ts)| TRUE | evaluated 37878 times by 2 tests | | FALSE | never evaluated |
| 0-37878 |
| 179 | { | - |
| 180 | adjusted_timespec[0] = timespec[0]; | - |
| 181 | adjusted_timespec[1] = timespec[1]; | - |
| 182 | adjustment_needed = validate_timespec (ts); | - |
| 183 | }executed 37878 times by 2 tests: end of block | 37878 |
| 184 | if (adjustment_needed < 0)| TRUE | never evaluated | | FALSE | evaluated 37878 times by 2 tests |
| 0-37878 |
| 185 | return -1; never executed: return -1; | 0 |
| 186 | | - |
| 187 | | - |
| 188 | | - |
| 189 | | - |
| 190 | if (fd < 0 && !file)| TRUE | evaluated 33949 times by 2 tests | | FALSE | evaluated 3929 times by 2 tests |
| TRUE | never evaluated | | FALSE | evaluated 33949 times by 2 tests |
| 0-33949 |
| 191 | { | - |
| 192 | errno = EBADF; | - |
| 193 | return -1; never executed: return -1; | 0 |
| 194 | } | - |
| 195 | | - |
| 196 | | - |
| 197 | | - |
| 198 | | - |
| 199 | | - |
| 200 | | - |
| 201 | | - |
| 202 | | - |
| 203 | | - |
| 204 | | - |
| 205 | | - |
| 206 | #if HAVE_BUGGY_NFS_TIME_STAMPS | - |
| 207 | if (fd < 0) | - |
| 208 | sync (); | - |
| 209 | else | - |
| 210 | fsync (fd); | - |
| 211 | #endif | - |
| 212 | | - |
| 213 | | - |
| 214 | | - |
| 215 | | - |
| 216 | | - |
| 217 | | - |
| 218 | #if HAVE_UTIMENSAT || HAVE_FUTIMENS | - |
| 219 | if (0 <= utimensat_works_really)| TRUE | evaluated 37878 times by 2 tests | | FALSE | never evaluated |
| 0-37878 |
| 220 | { | - |
| 221 | int result; | - |
| 222 | # if __linux__ || __sun | - |
| 223 | | - |
| 224 | | - |
| 225 | | - |
| 226 | | - |
| 227 | | - |
| 228 | | - |
| 229 | | - |
| 230 | | - |
| 231 | | - |
| 232 | | - |
| 233 | | - |
| 234 | | - |
| 235 | if (adjustment_needed == 2)| TRUE | never evaluated | | FALSE | evaluated 37878 times by 2 tests |
| 0-37878 |
| 236 | { | - |
| 237 | if (fd < 0 ? stat (file, &st) : fstat (fd, &st))| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 238 | return -1; never executed: return -1; | 0 |
| 239 | if (ts[0].tv_nsec == UTIME_OMIT)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 240 | ts[0] = get_stat_atime (&st); never executed: ts[0] = get_stat_atime (&st); | 0 |
| 241 | else if (ts[1].tv_nsec == UTIME_OMIT)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 242 | ts[1] = get_stat_mtime (&st); never executed: ts[1] = get_stat_mtime (&st); | 0 |
| 243 | | - |
| 244 | adjustment_needed++; | - |
| 245 | } never executed: end of block | 0 |
| 246 | # endif | - |
| 247 | # if HAVE_UTIMENSAT | - |
| 248 | if (fd < 0)| TRUE | evaluated 33949 times by 2 tests | | FALSE | evaluated 3929 times by 2 tests |
| 3929-33949 |
| 249 | { | - |
| 250 | result = utimensat (AT_FDCWD, file, ts, 0); | - |
| 251 | # ifdef __linux__ | - |
| 252 | | - |
| 253 | | - |
| 254 | | - |
| 255 | | - |
| 256 | | - |
| 257 | | - |
| 258 | | - |
| 259 | if (0 < result)| TRUE | never evaluated | | FALSE | evaluated 33949 times by 2 tests |
| 0-33949 |
| 260 | errno = ENOSYS; never executed: (*__errno_location ()) = 38 ; | 0 |
| 261 | # endif /* __linux__ */ | - |
| 262 | if (result == 0 || errno != ENOSYS)| TRUE | evaluated 33949 times by 2 tests | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0-33949 |
| 263 | { | - |
| 264 | utimensat_works_really = 1; | - |
| 265 | return result;executed 33949 times by 2 tests: return result; | 33949 |
| 266 | } | - |
| 267 | } never executed: end of block | 0 |
| 268 | # endif /* HAVE_UTIMENSAT */ | - |
| 269 | # if HAVE_FUTIMENS | - |
| 270 | if (0 <= fd)| TRUE | evaluated 3929 times by 2 tests | | FALSE | never evaluated |
| 0-3929 |
| 271 | { | - |
| 272 | result = futimens (fd, ts); | - |
| 273 | # ifdef __linux__ | - |
| 274 | | - |
| 275 | if (0 < result)| TRUE | never evaluated | | FALSE | evaluated 3929 times by 2 tests |
| 0-3929 |
| 276 | errno = ENOSYS; never executed: (*__errno_location ()) = 38 ; | 0 |
| 277 | # endif /* __linux__ */ | - |
| 278 | if (result == 0 || errno != ENOSYS)| TRUE | evaluated 3929 times by 2 tests | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0-3929 |
| 279 | { | - |
| 280 | utimensat_works_really = 1; | - |
| 281 | return result;executed 3929 times by 2 tests: return result; | 3929 |
| 282 | } | - |
| 283 | } never executed: end of block | 0 |
| 284 | # endif /* HAVE_FUTIMENS */ | - |
| 285 | } never executed: end of block | 0 |
| 286 | utimensat_works_really = -1; | - |
| 287 | lutimensat_works_really = -1; | - |
| 288 | #endif /* HAVE_UTIMENSAT || HAVE_FUTIMENS */ | - |
| 289 | | - |
| 290 | #ifdef USE_SETFILETIME | - |
| 291 | | - |
| 292 | | - |
| 293 | | - |
| 294 | if (0 <= fd) | - |
| 295 | { | - |
| 296 | HANDLE handle; | - |
| 297 | FILETIME current_time; | - |
| 298 | FILETIME last_access_time; | - |
| 299 | FILETIME last_write_time; | - |
| 300 | | - |
| 301 | handle = (HANDLE) _get_osfhandle (fd); | - |
| 302 | if (handle == INVALID_HANDLE_VALUE) | - |
| 303 | { | - |
| 304 | errno = EBADF; | - |
| 305 | return -1; | - |
| 306 | } | - |
| 307 | | - |
| 308 | if (ts == NULL || ts[0].tv_nsec == UTIME_NOW || ts[1].tv_nsec == UTIME_NOW) | - |
| 309 | { | - |
| 310 | | - |
| 311 | | - |
| 312 | | - |
| 313 | | - |
| 314 | | - |
| 315 | GetSystemTimeAsFileTime (¤t_time); | - |
| 316 | } | - |
| 317 | | - |
| 318 | if (ts == NULL || ts[0].tv_nsec == UTIME_NOW) | - |
| 319 | { | - |
| 320 | last_access_time = current_time; | - |
| 321 | } | - |
| 322 | else if (ts[0].tv_nsec == UTIME_OMIT) | - |
| 323 | { | - |
| 324 | last_access_time.dwLowDateTime = 0; | - |
| 325 | last_access_time.dwHighDateTime = 0; | - |
| 326 | } | - |
| 327 | else | - |
| 328 | { | - |
| 329 | ULONGLONG time_since_16010101 = | - |
| 330 | (ULONGLONG) ts[0].tv_sec * 10000000 + ts[0].tv_nsec / 100 + 116444736000000000LL; | - |
| 331 | last_access_time.dwLowDateTime = (DWORD) time_since_16010101; | - |
| 332 | last_access_time.dwHighDateTime = time_since_16010101 >> 32; | - |
| 333 | } | - |
| 334 | | - |
| 335 | if (ts == NULL || ts[1].tv_nsec == UTIME_NOW) | - |
| 336 | { | - |
| 337 | last_write_time = current_time; | - |
| 338 | } | - |
| 339 | else if (ts[1].tv_nsec == UTIME_OMIT) | - |
| 340 | { | - |
| 341 | last_write_time.dwLowDateTime = 0; | - |
| 342 | last_write_time.dwHighDateTime = 0; | - |
| 343 | } | - |
| 344 | else | - |
| 345 | { | - |
| 346 | ULONGLONG time_since_16010101 = | - |
| 347 | (ULONGLONG) ts[1].tv_sec * 10000000 + ts[1].tv_nsec / 100 + 116444736000000000LL; | - |
| 348 | last_write_time.dwLowDateTime = (DWORD) time_since_16010101; | - |
| 349 | last_write_time.dwHighDateTime = time_since_16010101 >> 32; | - |
| 350 | } | - |
| 351 | | - |
| 352 | if (SetFileTime (handle, NULL, &last_access_time, &last_write_time)) | - |
| 353 | return 0; | - |
| 354 | else | - |
| 355 | { | - |
| 356 | DWORD sft_error = GetLastError (); | - |
| 357 | #if 0 | - |
| 358 | fprintf (stderr, "fdutimens SetFileTime error 0x%x\n", (unsigned int) sft_error); | - |
| 359 | #endif | - |
| 360 | switch (sft_error) | - |
| 361 | { | - |
| 362 | case ERROR_ACCESS_DENIED: | - |
| 363 | errno = EACCES; | - |
| 364 | break; | - |
| 365 | default: | - |
| 366 | errno = EINVAL; | - |
| 367 | break; | - |
| 368 | } | - |
| 369 | return -1; | - |
| 370 | } | - |
| 371 | } | - |
| 372 | #endif | - |
| 373 | | - |
| 374 | | - |
| 375 | | - |
| 376 | | - |
| 377 | | - |
| 378 | if (adjustment_needed || (REPLACE_FUNC_STAT_FILE && fd < 0)) dead code: fd < 0 | TRUE | never evaluated | | FALSE | never evaluated |
| - |
| 379 | { | - |
| 380 | if (adjustment_needed != 3| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 381 | && (fd < 0 ? stat (file, &st) : fstat (fd, &st)))| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 382 | return -1; never executed: return -1; | 0 |
| 383 | if (ts && update_timespec (&st, &ts))| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 384 | return 0; never executed: return 0; | 0 |
| 385 | } never executed: end of block | 0 |
| 386 | | - |
| 387 | { | - |
| 388 | #if HAVE_FUTIMESAT || HAVE_WORKING_UTIMES | - |
| 389 | struct timeval timeval[2]; | - |
| 390 | struct timeval *t; | - |
| 391 | if (ts)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 392 | { | - |
| 393 | timeval[0].tv_sec = ts[0].tv_sec; | - |
| 394 | timeval[0].tv_usec = ts[0].tv_nsec / 1000; | - |
| 395 | timeval[1].tv_sec = ts[1].tv_sec; | - |
| 396 | timeval[1].tv_usec = ts[1].tv_nsec / 1000; | - |
| 397 | t = timeval; | - |
| 398 | } never executed: end of block | 0 |
| 399 | else | - |
| 400 | t = NULL; never executed: t = ((void *)0) ; | 0 |
| 401 | | - |
| 402 | if (fd < 0)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 403 | { | - |
| 404 | # if HAVE_FUTIMESAT | - |
| 405 | return futimesat (AT_FDCWD, file, t); never executed: return futimesat ( -100 , file, t); | 0 |
| 406 | # endif | - |
| 407 | } | - |
| 408 | else | - |
| 409 | { | - |
| 410 | | - |
| 411 | | - |
| 412 | | - |
| 413 | | - |
| 414 | | - |
| 415 | | - |
| 416 | | - |
| 417 | | - |
| 418 | | - |
| 419 | | - |
| 420 | | - |
| 421 | # if (HAVE_FUTIMESAT && !FUTIMESAT_NULL_BUG) || HAVE_FUTIMES | - |
| 422 | # if HAVE_FUTIMESAT && !FUTIMESAT_NULL_BUG | - |
| 423 | # undef futimes | - |
| 424 | # define futimes(fd, t) futimesat (fd, NULL, t) | - |
| 425 | # endif | - |
| 426 | if (futimes (fd, t) == 0)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 427 | { | - |
| 428 | # if __linux__ && __GLIBC__ | - |
| 429 | | - |
| 430 | | - |
| 431 | | - |
| 432 | | - |
| 433 | | - |
| 434 | if (t)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 435 | { | - |
| 436 | bool abig = 500000 <= t[0].tv_usec; | - |
| 437 | bool mbig = 500000 <= t[1].tv_usec; | - |
| 438 | if ((abig | mbig) && fstat (fd, &st) == 0)| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 439 | { | - |
| 440 | | - |
| 441 | | - |
| 442 | time_t adiff = st.st_atime - t[0].tv_sec; | - |
| 443 | time_t mdiff = st.st_mtime - t[1].tv_sec; | - |
| 444 | | - |
| 445 | struct timeval *tt = NULL; | - |
| 446 | struct timeval truncated_timeval[2]; | - |
| 447 | truncated_timeval[0] = t[0]; | - |
| 448 | truncated_timeval[1] = t[1]; | - |
| 449 | if (abig && adiff == 1 && get_stat_atime_ns (&st) == 0)| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 450 | { | - |
| 451 | tt = truncated_timeval; | - |
| 452 | tt[0].tv_usec = 0; | - |
| 453 | } never executed: end of block | 0 |
| 454 | if (mbig && mdiff == 1 && get_stat_mtime_ns (&st) == 0)| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 455 | { | - |
| 456 | tt = truncated_timeval; | - |
| 457 | tt[1].tv_usec = 0; | - |
| 458 | } never executed: end of block | 0 |
| 459 | if (tt)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 460 | futimes (fd, tt); never executed: futimesat (fd, ((void *)0) , tt); | 0 |
| 461 | } never executed: end of block | 0 |
| 462 | } never executed: end of block | 0 |
| 463 | # endif | - |
| 464 | | - |
| 465 | return 0; never executed: return 0; | 0 |
| 466 | } | - |
| 467 | # endif | - |
| 468 | } never executed: end of block | 0 |
| 469 | #endif /* HAVE_FUTIMESAT || HAVE_WORKING_UTIMES */ | - |
| 470 | | - |
| 471 | if (!file)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 472 | { | - |
| 473 | #if ! ((HAVE_FUTIMESAT && !FUTIMESAT_NULL_BUG) \ | - |
| 474 | || (HAVE_WORKING_UTIMES && HAVE_FUTIMES)) | - |
| 475 | errno = ENOSYS; | - |
| 476 | #endif | - |
| 477 | return -1; never executed: return -1; | 0 |
| 478 | } | - |
| 479 | | - |
| 480 | #ifdef USE_SETFILETIME | - |
| 481 | return _gl_utimens_windows (file, ts); | - |
| 482 | #elif HAVE_WORKING_UTIMES | - |
| 483 | return utimes (file, t); never executed: return utimes (file, t); | 0 |
| 484 | #else | - |
| 485 | { | - |
| 486 | struct utimbuf utimbuf; | - |
| 487 | struct utimbuf *ut; | - |
| 488 | if (ts) | - |
| 489 | { | - |
| 490 | utimbuf.actime = ts[0].tv_sec; | - |
| 491 | utimbuf.modtime = ts[1].tv_sec; | - |
| 492 | ut = &utimbuf; | - |
| 493 | } | - |
| 494 | else | - |
| 495 | ut = NULL; | - |
| 496 | | - |
| 497 | return utime (file, ut); | - |
| 498 | } | - |
| 499 | #endif /* !HAVE_WORKING_UTIMES */ | - |
| 500 | } | - |
| 501 | } | - |
| 502 | | - |
| 503 | | - |
| 504 | | - |
| 505 | int | - |
| 506 | utimens (char const *file, struct timespec const timespec[2]) | - |
| 507 | { | - |
| 508 | return fdutimens (-1, file, timespec);executed 33949 times by 2 tests: return fdutimens (-1, file, timespec); | 33949 |
| 509 | } | - |
| 510 | | - |
| 511 | | - |
| 512 | | - |
| 513 | | - |
| 514 | | - |
| 515 | int | - |
| 516 | lutimens (char const *file, struct timespec const timespec[2]) | - |
| 517 | { | - |
| 518 | struct timespec adjusted_timespec[2]; | - |
| 519 | struct timespec *ts = timespec ? adjusted_timespec : NULL;| TRUE | evaluated 3 times by 2 tests | | FALSE | never evaluated |
| 0-3 |
| 520 | int adjustment_needed = 0; | - |
| 521 | struct stat st; | - |
| 522 | | - |
| 523 | if (ts)| TRUE | evaluated 3 times by 2 tests | | FALSE | never evaluated |
| 0-3 |
| 524 | { | - |
| 525 | adjusted_timespec[0] = timespec[0]; | - |
| 526 | adjusted_timespec[1] = timespec[1]; | - |
| 527 | adjustment_needed = validate_timespec (ts); | - |
| 528 | }executed 3 times by 2 tests: end of block | 3 |
| 529 | if (adjustment_needed < 0)| TRUE | never evaluated | | FALSE | evaluated 3 times by 2 tests |
| 0-3 |
| 530 | return -1; never executed: return -1; | 0 |
| 531 | | - |
| 532 | | - |
| 533 | | - |
| 534 | | - |
| 535 | | - |
| 536 | | - |
| 537 | #if HAVE_UTIMENSAT | - |
| 538 | if (0 <= lutimensat_works_really)| TRUE | evaluated 3 times by 2 tests | | FALSE | never evaluated |
| 0-3 |
| 539 | { | - |
| 540 | int result; | - |
| 541 | # if __linux__ || __sun | - |
| 542 | | - |
| 543 | | - |
| 544 | | - |
| 545 | | - |
| 546 | | - |
| 547 | | - |
| 548 | | - |
| 549 | | - |
| 550 | | - |
| 551 | | - |
| 552 | | - |
| 553 | | - |
| 554 | if (adjustment_needed == 2)| TRUE | never evaluated | | FALSE | evaluated 3 times by 2 tests |
| 0-3 |
| 555 | { | - |
| 556 | if (lstat (file, &st))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 557 | return -1; never executed: return -1; | 0 |
| 558 | if (ts[0].tv_nsec == UTIME_OMIT)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 559 | ts[0] = get_stat_atime (&st); never executed: ts[0] = get_stat_atime (&st); | 0 |
| 560 | else if (ts[1].tv_nsec == UTIME_OMIT)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 561 | ts[1] = get_stat_mtime (&st); never executed: ts[1] = get_stat_mtime (&st); | 0 |
| 562 | | - |
| 563 | adjustment_needed++; | - |
| 564 | } never executed: end of block | 0 |
| 565 | # endif | - |
| 566 | result = utimensat (AT_FDCWD, file, ts, AT_SYMLINK_NOFOLLOW); | - |
| 567 | # ifdef __linux__ | - |
| 568 | | - |
| 569 | | - |
| 570 | | - |
| 571 | | - |
| 572 | | - |
| 573 | | - |
| 574 | | - |
| 575 | if (0 < result)| TRUE | never evaluated | | FALSE | evaluated 3 times by 2 tests |
| 0-3 |
| 576 | errno = ENOSYS; never executed: (*__errno_location ()) = 38 ; | 0 |
| 577 | # endif | - |
| 578 | if (result == 0 || errno != ENOSYS)| TRUE | evaluated 3 times by 2 tests | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0-3 |
| 579 | { | - |
| 580 | utimensat_works_really = 1; | - |
| 581 | lutimensat_works_really = 1; | - |
| 582 | return result;executed 3 times by 2 tests: return result; | 3 |
| 583 | } | - |
| 584 | } never executed: end of block | 0 |
| 585 | lutimensat_works_really = -1; | - |
| 586 | #endif /* HAVE_UTIMENSAT */ | - |
| 587 | | - |
| 588 | | - |
| 589 | | - |
| 590 | | - |
| 591 | | - |
| 592 | if (adjustment_needed || REPLACE_FUNC_STAT_FILE)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 593 | { | - |
| 594 | if (adjustment_needed != 3 && lstat (file, &st))| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 595 | return -1; never executed: return -1; | 0 |
| 596 | if (ts && update_timespec (&st, &ts))| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 597 | return 0; never executed: return 0; | 0 |
| 598 | } never executed: end of block | 0 |
| 599 | | - |
| 600 | | - |
| 601 | | - |
| 602 | #if HAVE_LUTIMES && !HAVE_UTIMENSAT | - |
| 603 | { | - |
| 604 | struct timeval timeval[2]; | - |
| 605 | struct timeval *t; | - |
| 606 | int result; | - |
| 607 | if (ts) | - |
| 608 | { | - |
| 609 | timeval[0].tv_sec = ts[0].tv_sec; | - |
| 610 | timeval[0].tv_usec = ts[0].tv_nsec / 1000; | - |
| 611 | timeval[1].tv_sec = ts[1].tv_sec; | - |
| 612 | timeval[1].tv_usec = ts[1].tv_nsec / 1000; | - |
| 613 | t = timeval; | - |
| 614 | } | - |
| 615 | else | - |
| 616 | t = NULL; | - |
| 617 | | - |
| 618 | result = lutimes (file, t); | - |
| 619 | if (result == 0 || errno != ENOSYS) | - |
| 620 | return result; | - |
| 621 | } | - |
| 622 | #endif /* HAVE_LUTIMES && !HAVE_UTIMENSAT */ | - |
| 623 | | - |
| 624 | | - |
| 625 | if (!(adjustment_needed || REPLACE_FUNC_STAT_FILE) && lstat (file, &st))| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 626 | return -1; never executed: return -1; | 0 |
| 627 | if (!S_ISLNK (st.st_mode))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 628 | return fdutimens (-1, file, ts); never executed: return fdutimens (-1, file, ts); | 0 |
| 629 | errno = ENOSYS; | - |
| 630 | return -1; never executed: return -1; | 0 |
| 631 | } | - |
| | |