From 45fad738641bf4c9c0df11737239876a38cf289d Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Wed, 4 Apr 2018 12:32:23 +0100 Subject: [PATCH] cache: If nsec is zero, don't use it for comparisons nanosecond precision on files isn't always supported, for example if we're on a squashfs. In that case we get 0 in tv_nsec. In the unlucky case that the file *is* modified when nsec is actually 0, we'll report that the cache is good. --- src/fccache.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fccache.c b/src/fccache.c index 7abb750..c88c926 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -738,10 +738,14 @@ FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat) dir_stat = &dir_static; } #ifdef HAVE_STRUCT_STAT_ST_MTIM - fnano = (cache->checksum_nano == dir_stat->st_mtim.tv_nsec); + fnano = (cache->checksum_nano == dir_stat->st_mtim.tv_nsec) || (dir_stat->st_mtim.tv_nsec == 0); if (FcDebug () & FC_DBG_CACHE) + { printf ("FcCacheTimeValid dir \"%s\" cache checksum %d.%ld dir checksum %d.%ld\n", FcCacheDir (cache), cache->checksum, (long)cache->checksum_nano, (int) dir_stat->st_mtime, dir_stat->st_mtim.tv_nsec); + if (dir_stat->st_mtim.tv_nsec == 0) + printf ("tv_nsec == 0, ignoring nanoseconds\n"); + } #else if (FcDebug () & FC_DBG_CACHE) printf ("FcCacheTimeValid dir \"%s\" cache checksum %d dir checksum %d\n", -- 2.15.1