about summary refs log tree commit homepage
path: root/compat-util.h
diff options
context:
space:
mode:
Diffstat (limited to 'compat-util.h')
-rw-r--r--compat-util.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/compat-util.h b/compat-util.h
index d3520e1..60616e2 100644
--- a/compat-util.h
+++ b/compat-util.h
@@ -56,4 +56,18 @@ static inline off_t cstr_to_off_t(const char *nptr, char **endptr, int base)
         exit(1);
 }
 
+static inline int open_noatime(const char *path)
+{
+        int flags = O_RDONLY | O_NOATIME;
+        int fd = open(path, flags);
+
+        if (fd < 0) {
+                if (errno == EPERM && O_NOATIME != 0)
+                        fd = open(path, O_RDONLY);
+                return fd;
+        }
+
+        return fd;
+}
+
 #endif /* OS_COMPAT_H */