From 29b45cf218947d2eb056c1a27820dddffdc3ef08 Mon Sep 17 00:00:00 2001 From: Chris82111 <75613723+Chris82111@users.noreply.github.com> Date: Fri, 27 Feb 2026 08:40:38 +0100 Subject: [PATCH] Retry opening without the O_NOATIME flag (#167) Change looks good, much appreciated! :) Merged. --- pclsync/pfile.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pclsync/pfile.c b/pclsync/pfile.c index 0226394..fbf1d94 100644 --- a/pclsync/pfile.c +++ b/pclsync/pfile.c @@ -125,11 +125,19 @@ int pfile_open(const char *path, int access, int flags) { flags |= O_NOATIME; #endif fd = open(path, access | flags, PSYNC_DEFAULT_POSIX_FILE_MODE); - if (unlikely(fd == -1)) { - while (errno == EINTR) { + +#if defined(O_NOATIME) + if ((-1 == fd ) && (EPERM == errno)) { + flags &= ~O_NOATIME; + fd = open(path, access | flags, PSYNC_DEFAULT_POSIX_FILE_MODE); + } +#endif + + if (unlikely(-1 == fd)) { + while (EINTR == errno) { pdbg_logf(D_NOTICE, "got EINTR while opening file"); fd = open(path, access | flags, PSYNC_DEFAULT_POSIX_FILE_MODE); - if (fd != -1) + if (-1 != fd) return fd; } }