diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-09-14 09:18:15 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-09-14 09:19:31 +0000 |
commit | a0eb4997e3fe992f8600fde7c59be033afd36adf (patch) | |
tree | fc6d3f98f1d62075dadbabee5bb12711ac0f1a89 | |
parent | 7c025916b246efb23ae890f339ef7f5a1946c9df (diff) | |
download | pcu-a0eb4997e3fe992f8600fde7c59be033afd36adf.tar.gz |
pcu-fadvise: fall back if O_NOATIME fails due to EPERM
open() may fail with EPERM on files we do not own.
-rw-r--r-- | fadvise.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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 */ |