github.com/docker/docker@v299999999.0.0-20200612211812-aaf470eca7b5+incompatible/pkg/archive/changes_unix.go (about)

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