]> Cypherpunks repositories - gostls13.git/commitdiff
os: make Stat work on FAT file system
authorAlex Brainman <alex.brainman@gmail.com>
Sat, 15 Dec 2018 07:52:26 +0000 (18:52 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Mon, 17 Dec 2018 09:34:04 +0000 (09:34 +0000)
It appears calling GetFileInformationByHandleEx with
FILE_ATTRIBUTE_TAG_INFO fails on FAT file system. FAT does not
support symlinks, so assume there are no symlnks when
GetFileInformationByHandleEx returns ERROR_INVALID_PARAMETER.

Fixes #29214

Change-Id: If2d9f3288bd99637681ab5fd4e4581c77b578a69
Reviewed-on: https://go-review.googlesource.com/c/154377
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/os/types_windows.go

index 8636dc7f05d9e1d4c38053977133b15fe38cc8d6..5e33292bec68197771b515c695eafec4386630cb 100644 (file)
@@ -51,7 +51,15 @@ func newFileStatFromGetFileInformationByHandle(path string, h syscall.Handle) (f
        var ti windows.FILE_ATTRIBUTE_TAG_INFO
        err = windows.GetFileInformationByHandleEx(h, windows.FileAttributeTagInfo, (*byte)(unsafe.Pointer(&ti)), uint32(unsafe.Sizeof(ti)))
        if err != nil {
-               return nil, &PathError{"GetFileInformationByHandleEx", path, err}
+               if errno, ok := err.(syscall.Errno); ok && errno == windows.ERROR_INVALID_PARAMETER {
+                       // It appears calling GetFileInformationByHandleEx with
+                       // FILE_ATTRIBUTE_TAG_INFO fails on FAT file system with
+                       // ERROR_INVALID_PARAMETER. Clear ti.ReparseTag in that
+                       // instance to indicate no symlinks are possible.
+                       ti.ReparseTag = 0
+               } else {
+                       return nil, &PathError{"GetFileInformationByHandleEx", path, err}
+               }
        }
 
        return &fileStat{