Repository navigation
mountinfo: fix ParentsFilter and PrefixFilter edge cases - #271
Merged
Merged
Conversation
kolyshkin
force-pushed
the
mountinfo-parents-filter
branch
from
October 26, 2026 19:20
7c0bd23 to
790381d
Compare
ParentsFilter is only tested against the fedoraMountinfo fixture. Add a table-driven unit test for it, similar to TestPrefixFilter. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
ParentsFilter does a plain string prefix match, so, for example, a mount point of "/a" is considered to be a parent of "/aa". Fix it to match on path components instead, similar to what commit f11a7ca did for PrefixFilter. The root mount point has to be special-cased, as it already ends with a slash. Document the requirements for the path argument, same as for PrefixFilter. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
PrefixFilter appends a slash to both the prefix and the mount point
before comparing them. For the root prefix, this results in "//",
which only matches the root mount itself, so PrefixFilter("/")
returns a single entry rather than all of them.
Since every mount point is under "/", special-case it.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
kolyshkin
force-pushed
the
mountinfo-parents-filter
branch
from
October 26, 2026 19:56
790381d to
44e556e
Compare
vvoland
approved these changes
Oct 26, 2026
There was a problem hiding this comment.
🟢 Approval recommended
The focused fixes match the documented behavior and include regression coverage for the affected edge cases, with no unresolved findings.
No open issues 🎉
What changed in this PR
Fixes two mount-filter edge cases so parent matching respects path boundaries and the root prefix includes all mounts.
Changes:
- Prevents
ParentsFilterfrom treating/aas a parent of/aaand documents input requirements. - Makes
PrefixFilter("/")include all mounts, aligning recursive unmount behavior with its documentation. - Adds regression tests for root prefixes and parent-path matching.
| File | Description |
|---|---|
mountinfo/mountinfo_filters.go |
Corrects both filters and clarifies parent-filter requirements. |
mountinfo/mountinfo_filters_test.go |
Adds root-prefix cases and table-driven parent-filter coverage. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ParentsFilterdid a plain string prefix match, so a mount point of/awas considered to be a parent of
/aa. Fix it to match on path components,similar to what commit f11a7ca did for
PrefixFilter. Add a table-drivenunit test for
ParentsFilter(first commit), and test cases for the fix.PrefixFilter("/")only returned the root mount itself, as the root prefixbecomes
//after appending a slash. Fix it to return all mounts.Note this changes the behavior of
mount.RecursiveUnmount("/")slow path:it used to try unmounting
/only, and now it tries to unmount all mounts(deepest first), as documented.