//go:build unix package host import ( "io/fs" "syscall" ) // fileOwner reports a file's owning uid and gid. Split by build tag because // internal/host is linked into the CLI, which people run on Macs and Windows, // and syscall.Stat_t does not exist everywhere — the gate cross-compiles all // five targets for exactly this reason. func fileOwner(fi fs.FileInfo) (uid, gid int, ok bool) { st, ok := fi.Sys().(*syscall.Stat_t) if !ok { return 0, 0, false } return int(st.Uid), int(st.Gid), true } // fileInode reports a file's device and inode, so a cache can tell a file // replaced at the same path from the one it hashed. Same split as fileOwner. func fileInode(fi fs.FileInfo) (dev, ino uint64, ok bool) { st, ok := fi.Sys().(*syscall.Stat_t) if !ok { return 0, 0, false } return uint64(st.Dev), uint64(st.Ino), true }