Browse code

copy: allow non-cgo build

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>

Tonis Tiigi authored on 2019/06/03 04:19:22
Showing 3 changed files
... ...
@@ -2,14 +2,6 @@
2 2
 
3 3
 package copy // import "github.com/docker/docker/daemon/graphdriver/copy"
4 4
 
5
-/*
6
-#include <linux/fs.h>
7
-
8
-#ifndef FICLONE
9
-#define FICLONE		_IOW(0x94, 9, int)
10
-#endif
11
-*/
12
-import "C"
13 5
 import (
14 6
 	"container/list"
15 7
 	"fmt"
... ...
@@ -50,7 +42,7 @@ func copyRegular(srcPath, dstPath string, fileinfo os.FileInfo, copyWithFileRang
50 50
 	defer dstFile.Close()
51 51
 
52 52
 	if *copyWithFileClone {
53
-		_, _, err = unix.Syscall(unix.SYS_IOCTL, dstFile.Fd(), C.FICLONE, srcFile.Fd())
53
+		err = fiClone(srcFile, dstFile)
54 54
 		if err == nil {
55 55
 			return nil
56 56
 		}
57 57
new file mode 100644
... ...
@@ -0,0 +1,22 @@
0
+// +build linux,cgo
1
+
2
+package copy // import "github.com/docker/docker/daemon/graphdriver/copy"
3
+
4
+/*
5
+#include <linux/fs.h>
6
+
7
+#ifndef FICLONE
8
+#define FICLONE		_IOW(0x94, 9, int)
9
+#endif
10
+*/
11
+import "C"
12
+import (
13
+	"os"
14
+
15
+	"golang.org/x/sys/unix"
16
+)
17
+
18
+func fiClone(srcFile, dstFile *os.File) error {
19
+	_, _, err := unix.Syscall(unix.SYS_IOCTL, dstFile.Fd(), C.FICLONE, srcFile.Fd())
20
+	return err
21
+}
0 22
new file mode 100644
... ...
@@ -0,0 +1,13 @@
0
+// +build linux,!cgo
1
+
2
+package copy // import "github.com/docker/docker/daemon/graphdriver/copy"
3
+
4
+import (
5
+	"os"
6
+
7
+	"golang.org/x/sys/unix"
8
+)
9
+
10
+func fiClone(srcFile, dstFile *os.File) error {
11
+	return unix.ENOSYS
12
+}