From c880caae4e18eeb227de759a7eeb08d365f117c4 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Thu, 23 Jun 2016 13:34:38 -0700 Subject: [PATCH] Fix overlay2 ignoring whiteout files Currently when overlay creates a whiteout file then the overlay2 layer is archived, the correct tar header will be created for the whiteout file, but the tar logic will then attempt to open the file causing a failure. When tar encounters such failures the file is skipped and excluded for the archive, causing the whiteout to be ignored. By skipping the copy of empty files, no open attempt will be made on whiteout files. Fixes #23863 Signed-off-by: Derek McGowan (github: dmcgowan) --- archive/archive.go | 2 +- archive/archive_linux.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/archive/archive.go b/archive/archive.go index 4f0b4ff..aec3b39 100644 --- a/archive/archive.go +++ b/archive/archive.go @@ -359,7 +359,7 @@ func (ta *tarAppender) addTarFile(path, name string) error { return err } - if hdr.Typeflag == tar.TypeReg { + if hdr.Typeflag == tar.TypeReg && hdr.Size > 0 { file, err := os.Open(path) if err != nil { return err diff --git a/archive/archive_linux.go b/archive/archive_linux.go index 86d2c7f..277ff98 100644 --- a/archive/archive_linux.go +++ b/archive/archive_linux.go @@ -26,6 +26,7 @@ func (overlayWhiteoutConverter) ConvertWrite(hdr *tar.Header, path string, fi os hdr.Name = WhiteoutPrefix + hdr.Name hdr.Mode = 0600 hdr.Typeflag = tar.TypeReg + hdr.Size = 0 } if fi.Mode()&os.ModeDir != 0 {