Fixes #9283. Consider hardlinks in image size.

Based on #8984. This patch fixes behavior when image size calculation
didn't consider hardlinks.

Signed-off-by: Dmitry Vorobev <dimahabr@gmail.com>
This commit is contained in:
Dmitry Vorobev 2015-10-12 21:11:22 +02:00
parent bc78380707
commit f6ec5ae6ee
7 changed files with 73 additions and 10 deletions

View file

@ -3,6 +3,7 @@
package archive
import (
"os"
"syscall"
"github.com/docker/docker/pkg/system"
@ -25,3 +26,11 @@ func statDifferent(oldStat *system.StatT, newStat *system.StatT) bool {
func (info *FileInfo) isDir() bool {
return info.parent == nil || info.stat.Mode()&syscall.S_IFDIR != 0
}
func getIno(fi os.FileInfo) uint64 {
return uint64(fi.Sys().(*syscall.Stat_t).Ino)
}
func hasHardlinks(fi os.FileInfo) bool {
return fi.Sys().(*syscall.Stat_t).Nlink > 1
}