From b03372dc8896736b7d02337a65e49ba846550c42 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 22 Oct 2026 08:12:24 -0700 Subject: [PATCH] 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. --- test/fuse_integration/mounted_unix.go | 4 +++- test/fuse_integration/mounted_unix_test.go | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/fuse_integration/mounted_unix_test.go diff --git a/test/fuse_integration/mounted_unix.go b/test/fuse_integration/mounted_unix.go index 85889b9ac4..471b8bb655 100644 --- a/test/fuse_integration/mounted_unix.go +++ b/test/fuse_integration/mounted_unix.go @@ -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 diff --git a/test/fuse_integration/mounted_unix_test.go b/test/fuse_integration/mounted_unix_test.go new file mode 100644 index 0000000000..ed47185519 --- /dev/null +++ b/test/fuse_integration/mounted_unix_test.go @@ -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) + } + } +}