Skip to content

Commit

Permalink
unix: fix fsync for read-only files on aix
Browse files Browse the repository at this point in the history
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 <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
  • Loading branch information
tklauser committed Nov 9, 2021
1 parent cbcd623 commit 02f5c03
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 41 deletions.
6 changes: 5 additions & 1 deletion unix/syscall_aix.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@ func (w WaitStatus) TrapCause() int { return -1 }

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

//sys fsyncRange(fd int, how int, start int64, length int64) (err error) = fsync_range
func Fsync(fd int) error {
return fsyncRange(fd, O_SYNC, 0, 0)
}

/*
* Direct access
*/
Expand All @@ -393,7 +398,6 @@ func (w WaitStatus) TrapCause() int { return -1 }
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
//sys Fdatasync(fd int) (err error)
//sys Fsync(fd int) (err error)
// readdir_r
//sysnb Getpgid(pid int) (pgid int, err error)

Expand Down
22 changes: 11 additions & 11 deletions unix/zsyscall_aix_ppc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions unix/zsyscall_aix_ppc64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions unix/zsyscall_aix_ppc64_gc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions unix/zsyscall_aix_ppc64_gccgo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 02f5c03

Please sign in to comment.