27 lines
630 B
Go
27 lines
630 B
Go
//go:build unix
|
|
|
|
package apply
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
)
|
|
|
|
// statOwner reads a file's numeric owner. Split out because the field is platform-specific and
|
|
// the rest of this package should not have to know that.
|
|
func statOwner(info os.FileInfo) (uid, gid int, ok bool) {
|
|
stat, ok := info.Sys().(*syscall.Stat_t)
|
|
if !ok {
|
|
return 0, 0, false
|
|
}
|
|
return int(stat.Uid), int(stat.Gid), true
|
|
}
|
|
|
|
// linkCount is how many names a file has (its hard links); 1 where the file system does not say.
|
|
func linkCount(info os.FileInfo) uint64 {
|
|
if stat, ok := info.Sys().(*syscall.Stat_t); ok {
|
|
return uint64(stat.Nlink)
|
|
}
|
|
return 1
|
|
}
|