aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/terraform/config/module/inode.go
blob: da520abcb27282872e0e7eefe65140690fe116ff (plain) (blame)
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 dragonfly

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")
}