Repository navigation
Fix filesystem type detection for stacked Linux mounts - #137748
Merged
Merged
Conversation
Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-io |
adamsitnik
approved these changes
Nov 18, 2026
adamsitnik
left a comment
Member
There was a problem hiding this comment.
LGTM, thank you for fixing it @krwq !
Member
Author
|
/azp run runtime-android |
Member
Author
|
/azp run runtime-androidemulator |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
1 similar comment
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This was referenced Nov 20, 2026
Member
Author
CI failures analysis (Copilot generated)No reviewed failure was attributed to this PR. New trackers: 3 for failed CI + 2 for non-blocking warnings.
|
Member
Author
|
/ba-g unrelated failures, issues are tracked as in the table above |
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.
Follow-up to #137195, which fixed escaped mount paths reported in #123347. This addresses offline feedback about stacked-mount selection, separately from escaped-path decoding.
Problem
Linux allows another filesystem to be mounted at a directory that is already a mount point. File access uses the new mount, but
/proc/self/mountinfostill lists the earlier one. The current lookup stops at the first exact-path match, soDriveInfocan report the hidden filesystem instead of the one the path actually reaches.Choosing the longest matching path is not sufficient either: mounting a new filesystem at a parent directory also hides mounts below the old parent.
Both cases were reproduced with real mounts on Ubuntu 24.04.5, Linux 6.12.115-adc.2 x64, using installed .NET 11.0.0:
DriveFormat/DriveTypetargetext4/Fixedtmpfs/Ramtarget/childtmpfs/Ramtmpfs/Ramtarget/childinside tmpfsext4/Fixedtmpfs/RamNative
statfsreported tmpfs for every queried path. The proposed selector also returned tmpfs for every path when run against the same live mount table.Why fix this
This affects behavior, not just the filesystem name displayed to a user. For example, code filtering on
DriveType.Fixedaccepts the tmpfs mount even though it should be classified asRam. The directory and its child can also disagree despite accessing the same filesystem.The issue was identified through offline feedback and confirmed with a controlled Linux reproduction, rather than an exact matching customer report. This is a correctness fix for the metadata returned by the API; it does not change mounts, file access, or kernel permissions.
Change
Follow mount IDs and parent IDs to select the filesystem that is actually reachable. This handles both same-directory stacks and child mounts hidden by a newer parent mount, without assuming record order or selecting the largest mount ID.
Mount identifiers remain spans in the shared parser and are converted only for matching paths. Mount enumeration, escaped-path decoding, and native interop are unchanged. No newer kernel feature is required.
Validation
Results so far
The live comparison exercised the proposed helper, not a rebuilt patched public
DriveInfoassembly. That end-to-end patched API run remains outstanding. .NET 10, autofs, and optical media were not exercised.Reproduce the public API bug
No PR, CI, or runtime build is needed. The following recipe was run successfully with the installed .NET 11 SDK/runtime.
Use a new empty directory on a non-tmpfs/non-ramfs filesystem. This requires Linux, Bash, GNU coreutils, util-linux, the .NET 11 SDK/targeting pack, and permission to create a private mount namespace and mounts (
CAP_SYS_ADMIN). Root inside a restricted container may still lack that permission. The script refuses to mount anything in the original namespace.Self-contained reproduction
Save this as
Program.cs:Save this as
repro.sh. The local SDK and build configuration files keep the standalone project independent of the runtime repository's build settings.Run the entire script for each setup:
On the tested ext4 host, the first run printed
ext4/Fixedfor the target andtmpfs/Ramfor the child. The second printedext4/Fixedfor both. In both runs,stat -freported tmpfs for both paths.The correct public API result is
tmpfs/Ramfor both paths in both setups. The incorrectly selected lower type depends on the backing filesystem. A zero script exit code means the setup and cleanup succeeded; compare the printed API results withstat -fto detect the bug.Validate the patch
From the repository root on Linux, build the normal component baseline and run the regression suites:
For the remaining end-to-end check, run the same probe inside the same private mount setup using the patched repository testhost instead of the installed runtime. Confirm that it loads the rebuilt DriveInfo assembly and returns
tmpfs/Ramfor both paths in both setups.Tradeoff
Exact-path lookups now scan the whole mount table to account for other mounts at the same directory or above it, rather than stopping at the first match. The selector retains only matching path prefixes and adds no native calls. This is a correctness change, not a performance optimization.
Fixes #137745
Note
This pull request was opened with GitHub Copilot.