aboutsummaryrefslogtreecommitdiff
path: root/src/internal/poll/fd_fsync_darwin.go
AgeCommit message (Collapse)Author
2024-03-07internal/poll: change Fsync to fallback to syscall.Fsync on darwinMauri de Souza Meneguzzo
In certain scenarios, such as network mounts, calling Fsync results in ENOTSUP in OSX. This issue was introduced in CL 130676 since syscall.FSync was not properly flushing contents to disk, and it was replaced with fcntl(fd, F_FULLSYNC). Most SMB servers, like Windows Server and Samba don't support F_FULLSYNC. To avoid such issues fallback to syscall.Fsync if fcntl returns ENOTSUP. Fixes #64215 Change-Id: I567191e1179b7e70ddffb6b881469de1872746ef GitHub-Last-Rev: 62e6931cf79735a192ed57be05005e84720ed232 GitHub-Pull-Request: golang/go#64258 Reviewed-on: https://go-review.googlesource.com/c/go/+/543535 Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-05-18internal/poll, internal/syscall/unix, net: move and export fcntl syscall wrapperTobias Klauser
This will allow to use the fcntl syscall in packages other than internal/poll. For #60181 Change-Id: I76703766a655f2343c61dad95faf81aad58e007f Reviewed-on: https://go-review.googlesource.com/c/go/+/494916 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2020-10-01internal/poll: use ignoringEINTR in Darwin FsyncIan Lance Taylor
Also add comment explaining why we don't use ignoringEINTR around call to close. Fixes #41115 Change-Id: Ia7bbe01eaf26003f70d184b7e82803efef2b2c18 Reviewed-on: https://go-review.googlesource.com/c/go/+/258542 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-12-31internal/poll: use correct fcntl implementationsTobias Klauser
Use the libc fcntl (via syscall.fcntl) on aix and solaris like it is already done for darwin. For the syscall-based fcntl implementation use FcntlSyscall from internal/syscall/unix in order to get fcntl64 on 32-bit Linux systems. On aix, fcntl with F_DUPFD_CLOEXEC is not supported. Thus, defined F_DUPFD_CLOEXEC = 0 in the syscall package and check its value before calling fcntl(fd, syscall.F_DUPFD_CLOEXEC, 0). On js/wasm, fcntl is not supported thus let its implementation return ENOSYS directly. Updates #36211 Change-Id: I96a2ea79e5c4eed2fefd94d0aefd72c940825682 Reviewed-on: https://go-review.googlesource.com/c/go/+/212278 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-11-07syscall: implement syscalls on Darwin using libSystemKeith Randall
There are still some references to the bare Syscall functions in the stdlib. I will root those out in a following CL. (This CL is big enough as it is.) Most are in vendor directories: cmd/vendor/golang.org/x/sys/unix/ vendor/golang_org/x/net/route/syscall.go syscall/bpf_bsd.go syscall/exec_unix.go syscall/flock.go Update #17490 Change-Id: I69ab707811530c26b652b291cadee92f5bf5c1a4 Reviewed-on: https://go-review.googlesource.com/c/141639 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Elias Naur <elias.naur@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-22internal/poll: use F_FULLFSYNC fcntl for FD.Fsync on OS XEmmanuel T Odeke
As reported in #26650 and also cautioned on the man page for fsync on OS X, fsync doesn't properly flush content to permanent storage, and might cause corruption of data if the OS crashes or if the drive loses power. Thus it is recommended to use the F_FULLFSYNC fcntl, which flushes all buffered data to permanent storage and is important for applications such as databases that require a strict ordering of writes. Also added a note in syscall_darwin.go that syscall.Fsync is not invoked for os.File.Sync. Fixes #26650. Change-Id: Idecd9adbbdd640b9c5b02e73b60ed254c98b48b6 Reviewed-on: https://go-review.googlesource.com/130676 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>