Skip to content

Commit

Permalink
syscall: correct argument order for SyncFileRange syscall on linux/pp…
Browse files Browse the repository at this point in the history
…c64{,le}

On linux/ppc64{,le} the SYS_SYNC_FILE_RANGE2 syscall is used to
implement SyncFileRange. This syscall has a different argument order
than SYS_SYNC_FILE_RANGE. Apart from that the implementations of both
syscalls are the same, so use a simple wrapper to invoke the syscall
with the correct argument order.

For context see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=edd5cd4a9424f22b0fa08bef5e299d41befd5622

Updates golang#27485

Change-Id: Ib94fb98376bf6c879df6f1b68c3bdd11ebcb5a44
Reviewed-on: https://go-review.googlesource.com/133195
Run-TryBot: Tobias Klauser <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
tklauser committed Sep 5, 2018
1 parent d7fc220 commit eee1cfb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
9 changes: 8 additions & 1 deletion src/syscall/syscall_linux_ppc64x.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const (
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
//sys Stat(path string, stat *Stat_t) (err error)
//sys Statfs(path string, buf *Statfs_t) (err error)
//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2
//sys Truncate(path string, length int64) (err error)
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
Expand Down Expand Up @@ -120,3 +119,11 @@ func (cmsg *Cmsghdr) SetLen(length int) {
func rawVforkSyscall(trap, a1 uintptr) (r1 uintptr, err Errno) {
panic("not implemented")
}

//sys syncFileRange2(fd int, flags int, off int64, n int64) (err error) = SYS_SYNC_FILE_RANGE2

func SyncFileRange(fd int, off int64, n int64, flags int) error {
// The sync_file_range and sync_file_range2 syscalls differ only in the
// order of their arguments.
return syncFileRange2(fd, flags, off, n)
}
20 changes: 10 additions & 10 deletions src/syscall/zsyscall_linux_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 src/syscall/zsyscall_linux_ppc64le.go

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

0 comments on commit eee1cfb

Please sign in to comment.