瀏覽代碼

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>
Tobias Klauser 4 年之前
父節點
當前提交
5a7b75f889
共有 3 個文件被更改,包括 1 次插入36 次删除
  1. 1 1
      daemon/graphdriver/copy/copy.go
  2. 0 22
      daemon/graphdriver/copy/copy_cgo.go
  3. 0 13
      daemon/graphdriver/copy/copy_nocgo.go

+ 1 - 1
daemon/graphdriver/copy/copy.go

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

+ 0 - 22
daemon/graphdriver/copy/copy_cgo.go

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

+ 0 - 13
daemon/graphdriver/copy/copy_nocgo.go

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