From a0eb4997e3fe992f8600fde7c59be033afd36adf Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 14 Sep 2013 09:18:15 +0000 Subject: [PATCH] pcu-fadvise: fall back if O_NOATIME fails due to EPERM open() may fail with EPERM on files we do not own. --- fadvise.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fadvise.c b/fadvise.c index 12c9b1b..b4b85d7 100644 --- a/fadvise.c +++ b/fadvise.c @@ -31,9 +31,15 @@ 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; + } fprintf(stderr, "%s: open(): %s\n", path, strerror(errno)); return; } +ok: if (len <= 0) { /* for compatibility with kernels < 2.6.6 */ -- 2.11.4.GIT