github.com/searKing/golang/go@v1.2.117/io/copy_linux_experiment.go (about)

     1  // Copyright 2020 The searKing Author. 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 linux && cgo && experiment
     6  // +build linux,cgo,experiment
     7  
     8  package io
     9  
    10  /*
    11     #include <linux/fs.h>
    12  
    13     #ifndef FICLONE
    14     #define FICLONE		_IOW(0x94, 9, int)
    15     #endif
    16  */
    17  import "C"
    18  import (
    19  	"os"
    20  
    21  	"golang.org/x/sys/unix"
    22  )
    23  
    24  func copyFileClone(srcFile, dstFile *os.File) error {
    25  	_, _, err := unix.Syscall(unix.SYS_IOCTL, dstFile.Fd(), C.FICLONE, srcFile.Fd())
    26  	return err
    27  }