1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 func sameFile(sys1, sys2 interface{}) bool {
13 stat1 := sys1.(*syscall.Stat_t)
14 stat2 := sys2.(*syscall.Stat_t)
15 return stat1.Dev == stat2.Dev && stat1.Ino == stat2.Ino
18 func fileInfoFromStat(st *syscall.Stat_t, name string) FileInfo {
22 modTime: timespecToTime(st.Mtim),
25 fs.mode = FileMode(st.Mode & 0777)
26 switch st.Mode & syscall.S_IFMT {
30 fs.mode |= ModeDevice | ModeCharDevice
34 fs.mode |= ModeNamedPipe
36 fs.mode |= ModeSymlink
39 case syscall.S_IFSOCK:
42 if st.Mode&syscall.S_ISGID != 0 {
45 if st.Mode&syscall.S_ISUID != 0 {
48 if st.Mode&syscall.S_ISVTX != 0 {
54 func timespecToTime(ts syscall.Timespec) time.Time {
55 return time.Unix(int64(ts.Sec), int64(ts.Nsec))
59 func atime(fi FileInfo) time.Time {
60 return timespecToTime(fi.Sys().(*syscall.Stat_t).Atim)