Skip to content

Commit 02f5c03

Browse files
committed
unix: fix fsync for read-only files on aix
On aix, the fsync syscall doesn't work on read-only files. Use fsync_range instead to allow Fsync to work on any file. Follow CL 254657 which did the same in package syscall. For golang/go#41372 Change-Id: Ibc55ecf5c43e27a04281af1a204f847eeafeea63 Reviewed-on: https://go-review.googlesource.com/c/sys/+/362274 Trust: Tobias Klauser <[email protected]> Run-TryBot: Tobias Klauser <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent cbcd623 commit 02f5c03

5 files changed

+45
-41
lines changed

unix/syscall_aix.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,11 @@ func (w WaitStatus) TrapCause() int { return -1 }
377377

378378
//sys fcntl(fd int, cmd int, arg int) (val int, err error)
379379

380+
//sys fsyncRange(fd int, how int, start int64, length int64) (err error) = fsync_range
381+
func Fsync(fd int) error {
382+
return fsyncRange(fd, O_SYNC, 0, 0)
383+
}
384+
380385
/*
381386
* Direct access
382387
*/
@@ -393,7 +398,6 @@ func (w WaitStatus) TrapCause() int { return -1 }
393398
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
394399
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
395400
//sys Fdatasync(fd int) (err error)
396-
//sys Fsync(fd int) (err error)
397401
// readdir_r
398402
//sysnb Getpgid(pid int) (pgid int, err error)
399403

unix/zsyscall_aix_ppc.go

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

unix/zsyscall_aix_ppc64.go

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

unix/zsyscall_aix_ppc64_gc.go

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

unix/zsyscall_aix_ppc64_gccgo.go

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

0 commit comments

Comments
 (0)