If O_NOATIME use fails with EPERM, retry without it.

This commit is contained in:
Andrea Mazzoleni 2012-11-04 00:26:30 +01:00
parent db6ff47062
commit 2d6528fe90
4 changed files with 25 additions and 14 deletions

View file

@ -137,12 +137,19 @@
#define STAT_NSEC(st) -1
#endif
#ifdef O_NOATIME
/**
* Defines O_NOATIME if absent.
* O_NOATIME is used to open files in RDONLY mode avoding to update their access time.
* Open a file with the O_NOATIME flag to avoid to update the acces time.
*/
#ifndef O_NOATIME
#define O_NOATIME 0
static int open_noatime(const char* file, int flags)
{
int f = open(file, flags | O_NOATIME);
if (f == -1 && errno == EPERM)
f = open(file, flags);
return f;
}
#else
#define open_noatime open
#endif
/**