-static int utimensat_ctime_really;
-
-/* Determine whether the kernel has a ctime bug. ST1 and ST2
- correspond to stat data before and after a successful time change.
- TIMES contains the timestamps that were used during the time change
- (mtime will be UTIME_OMIT). Update the cache variable if there is
- conclusive evidence of the kernel working or being buggy. Return
- true if TIMES has been updated and another kernel call is needed,
- whether or not the kernel is known to have the bug. */
-static bool
-detect_ctime_bug (struct stat *st1, struct stat *st2, struct timespec times[2])
-{
- struct timespec now;
- if (st1->st_ctime != st2->st_ctime
- || get_stat_ctime_ns (st1) != get_stat_ctime_ns (st2))
- {
- utimensat_ctime_really = 1;
- return false;
- }
- /* The results are inconclusive if the ctime in st1 is within a file
- system quantization window of now. For FAT, this is 2 seconds,
- for systems with sub-second resolution, a typical resolution is
- 10 milliseconds; to be safe we declare an inconsistent result if
- ctime is within a 20 millisecond window. Avoid an extra gettime
- call if atime makes sense. It is unlikely that the original
- ctime is later than now, but rather than deal with the overflow,
- we treat that as consistent evidence of the bug. */
- if (times[0].tv_nsec == UTIME_NOW)
- now = get_stat_atime (st2);
- else
- gettime (&now);
- if (now.tv_sec < st2->st_ctime
- || 2 < now.tv_sec - st2->st_ctime
- || (get_stat_ctime_ns (st2)
- && now.tv_sec - st2->st_ctime < 2
- && (20000000 < (1000000000 * (now.tv_sec - st2->st_ctime)
- + now.tv_nsec - get_stat_ctime_ns (st2)))))
- utimensat_ctime_really = -1;
- times[1] = get_stat_mtime (st2);
- return true;
-}