Skip to content

Conversation

gabriel-samfira
Copy link
Contributor

Symlinks on Windows are implemented using NTFS reparse points. Reparse points are also used when creating volume mounts on Windows. As far as golang is concerned, mountpoints and symlinks look the same. This change makes the distinction between the two and allows safely renaming symlinks, while erring out for anything else that looks like a symlink.

Signed-off-by: Gabriel Adrian Samfira gsamfira@cloudbasesolutions.com

Symlinks on Windows are implemented using NTFS reparse points. Reparse
points are also used when creating volume mounts on Windows. As far as
golang is concerned, mountpoints and symlinks look the same. This change
makes the distinction between the two and allows safely renaming
symlinks, while erring out for anything else that looks like a symlink.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
// +build windows

package fsutil

import (
"fmt"
ioFS "io/fs"
Copy link
Owner

Choose a reason for hiding this comment

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

what's up with this package alias. fs doesn't even seem to be used elsewhere in the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remnant from splitting up the previous PR. Changing it now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahh! I remember now. There is a type fs struct{} defined here: https://github.com/tonistiigi/fsutil/blob/master/fs.go#L29

gabriel@arrakis:~/work/msft/fsutil$ GOOS=windows go build ./...
# github.com/tonistiigi/fsutil
./fs.go:29:6: fs already declared through import of package fs ("io/fs")
        ./diskwriter_windows.go:8:2: other declaration of fs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only way we can import io/fs is if we rename that struct. I think the aliased import is probably the path with the least amount of code changes 😄 . What do you think?

Copy link
Owner

Choose a reason for hiding this comment

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

Ok, but make it all lowercase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Import was renamed. Please take another look.

@gabriel-samfira gabriel-samfira force-pushed the fix-diskwriter-on-windows branch 2 times, most recently from 6861ae6 to 4e7d36d Compare February 14, 2023 22:36
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
@gabriel-samfira gabriel-samfira force-pushed the fix-diskwriter-on-windows branch from 5b9d415 to 2305f0a Compare February 14, 2023 22:49
@tonistiigi tonistiigi merged commit a3696a2 into tonistiigi:master Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants