2019-01-09 01:21:31 +01:00
|
|
|
// +build linux darwin openbsd netbsd solaris dragonfly
|
|
|
|
|
2019-01-09 03:39:14 +01:00
|
|
|
package initwd
|
2019-01-09 01:21:31 +01:00
|
|
|
|
|
|
|
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")
|
|
|
|
}
|