github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/engine/pkg/archive/changes_unix.go (about) 1 //go:build !windows 2 // +build !windows 3 4 package archive // import "github.com/docker/docker/pkg/archive" 5 6 import ( 7 "os" 8 "syscall" 9 10 "github.com/docker/docker/pkg/system" 11 "golang.org/x/sys/unix" 12 ) 13 14 func statDifferent(oldStat *system.StatT, newStat *system.StatT) bool { 15 // Don't look at size for dirs, its not a good measure of change 16 if oldStat.Mode() != newStat.Mode() || 17 oldStat.UID() != newStat.UID() || 18 oldStat.GID() != newStat.GID() || 19 oldStat.Rdev() != newStat.Rdev() || 20 // Don't look at size or modification time for dirs, its not a good 21 // measure of change. See https://github.com/moby/moby/issues/9874 22 // for a description of the issue with modification time, and 23 // https://github.com/moby/moby/pull/11422 for the change. 24 // (Note that in the Windows implementation of this function, 25 // modification time IS taken as a change). See 26 // https://github.com/moby/moby/pull/37982 for more information. 27 (oldStat.Mode()&unix.S_IFDIR != unix.S_IFDIR && 28 (!sameFsTimeSpec(oldStat.Mtim(), newStat.Mtim()) || (oldStat.Size() != newStat.Size()))) { 29 return true 30 } 31 return false 32 } 33 34 func (info *FileInfo) isDir() bool { 35 return info.parent == nil || info.stat.Mode()&unix.S_IFDIR != 0 36 } 37 38 func getIno(fi os.FileInfo) uint64 { 39 return fi.Sys().(*syscall.Stat_t).Ino 40 } 41 42 func hasHardlinks(fi os.FileInfo) bool { 43 return fi.Sys().(*syscall.Stat_t).Nlink > 1 44 }