From dab9b74bc78cb6d869859c6642c33993b071b168 Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Wed, 31 Mar 2021 21:49:11 +0200 Subject: [PATCH] test crosscompile --- reflink_linux.go | 68 -------------------------------------------- test_crosscompile.sh | 17 +++++++++++ 2 files changed, 17 insertions(+), 68 deletions(-) delete mode 100644 reflink_linux.go create mode 100755 test_crosscompile.sh diff --git a/reflink_linux.go b/reflink_linux.go deleted file mode 100644 index 337e10b..0000000 --- a/reflink_linux.go +++ /dev/null @@ -1,68 +0,0 @@ -// +build linux - -package main - -import ( - "os" - "syscall" -) - -// #include -import "C" - -// this defines C.FICLONE - -// reflink takes two paths as arguments. Attempts to reflink dst to -// src. If that did not work, an error is returned and the file has to -// be copied manually -func reflink(srcPath string, dstPath string, progressStorage *uint64) error { - var err error - var src, dst *os.File - src, err = os.OpenFile(srcPath, os.O_RDONLY, 0o644) - if err != nil { - return err - } - dst, err = os.OpenFile(dstPath, os.O_WRONLY|os.O_CREATE, 0o644) - if err != nil { - return err - } - - var ss, sd syscall.RawConn - ss, err = src.SyscallConn() - if err != nil { - return err - } - sd, err = dst.SyscallConn() - if err != nil { - return err - } - - var err2, err3 error - - err = sd.Control(func(dfd uintptr) { - err2 = ss.Control(func(sfd uintptr) { - _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, dfd, C.FICLONE, sfd) - if errno != 0 { - err3 = errno - } - }) - }) - - if err != nil { - // sd.Control failed - return err - } - if err2 != nil { - // ss.Control failed - return err2 - } - - if err3 != nil { - // write progress: - stat, _ := dst.Stat() //nolint:errcheck // this must work at this point - *progressStorage += uint64(stat.Size()) - } - - // err3 is ioctl() response - return err3 -} diff --git a/test_crosscompile.sh b/test_crosscompile.sh new file mode 100755 index 0000000..0837a61 --- /dev/null +++ b/test_crosscompile.sh @@ -0,0 +1,17 @@ +export GOOS=linux; export GOARCH=arm; echo $GOOS/$GOARCH; go build +export GOOS=linux; export GOARCH=arm64; echo $GOOS/$GOARCH; go build +export GOOS=linux; export GOARCH=amd64; echo $GOOS/$GOARCH; go build +export GOOS=linux; export GOARCH=386; echo $GOOS/$GOARCH; go build +export GOOS=darwin; export GOARCH=arm64; echo $GOOS/$GOARCH; go build +export GOOS=darwin; export GOARCH=amd64; echo $GOOS/$GOARCH; go build +export GOOS=freebsd; export GOARCH=arm; echo $GOOS/$GOARCH; go build +export GOOS=freebsd; export GOARCH=amd64; echo $GOOS/$GOARCH; go build +export GOOS=freebsd; export GOARCH=386; echo $GOOS/$GOARCH; go build +export GOOS=openbsd; export GOARCH=arm; echo $GOOS/$GOARCH; go build +export GOOS=openbsd; export GOARCH=amd64; echo $GOOS/$GOARCH; go build +export GOOS=openbsd; export GOARCH=386; echo $GOOS/$GOARCH; go build +export GOOS=netbsd; export GOARCH=arm; echo $GOOS/$GOARCH; go build +export GOOS=netbsd; export GOARCH=amd64; echo $GOOS/$GOARCH; go build +export GOOS=netbsd; export GOARCH=386; echo $GOOS/$GOARCH; go build +export GOOS=dragonfly; export GOARCH=amd64; echo $GOOS/$GOARCH; go build +