2016-07-30 01:40:31 +02:00
|
|
|
// +build linux darwin openbsd solaris
|
2016-06-23 14:02:32 +02:00
|
|
|
|
|
|
|
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")
|
|
|
|
}
|