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

@@ -133,7 +133,7 @@ func fsStatDir(statDir string) (os.FileInfo, error) {
return nil, traceError(err)
}
fi, err := os.Stat(preparePath(statDir))
fi, err := osStat(preparePath(statDir))
if err != nil {
if os.IsNotExist(err) {
return nil, traceError(errVolumeNotFound)
@@ -160,7 +160,7 @@ func fsStatFile(statFile string) (os.FileInfo, error) {
return nil, traceError(err)
}
fi, err := os.Stat(preparePath(statFile))
fi, err := osStat(preparePath(statFile))
if err != nil {
if os.IsNotExist(err) {
return nil, traceError(errFileNotFound)
@@ -206,7 +206,7 @@ func fsOpenFile(readPath string, offset int64) (io.ReadCloser, int64, error) {
}
// Stat to get the size of the file at path.
st, err := fr.Stat()
st, err := osStat(preparePath(readPath))
if err != nil {
return nil, 0, traceError(err)
}
@@ -344,7 +344,7 @@ func fsDeleteFile(basePath, deletePath string) error {
}
// Verify if the path exists.
pathSt, err := os.Stat(preparePath(deletePath))
pathSt, err := osStat(preparePath(deletePath))
if err != nil {
if os.IsNotExist(err) {
return traceError(errFileNotFound)