1
0
Fork 0
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:
Tobias Klauser 2020-09-22 21:46:21 +02:00
parent 6267800783
commit 5a7b75f889
3 changed files with 1 additions and 36 deletions

View file

@ -42,7 +42,7 @@ func copyRegular(srcPath, dstPath string, fileinfo os.FileInfo, copyWithFileRang
defer dstFile.Close() defer dstFile.Close()
if *copyWithFileClone { if *copyWithFileClone {
err = fiClone(srcFile, dstFile) err = unix.IoctlFileClone(int(dstFile.Fd()), int(srcFile.Fd()))
if err == nil { if err == nil {
return nil return nil
} }

View file

@ -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
}

View file

@ -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
}