about summary refs log tree commit homepage
path: root/fadvise.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-09-15 08:58:56 +0000
committerEric Wong <normalperson@yhbt.net>2013-09-15 08:58:56 +0000
commitd167ac7305f8a13cb8529a74b7239cc0801fa6ad (patch)
treee836c61642d009fc5c3710360bfbd408843eb43e /fadvise.c
parenta0eb4997e3fe992f8600fde7c59be033afd36adf (diff)
downloadpcu-d167ac7305f8a13cb8529a74b7239cc0801fa6ad.tar.gz
open_noatime wrapper to deal with EPERM on O_NOATIME
We favor O_NOATIME in a variety of places, use it when we can,
but fall back gracefully when we cannot.
Diffstat (limited to 'fadvise.c')
-rw-r--r--fadvise.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/fadvise.c b/fadvise.c
index b4b85d7..72ef3a3 100644
--- a/fadvise.c
+++ b/fadvise.c
@@ -30,16 +30,10 @@ static void apply_fadvise(const char *path, off_t offset, off_t len, int advice)
 {
         int fd;
 
-        if ((fd = open(path, O_RDONLY|O_NOATIME)) < 0) {
-                if (errno == EPERM && O_NOATIME != 0) {
-                        fd = open(path, O_RDONLY);
-                        if (fd >= 0)
-                                goto ok;
-                }
+        if ((fd = open_noatime(path) < 0)) {
                 fprintf(stderr, "%s: open(): %s\n", path, strerror(errno));
                 return;
         }
-ok:
 
         if (len <= 0) {
                 /* for compatibility with kernels < 2.6.6 */