fuse integration: clean TEST_MOUNT_POINT before the parent-device check

filepath.Dir of a trailing-slash path returns the mount itself, so a mounted TEST_MOUNT_POINT ending in / was refused.
This commit is contained in:
Chris Lu committed 2026-10-22 08:12:24 -07:00
1 parent 41088e93f6
commit b03372dc88
2 files changed
+22 -1

No files matched your search

+3 -1
View File
@@ -17,8 +17,10 @@ func deviceID(path string) (uint64, error) {
}
// mountedAt reports whether something is actually mounted at path: a plain
// directory shares its parent's device, a mount point does not.
// directory shares its parent's device, a mount point does not. The path is
// cleaned first so a trailing slash does not make Dir return the mount itself.
func mountedAt(path string) bool {
path = filepath.Clean(path)
dev, err := deviceID(path)
if err != nil {
return false
@@ -0,0 +1,19 @@
//go:build unix
package fuse
import "testing"
func TestMountedAt(t *testing.T) {
for _, p := range []string{"/proc", "/proc/"} {
if !mountedAt(p) {
t.Errorf("mountedAt(%q) = false, want true", p)
}
}
plain := t.TempDir()
for _, p := range []string{plain, plain + "/"} {
if mountedAt(p) {
t.Errorf("mountedAt(%q) = true, want false", p)
}
}
}