summaryrefslogtreecommitdiff
path: root/vendor/github.com/hashicorp/terraform/config/module/inode.go
blob: 8603ee268ead0366a32a52383efbdff00c29a579 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// +build linux darwin openbsd netbsd solaris

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 st.Ino, nil
	}
	return 0, fmt.Errorf("could not determine file inode")
}