From e4535772ca3f11084ee5fa4d4bd3a542e143b80f Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Sat, 15 Dec 2018 18:52:26 +1100 Subject: [PATCH] os: make Stat work on FAT file system 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 TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/os/types_windows.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/os/types_windows.go b/src/os/types_windows.go index 8636dc7f05d..5e33292bec6 100644 --- a/src/os/types_windows.go +++ b/src/os/types_windows.go @@ -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{