copy: allow non-cgo build
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com> (cherry picked from commit 230a55d337f67a2850fd3206500c5c2a89f9e2e7) Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> Upstream-commit: 1da22d7201f5fdedf3c6732163819d56a7571414 Component: engine
This commit is contained in:
committed by
Kir Kolyshkin
parent
36678eaf72
commit
920f2a46aa
@ -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
|
||||
}
|
||||
|
||||
22
components/engine/daemon/graphdriver/copy/copy_cgo.go
Normal file
22
components/engine/daemon/graphdriver/copy/copy_cgo.go
Normal 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
|
||||
}
|
||||
13
components/engine/daemon/graphdriver/copy/copy_nocgo.go
Normal file
13
components/engine/daemon/graphdriver/copy/copy_nocgo.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user