aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-10-11 01:31:09 +0200
committerJakob Unterwurzacher2020-10-11 01:31:09 +0200
commit803fdf410bb57d34ef09357ec4924646978c20b5 (patch)
treee175cb57d27b3aa1295242a036ea3f2018b77be3
parentfe340477b2471ed03510339ca51bfcc396b03040 (diff)
syscallcompat: Openat: retry on EINTR
Towards fixing https://github.com/rfjakob/gocryptfs/issues/507
-rw-r--r--internal/syscallcompat/sys_common.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/syscallcompat/sys_common.go b/internal/syscallcompat/sys_common.go
index d5e3251..c50c940 100644
--- a/internal/syscallcompat/sys_common.go
+++ b/internal/syscallcompat/sys_common.go
@@ -44,7 +44,7 @@ func Faccessat(dirfd int, path string, mode uint32) error {
return unix.Faccessat(dirfd, path, mode, 0)
}
-// Openat wraps the Openat syscall.
+// Openat wraps the Openat syscall, retrying on EINTR.
func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
if flags&syscall.O_CREAT != 0 {
// O_CREAT should be used with O_EXCL. O_NOFOLLOW has no effect with O_EXCL.
@@ -59,7 +59,14 @@ func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
flags |= syscall.O_NOFOLLOW
}
}
- return unix.Openat(dirfd, path, flags, mode)
+ // Like ignoringEINTR() in the Go stdlib:
+ // https://github.com/golang/go/blob/d2a80f3fb5b44450e0b304ac5a718f99c053d82a/src/os/file_posix.go#L243
+ for {
+ fd, err = unix.Openat(dirfd, path, flags, mode)
+ if err != unix.EINTR {
+ return fd, err
+ }
+ }
}
// Renameat wraps the Renameat syscall.