2015-05-07 18:14:11 -04:00
|
|
|
// +build !windows
|
|
|
|
|
2018-02-05 16:05:59 -05:00
|
|
|
package archive // import "github.com/docker/docker/pkg/archive"
|
2015-05-07 18:14:11 -04:00
|
|
|
|
|
|
|
import (
|
2015-10-12 15:11:22 -04:00
|
|
|
"os"
|
2015-05-07 18:14:11 -04:00
|
|
|
"syscall"
|
|
|
|
|
|
|
|
"github.com/docker/docker/pkg/system"
|
2017-05-23 10:22:32 -04:00
|
|
|
"golang.org/x/sys/unix"
|
2015-05-07 18:14:11 -04:00
|
|
|
)
|
|
|
|
|
2015-07-28 12:13:12 -04:00
|
|
|
func statDifferent(oldStat *system.StatT, newStat *system.StatT) bool {
|
2015-05-07 18:14:11 -04:00
|
|
|
// Don't look at size for dirs, its not a good measure of change
|
|
|
|
if oldStat.Mode() != newStat.Mode() ||
|
2015-07-28 12:13:12 -04:00
|
|
|
oldStat.UID() != newStat.UID() ||
|
2015-10-12 10:58:33 -04:00
|
|
|
oldStat.GID() != newStat.GID() ||
|
2015-05-07 18:14:11 -04:00
|
|
|
oldStat.Rdev() != newStat.Rdev() ||
|
2018-10-05 18:46:59 -04:00
|
|
|
// Don't look at size or modification time for dirs, its not a good
|
|
|
|
// measure of change. See https://github.com/moby/moby/issues/9874
|
|
|
|
// for a description of the issue with modification time, and
|
|
|
|
// https://github.com/moby/moby/pull/11422 for the change.
|
|
|
|
// (Note that in the Windows implementation of this function,
|
|
|
|
// modification time IS taken as a change). See
|
|
|
|
// https://github.com/moby/moby/pull/37982 for more information.
|
2017-05-23 10:22:32 -04:00
|
|
|
(oldStat.Mode()&unix.S_IFDIR != unix.S_IFDIR &&
|
2015-05-07 18:14:11 -04:00
|
|
|
(!sameFsTimeSpec(oldStat.Mtim(), newStat.Mtim()) || (oldStat.Size() != newStat.Size()))) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (info *FileInfo) isDir() bool {
|
2017-05-23 10:22:32 -04:00
|
|
|
return info.parent == nil || info.stat.Mode()&unix.S_IFDIR != 0
|
2015-05-07 18:14:11 -04:00
|
|
|
}
|
2015-10-12 15:11:22 -04:00
|
|
|
|
|
|
|
func getIno(fi os.FileInfo) uint64 {
|
2017-08-24 13:11:44 -04:00
|
|
|
return fi.Sys().(*syscall.Stat_t).Ino
|
2015-10-12 15:11:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func hasHardlinks(fi os.FileInfo) bool {
|
|
|
|
return fi.Sys().(*syscall.Stat_t).Nlink > 1
|
|
|
|
}
|