From 33f695c435f3a49abbb6f1bf763c94ace8d026b9 Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Sun, 12 Jun 2016 18:57:23 -0700 Subject: [PATCH] Use O_NOATIME on directories too, where available, to avoid bumping dir access times during scans. --- src/core/unixfsservices.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/unixfsservices.cpp b/src/core/unixfsservices.cpp index dc2d72e..91b3098 100644 --- a/src/core/unixfsservices.cpp +++ b/src/core/unixfsservices.cpp @@ -190,8 +190,16 @@ void cUnixFSServices::ReadDir(const TSTRING& strFilenameC, std::vector& #endif //Get all the filenames - DIR* dp; + DIR* dp=0; + +#if defined(O_DIRECTORY) && defined(O_NOATIME) + //dfd will be autoclosed by closedir(), should not be explicitly closed. + int dfd=open(strFilename.c_str(), O_RDONLY|O_DIRECTORY|O_NOATIME); + if (dfd>0) + dp = fdopendir(dfd); +#else dp = opendir( strFilename.c_str() ); +#endif if (dp == NULL) {