]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: correct argument order for SyncFileRange syscall on linux/ppc64{,le}
authorTobias Klauser <tklauser@distanz.ch>
Tue, 4 Sep 2018 12:19:53 +0000 (14:19 +0200)
committerTobias Klauser <tobias.klauser@gmail.com>
Wed, 5 Sep 2018 10:03:43 +0000 (10:03 +0000)
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 #27485

Change-Id: Ib94fb98376bf6c879df6f1b68c3bdd11ebcb5a44
Reviewed-on: https://go-review.googlesource.com/133195
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/syscall/syscall_linux_ppc64x.go
src/syscall/zsyscall_linux_ppc64.go
src/syscall/zsyscall_linux_ppc64le.go

index 88a520e3fd6134ff6bc5932d71f03313dfb41efc..1cdc5f9a44155fd9a18d5fa2013f099e4f1810ef 100644 (file)
@@ -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)
@@ -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)
+}
index 20c78ef2d285cabd4edce6dee7e385c3a523b500..74402250ebdb748b6cefc9414e82db0619fdf463 100644 (file)
@@ -1504,16 +1504,6 @@ func Statfs(path string, buf *Statfs_t) (err error) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
-func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
-       _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE2, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
-       if e1 != 0 {
-               err = errnoErr(e1)
-       }
-       return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
 func Truncate(path string, length int64) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
@@ -1764,3 +1754,13 @@ func pipe2(p *[2]_C_int, flags int) (err error) {
        }
        return
 }
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func syncFileRange2(fd int, flags int, off int64, n int64) (err error) {
+       _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE2, uintptr(fd), uintptr(flags), uintptr(off), uintptr(n), 0, 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
index 592934399374fd25361f634cb4e254ddce23ae56..3b6c283c4b62ba54350d2a56bd133b38d245e7ae 100644 (file)
@@ -1504,16 +1504,6 @@ func Statfs(path string, buf *Statfs_t) (err error) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
-func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
-       _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE2, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
-       if e1 != 0 {
-               err = errnoErr(e1)
-       }
-       return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
 func Truncate(path string, length int64) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
@@ -1764,3 +1754,13 @@ func pipe2(p *[2]_C_int, flags int) (err error) {
        }
        return
 }
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func syncFileRange2(fd int, flags int, off int64, n int64) (err error) {
+       _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE2, uintptr(fd), uintptr(flags), uintptr(off), uintptr(n), 0, 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}