mirror of
https://github.com/golang/go
synced 2024-09-04 23:44:16 +00:00
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 <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
bc175e53cc
commit
e4535772ca
|
@ -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{
|
||||
|
|
Loading…
Reference in a new issue