mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
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:
parent
56ff8ccc91
commit
4ef8f6d323
3 changed files with 36 additions and 9 deletions
|
@ -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
daemon/graphdriver/copy/copy_cgo.go
Normal file
22
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
daemon/graphdriver/copy/copy_nocgo.go
Normal file
13
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
|
||||
}
|
Loading…
Reference in a new issue