Skip to content

Conversation

@jsternberg
Copy link
Collaborator

Clears ModeIrregular from the checksum generation. This may be sent by the client when the version of Go used is post Go 1.23. The behavior of os.Stat was modified in Go 1.23 to set ModeIrregular on reparse points in Windows. This clears ModeIrregular when any mode is set which was the previous behavior of os.Stat.

Fixes docker/for-win#14083.

Clears ModeIrregular from the checksum generation. This may be sent by
the client when the version of Go used is post Go 1.23. The behavior of
`os.Stat` was modified in Go 1.23 to set `ModeIrregular` on reparse
points in Windows. This clears `ModeIrregular` when any mode is set
which was the previous behavior of `os.Stat`.

Signed-off-by: Jonathan A. Sternberg <[email protected]>
@jsternberg jsternberg force-pushed the clear-mode-irregular branch from 5887a6c to 45177da Compare January 15, 2025 19:03
Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

So are these files created as regular empty files on transfer?

// bit to regular files with non-handled reparse points.
// Current versions of Go now apply them to directories too.
// archive/tar.FileInfoHeader does not handle the irregular bit.
if stat.Mode&uint32(os.ModeType&^os.ModeIrregular) != 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the negation wrong in the condition here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The intention is to use os.ModeType but to remove os.ModeIrregular because os.ModeIrregular&os.ModeType will always return non-zero. so this uses the os.ModeType constant but removes os.ModeIrregular from it.

It's a bit tricky because the original condition checks if m&os.ModeType == 0 and sets os.ModeIrregular if it is. But, because we've now set os.ModeIrregular, the condition will always be true so the reverse doesn't work.

@jsternberg
Copy link
Collaborator Author

I think they should get created as regular directories. Files will be excluded from this behavior and will still return an error which is what they previously did. While I used os.ModeType to cover everything like named pipes and others, I think the only things that get irregular set are directories with certain attributes.

@tonistiigi
Copy link
Member

. Files will be excluded from this behavior and will still return an error which is what they previously did.

Where is that error happening?

@jsternberg
Copy link
Collaborator Author

@tonistiigi tonistiigi added this to the v0.19.0 milestone Jan 15, 2025
@thompson-shaun thompson-shaun merged commit f55aa54 into moby:master Jan 16, 2025
97 checks passed
@jsternberg jsternberg deleted the clear-mode-irregular branch January 16, 2025 21:10
@PeterDraex
Copy link

When should this make it into a release? I'm still getting unknown file mode error

Docker Desktop 4.41.2 (191736)
Engine v28.1.1

failed to solve: failed to checksum file .output/server/node_modules/.nitro/@solid-primitives/[email protected]/node_modules/@solid-primitives/utils: archive/tar: unknown file mode ?rwxr-xr-x

@jsternberg
Copy link
Collaborator Author

@PeterDraex do you have a reproducer by any chance? This should be fixed by now. There might be something we've missed.

@jsternberg
Copy link
Collaborator Author

I've opened another issue to fix this. I think I may have made an incorrect assumption in this original fix. I assumed that another mode type would be set at the same time as ModeIrregular and I assumed that, if only ModeIrregular was set, it was a normal file.

These seem to have been invalid assumptions. Looking at the string output of the file mode in both @PeterDraex and the original issue, I see that only ModeIrregular is set. So this solution may have been too conservative. I've opened another pull request to properly fix the original issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

failed to solve: archive/tar: unknown file mode ?rwxr-xr-x while following official tutorial

4 participants