copy_file_range_unix.mx raw

   1  // Copyright 2020 The Go Authors. All rights reserved.
   2  // Use of this source code is governed by a BSD-style
   3  // license that can be found in the LICENSE file.
   4  
   5  //go:build freebsd || linux
   6  
   7  package unix
   8  
   9  import (
  10  	"syscall"
  11  	"unsafe"
  12  )
  13  
  14  func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) {
  15  	r1, _, errno := syscall.Syscall6(copyFileRangeTrap,
  16  		uintptr(rfd),
  17  		uintptr(unsafe.Pointer(roff)),
  18  		uintptr(wfd),
  19  		uintptr(unsafe.Pointer(woff)),
  20  		uintptr(len),
  21  		uintptr(flags),
  22  	)
  23  	n = int(r1)
  24  	if errno != 0 {
  25  		err = errno
  26  	}
  27  	return
  28  }
  29