mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
daemon/graphdriver/copy: use IoctlFileClone from golang.org/x/sys/unix
This allows to drop the cgo implementation. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
This commit is contained in:
parent
6267800783
commit
5a7b75f889
3 changed files with 1 additions and 36 deletions
|
@ -42,7 +42,7 @@ func copyRegular(srcPath, dstPath string, fileinfo os.FileInfo, copyWithFileRang
|
|||
defer dstFile.Close()
|
||||
|
||||
if *copyWithFileClone {
|
||||
err = fiClone(srcFile, dstFile)
|
||||
err = unix.IoctlFileClone(int(dstFile.Fd()), int(srcFile.Fd()))
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
// +build linux,cgo
|
||||
|
||||
package copy // import "github.com/docker/docker/daemon/graphdriver/copy"
|
||||
|
||||
/*
|
||||
#include <linux/fs.h>
|
||||
|
||||
#ifndef FICLONE
|
||||
#define FICLONE _IOW(0x94, 9, int)
|
||||
#endif
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func fiClone(srcFile, dstFile *os.File) error {
|
||||
_, _, err := unix.Syscall(unix.SYS_IOCTL, dstFile.Fd(), C.FICLONE, srcFile.Fd())
|
||||
return err
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
// +build linux,!cgo
|
||||
|
||||
package copy // import "github.com/docker/docker/daemon/graphdriver/copy"
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func fiClone(srcFile, dstFile *os.File) error {
|
||||
return unix.ENOSYS
|
||||
}
|
Loading…
Reference in a new issue