copy: allow non-cgo build

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 230a55d337)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Tonis Tiigi 2019-06-02 12:19:22 -07:00 committed by Kir Kolyshkin
parent 56ff8ccc91
commit 4ef8f6d323
3 changed files with 36 additions and 9 deletions

View file

@ -2,14 +2,6 @@
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 (
"container/list"
"fmt"
@ -50,7 +42,7 @@ func copyRegular(srcPath, dstPath string, fileinfo os.FileInfo, copyWithFileRang
defer dstFile.Close()
if *copyWithFileClone {
_, _, err = unix.Syscall(unix.SYS_IOCTL, dstFile.Fd(), C.FICLONE, srcFile.Fd())
err = fiClone(srcFile, dstFile)
if err == nil {
return nil
}

View file

@ -0,0 +1,22 @@
// +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

@ -0,0 +1,13 @@
// +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
}