From b377e2cdc9248e2559d1d9f76512b7aaeaac27bb Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 22 Oct 2026 08:12:24 -0700 Subject: [PATCH] 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. --- test/fuse_integration/mounted_unsupported.go | 2 +- test/fuse_integration/mounted_windows.go | 34 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 test/fuse_integration/mounted_windows.go diff --git a/test/fuse_integration/mounted_unsupported.go b/test/fuse_integration/mounted_unsupported.go index c288b8c2e1..1d698e5241 100644 --- a/test/fuse_integration/mounted_unsupported.go +++ b/test/fuse_integration/mounted_unsupported.go @@ -1,4 +1,4 @@ -//go:build !unix +//go:build !unix && !windows package fuse diff --git a/test/fuse_integration/mounted_windows.go b/test/fuse_integration/mounted_windows.go new file mode 100644 index 0000000000..4a8d199b3a --- /dev/null +++ b/test/fuse_integration/mounted_windows.go @@ -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 +}