windows: Support all REPARSE_POINT attrib files properly. (#4203)

This change adopts the upstream fix in this regard at
https://go-review.googlesource.com/#/c/41834/ for Minio's
purposes.

Go's current os.Stat() lacks support for lot of strange
windows files such as

 - share symlinks on SMB2
 - symlinks on docker nanoserver
 - de-duplicated files on NTFS de-duplicated volume.

This PR attempts to incorporate the change mentioned here

   https://blogs.msdn.microsoft.com/oldnewthing/20100212-00/?p=14963/

The article suggests to use Windows I/O manager to
dereference the symbolic link.

Fixes #4122
This commit is contained in:
Harshavardhana
2017-05-02 02:35:27 -07:00
committed by GitHub
parent 44d53c9c67
commit f0b5c0ec7c
20 changed files with 497 additions and 56 deletions

View File

@@ -75,12 +75,12 @@ func parseDirents(dirPath string, buf []byte) (entries []string, err error) {
case syscall.DT_REG:
entries = append(entries, name)
case syscall.DT_LNK, syscall.DT_UNKNOWN:
// If its symbolic link, follow the link using os.Stat()
// If its symbolic link, follow the link using osStat()
// On Linux XFS does not implement d_type for on disk
// format << v5. Fall back to Stat().
// format << v5. Fall back to OsStat().
var fi os.FileInfo
fi, err = os.Stat(path.Join(dirPath, name))
fi, err = osStat(path.Join(dirPath, name))
if err != nil {
// If file does not exist, we continue and skip it.
// Could happen if it was deleted in the middle while