mirror of
https://github.com/minio/minio.git
synced 2025-11-10 05:59:43 -05:00
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:
@@ -24,6 +24,8 @@ import (
|
||||
"os"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
os2 "github.com/minio/minio/pkg/x/os"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -51,7 +53,7 @@ func LockedOpenFile(path string, flag int, perm os.FileMode) (*LockedFile, error
|
||||
return nil, err
|
||||
}
|
||||
|
||||
st, err := os.Stat(path)
|
||||
st, err := os2.Stat(path)
|
||||
if err != nil {
|
||||
f.Close()
|
||||
return nil, err
|
||||
@@ -140,7 +142,8 @@ func lockFile(fd syscall.Handle, flags uint32) error {
|
||||
|
||||
func lockFileEx(h syscall.Handle, flags, locklow, lockhigh uint32, ol *syscall.Overlapped) (err error) {
|
||||
var reserved = uint32(0)
|
||||
r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(h), uintptr(flags), uintptr(reserved), uintptr(locklow), uintptr(lockhigh), uintptr(unsafe.Pointer(ol)))
|
||||
r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(h), uintptr(flags),
|
||||
uintptr(reserved), uintptr(locklow), uintptr(lockhigh), uintptr(unsafe.Pointer(ol)))
|
||||
if r1 == 0 {
|
||||
if e1 != 0 {
|
||||
err = error(e1)
|
||||
|
||||
Reference in New Issue
Block a user