mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-23 22:40:39 +02:00
fuse integration: detect WinFsp mounts on Windows in mountedAt
A directory mount is a reparse point and a drive mount is a volume root; a plain directory is now refused instead of accepted.
This commit is contained in:
1 parent
b03372dc88
commit
b377e2cdc9
2 files changed
+35
-1
No files matched your search
@@ -1,4 +1,4 @@
|
||||
//go:build !unix
|
||||
//go:build !unix && !windows
|
||||
|
||||
package fuse
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
//go:build windows
|
||||
|
||||
package fuse
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// deviceID has no portable meaning here: reporting one device keeps
|
||||
// waitForMount from mistaking the plain pre-mount directory for a live mount.
|
||||
func deviceID(path string) (uint64, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// mountedAt reports whether path is a WinFsp mount: a directory mount is a
|
||||
// reparse point and a drive mount is a volume root, while a plain directory
|
||||
// is neither.
|
||||
func mountedAt(path string) bool {
|
||||
abs, err := filepath.Abs(path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if filepath.Dir(abs) == abs {
|
||||
return true
|
||||
}
|
||||
info, err := os.Lstat(abs)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
data, ok := info.Sys().(*syscall.Win32FileAttributeData)
|
||||
return ok && data.FileAttributes&syscall.FILE_ATTRIBUTE_REPARSE_POINT != 0
|
||||
}
|
||||
Reference in new issue
Block a user