소스 검색

unix: add SyncFileRange on linux/arm

Use the arm_sync_file_range to implement SyncFileRange.

This is an alias for sync_file_range2 syscall which is already used to
implement SyncFileRange on ppc64x. These have the order of the flags and
offset arguments reversed in order to fit the syscall arguments within 6
registers.

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

This makes TestSyncFileRange build and pass on linux/arm.

Change-Id: I1316328ebcf550a3fb70f9ce5ebf54d8bcaa932c
Reviewed-on: https://go-review.googlesource.com/c/153939
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Tobias Klauser 7 년 전
부모
커밋
586ba8c9bb
2개의 변경된 파일18개의 추가작업 그리고 0개의 파일을 삭제
  1. 8 0
      unix/syscall_linux_arm.go
  2. 10 0
      unix/zsyscall_linux_arm.go

+ 8 - 0
unix/syscall_linux_arm.go

@@ -257,3 +257,11 @@ func Poll(fds []PollFd, timeout int) (n int, err error) {
 	}
 	return poll(&fds[0], len(fds), timeout)
 }
+
+//sys	armSyncFileRange(fd int, flags int, off int64, n int64) (err error) = SYS_ARM_SYNC_FILE_RANGE
+
+func SyncFileRange(fd int, off int64, n int64, flags int) error {
+	// The sync_file_range and arm_sync_file_range syscalls differ only in the
+	// order of their arguments.
+	return armSyncFileRange(fd, flags, off, n)
+}

+ 10 - 0
unix/zsyscall_linux_arm.go

@@ -2282,3 +2282,13 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
 	}
 	return
 }
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func armSyncFileRange(fd int, flags int, off int64, n int64) (err error) {
+	_, _, e1 := Syscall6(SYS_ARM_SYNC_FILE_RANGE, uintptr(fd), uintptr(flags), uintptr(off), uintptr(off>>32), uintptr(n), uintptr(n>>32))
+	if e1 != 0 {
+		err = errnoErr(e1)
+	}
+	return
+}