← Back to Pull requests

mountinfo: use statx in Mounted and MountedFast #281

Open
unknown opened this pull request with 160 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 14, 2026 21:03 UTC
Author

Since Linux v5.8, statx(2) reports the STATX_ATTR_MOUNT_ROOT attribute, which tells whether a path is the root of a mount. It works for all kinds of mounts, including bind mounts, and takes a single syscall.

This PR makes it the first method tried by Mounted and MountedFast:

  • The path is only made absolute and clean (filepath.Abs), not fully normalized: the kernel resolves symlinks itself, and filepath.EvalSymlinks (an lstat per path component) was the most expensive part of Mounted. .. is still handled lexically, as before.

  • AT_NO_AUTOMOUNT is used so that checking an automount point does not trigger the automount; this is consistent with the existing methods (verified with /sys/kernel/debug/tracing on tracefs).

  • If statx fails for any reason (old kernel, seccomp, non-existent path) or the kernel does not report STATX_ATTR_MOUNT_ROOT, the existing chain (openat2 → stat → mountinfo) is used, so returned errors are unchanged.
  • Result: Mounted is about 10x faster (523 vs 5056 ns/op for a path with 6 components) 👯.

    Tests: mountedByStatx is added to TestMountedBy (which covers bind mounts of dirs, files and sockets, symlinks, etc. when run as root), and a new TestMountedByStatxVsMountinfo checks it against every entry in mountinfo.

    Diff: 160 lines (+120 / -40) across 2 files Reviewer: kolyshkin Review duration: 11473m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.35) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.35 · 160 lines diff across 2 files
    0.35
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.304
    Real PR Conversation Timeline
    1 comments
    "Review active on #281"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 34.8% (LOW) · Higher = larger blast radius
    34.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.6% · Safe to merge
    18.6%
    Repository