diff --git a/pkg/archive/archive.go b/pkg/archive/archive.go index ce465db754..be47f6576d 100644 --- a/pkg/archive/archive.go +++ b/pkg/archive/archive.go @@ -8,7 +8,6 @@ import ( "io/fs" "os" "path/filepath" - "syscall" "time" "github.com/docker/docker/pkg/ioutils" @@ -429,18 +428,6 @@ func hasModeSocket(fi os.FileInfo) fs.FileMode { return fi.Mode() & os.ModeSocket } -func hasHardlinks(fi os.FileInfo) bool { - return fi.Sys().(*syscall.Stat_t).Nlink > 1 -} - -func getInodeFromStat(stat interface{}) (inode uint64, err error) { - s, ok := stat.(*syscall.Stat_t) - if ok { - inode = s.Ino - } - return -} - func writeRootHeader(tw TarWriter, basePath string, mode int64, uid int, gid int, normalizeModTime bool) error { rootHeader := &tar.Header{ Typeflag: tar.TypeDir, diff --git a/pkg/archive/archive_test.go b/pkg/archive/archive_test.go index c41a9310a9..e144beb27b 100644 --- a/pkg/archive/archive_test.go +++ b/pkg/archive/archive_test.go @@ -445,6 +445,7 @@ func testArchive(t *testing.T, when spec.G, it spec.S) { when("hard link files are present", func() { it.Before(func() { + h.SkipIf(t, runtime.GOOS == "windows", "Skipping on windows") src = filepath.Join("testdata", "dir-to-tar-with-hardlink") // create a hard link err := os.Link(filepath.Join(src, "original-file"), filepath.Join(src, "original-file-2")) diff --git a/pkg/archive/archive_unix.go b/pkg/archive/archive_unix.go new file mode 100644 index 0000000000..766a4ca5d0 --- /dev/null +++ b/pkg/archive/archive_unix.go @@ -0,0 +1,18 @@ +package archive + +import ( + "os" + "syscall" +) + +func hasHardlinks(fi os.FileInfo) bool { + return fi.Sys().(*syscall.Stat_t).Nlink > 1 +} + +func getInodeFromStat(stat interface{}) (inode uint64, err error) { + s, ok := stat.(*syscall.Stat_t) + if ok { + inode = s.Ino + } + return +} diff --git a/pkg/archive/archive_windows.go b/pkg/archive/archive_windows.go new file mode 100644 index 0000000000..42c1b1f19b --- /dev/null +++ b/pkg/archive/archive_windows.go @@ -0,0 +1,13 @@ +package archive + +import ( + "os" +) + +func hasHardlinks(fi os.FileInfo) bool { + return false +} + +func getInodeFromStat(stat interface{}) (inode uint64, err error) { + return +} diff --git a/pkg/buildpack/buildpack_test.go b/pkg/buildpack/buildpack_test.go index 082774398c..1de37c9c47 100644 --- a/pkg/buildpack/buildpack_test.go +++ b/pkg/buildpack/buildpack_test.go @@ -516,6 +516,7 @@ version = "1.2.3" var bpRootFolder string it.Before(func() { + h.SkipIf(t, runtime.GOOS == "windows", "Skipping on windows") bpRootFolder = filepath.Join("testdata", "buildpack-with-hardlink") // create a hard link err := os.Link(filepath.Join(bpRootFolder, "original-file"), filepath.Join(bpRootFolder, "original-file-2"))