mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-29 11:26:48 -05:00
If O_NOATIME use fails with EPERM, retry without it.
This commit is contained in:
parent
db6ff47062
commit
2d6528fe90
4 changed files with 25 additions and 14 deletions
15
portable.h
15
portable.h
|
|
@ -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
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue