From 2eb00c918459b233c1490474aa92de9bf9839f5c Mon Sep 17 00:00:00 2001 From: James Nugent Date: Fri, 29 Jul 2016 18:26:22 -0500 Subject: [PATCH] build: Fix errors in FreeBSD build Fixes the following error when cross compiling: ``` --> freebsd/amd64 error: exit status 2 Stderr: # github.com/hashicorp/terraform/config/module config/module/inode.go:18: cannot use st.Ino (type uint32) as type uint64 in return argument ``` --- config/module/inode.go | 2 +- config/module/inode_freebsd.go | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 config/module/inode_freebsd.go diff --git a/config/module/inode.go b/config/module/inode.go index a49e8a19d..20a951f06 100644 --- a/config/module/inode.go +++ b/config/module/inode.go @@ -1,4 +1,4 @@ -// +build !windows +// +build !windows !freebsd package module diff --git a/config/module/inode_freebsd.go b/config/module/inode_freebsd.go new file mode 100644 index 000000000..ff658761a --- /dev/null +++ b/config/module/inode_freebsd.go @@ -0,0 +1,19 @@ +package module + +import ( + "fmt" + "os" + "syscall" +) + +// lookup the inode of a file on posix systems +func inode(path string) (uint64, error) { + stat, err := os.Stat(path) + if err != nil { + return 0, err + } + if st, ok := stat.Sys().(*syscall.Stat_t); ok { + return uint64(st.Ino), nil + } + return 0, fmt.Errorf("could not determine file inode") +}