Skip to content

fix(archive): handle whiteout ancestors during root path resolution - #38

Open
dinoallo wants to merge 1 commit into
labring:v1.7from
dinoallo:fix/overlay-whiteout-rootpath
Open

fix(archive): handle whiteout ancestors during root path resolution#38
dinoallo wants to merge 1 commit into
labring:v1.7from
dinoallo:fix/overlay-whiteout-rootpath

Conversation

@dinoallo

Copy link
Copy Markdown
Collaborator

Background

Archive apply can still fail with ENOTDIR when the destination already contains an overlay whiteout ancestor. fs.RootPath resolves parent paths before mkparent runs, so a path like .vscode-server/cli can fail while .vscode-server is still a c 0,0 whiteout.

Changes

  • Retry parent path resolution after replacing an overlay whiteout ancestor.
  • Skip delayed directory mtime replay when the directory was removed by a later whiteout entry.
  • Ignore ENOTDIR while copying lower parent directory attributes, so a non-directory lower ancestor only prevents attribute copy-up.
  • Add regression coverage for whiteout ancestors, delayed mtime replay, and lower parent ENOTDIR handling.

Risks / Notes

Only overlay whiteout character devices are replaced. Regular files, symlinks, and non-whiteout device nodes remain non-directory parents and continue to fail.

Copilot AI review requested due to automatic review settings July 31, 2026 10:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens archive.Apply (naive tar apply) against overlay/OCI whiteout edge cases where non-directory ancestors (notably overlay whiteout character devices) can cause fs.RootPath or metadata replay to fail, and adds regression coverage for those scenarios.

Changes:

  • Add rootPathReplacingWhiteoutAncestor to retry fs.RootPath after detecting and replacing an overlay whiteout ancestor via mkparent.
  • Make directory mtime replay tolerant of directories that no longer exist / are no longer directories, and ignore ENOTDIR when copying lower-parent directory attributes.
  • Add Linux tests covering whiteout ancestors, delayed mtime replay with removal, and lower-parent ENOTDIR handling.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
archive/tar.go Adjust root path resolution and parent creation logic to handle overlay whiteout ancestors and tolerate ENOENT/ENOTDIR during delayed metadata replay / lower-parent attribute copy.
archive/tar_linux_test.go Add regression tests for removed-directory mtime replay and lower-parent ENOTDIR behavior (plus existing overlay whiteout ancestor coverage).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread archive/tar.go
Comment on lines 317 to 331
for _, hdr := range dirs {
path, err := fs.RootPath(root, hdr.Name)
if err != nil {
if isNotExistOrNotDir(err) {
continue
}
return 0, err
}
if err := chtimes(path, boundTime(latestTime(hdr.AccessTime, hdr.ModTime)), boundTime(hdr.ModTime)); err != nil {
if isNotExistOrNotDir(err) {
continue
}
return 0, err
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants