Skip to content

Commit 86dbeef

Browse files
Helflymianlancetaylor
authored andcommitted
syscall: fix fsync for read-only files on aix
AIX fsync syscall doesn't work on read-only files. Using fsync_range instead allows syscall.Fsync to work on any files. Fixes #41372 Change-Id: I66d33e847875496af53da60828c1bddf6c2b76b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/254657 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
1 parent 4f5cd0c commit 86dbeef

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

src/syscall/syscall_aix.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int,
214214
return
215215
}
216216

217+
//sys fsyncRange(fd int, how int, start int64, length int64) (err error) = fsync_range
218+
func Fsync(fd int) error {
219+
return fsyncRange(fd, O_SYNC, 0, 0)
220+
}
221+
217222
/*
218223
* Socket
219224
*/
@@ -600,7 +605,6 @@ func PtraceDetach(pid int) (err error) { return ptrace64(PT_DETACH, int64(pid),
600605
//sys Fstat(fd int, stat *Stat_t) (err error)
601606
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
602607
//sys Ftruncate(fd int, length int64) (err error)
603-
//sys Fsync(fd int) (err error)
604608
//sysnb Getgid() (gid int)
605609
//sysnb Getpid() (pid int)
606610
//sys Geteuid() (euid int)

src/syscall/zsyscall_aix_ppc64.go

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)