tools: remove the use of cgo on Linux
We currently import the C package solely for a single value: the FICLONE ioctl, which is a constant. Since this is a constant and also part of the Linux kernel ABI, there's no reason we need to have the C compiler generate it for us every time we build. We can instead hard-code the constant in place, since it will never change. This avoids the need for cgo in order to have a functional invocation of git lfs dedup on Linux.
This commit is contained in:
parent
5f969e6a3e
commit
a27bda0eb9
@ -1,4 +1,4 @@
|
||||
// +build !linux !cgo
|
||||
// +build !linux
|
||||
// +build !darwin !cgo
|
||||
// +build !windows
|
||||
|
||||
|
@ -1,17 +1,7 @@
|
||||
// +build linux,cgo
|
||||
// +build linux
|
||||
|
||||
package tools
|
||||
|
||||
/*
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#undef FICLONE
|
||||
#define FICLONE _IOW(0x94, 9, int)
|
||||
// copy from https://github.com/torvalds/linux/blob/v5.2/include/uapi/linux/fs.h#L195 for older header files.
|
||||
// This is equal to the older BTRFS_IOC_CLONE value.
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@ -20,7 +10,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
ioctlFiClone = C.FICLONE
|
||||
// This is the FICLONE ioctl value found in linux/fs.h on a typical
|
||||
// system. It's equivalent to the older BTRFS_IOC_CLONE. We hard-code
|
||||
// the value here to avoid a dependency on cgo.
|
||||
ioctlFiClone = 0x40049409
|
||||
)
|
||||
|
||||
// CheckCloneFileSupported runs explicit test of clone file on supplied directory.
|
||||
|
Loading…
Reference in New Issue
Block a user