diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -315,7 +315,19 @@ } TimePoint<> basic_file_status::getLastAccessedTime() const { - return toTimePoint(fs_st_atime, fs_st_atime_nsec); + // There is a bug in fuse-overlayfs, which is a filesystem mostly used by + // containers, which causes the value of atime to be incorrect in some + // specific scenarios. The value of mtime is not affected, so we can + // workaround this by returning mtime if its newer than atime. + // https://github.com/containers/fuse-overlayfs/issues/259 + // + // This should be a no-op on all other file systems, since atime should + // always be as new or newer than mtime. + auto ATime = toTimePoint(fs_st_atime, fs_st_atime_nsec); + auto MTime = getLastModificationTime(); + if (MTime > ATime) + return MTime; + return ATime; } TimePoint<> basic_file_status::getLastModificationTime() const {