Skip to content

worktree prune safety round 7: mirrored parent mounts, raw paths, cached namespace views (part of #15298) - #15930

Merged
TrapsterDK merged 1 commit into
mainfrom
prune-safe-7
Dec 6, 2026
Merged

TrapsterDK merged 1 commit into
mainfrom
prune-safe-7

Conversation

@TrapsterDK

Copy link
Copy Markdown
Collaborator

Fixes the post-merge review of #15925.

  • Mirrored parent mounts (host.rs): a mount now records whether it shows the host directory at the host's own path. Such a mirror of a parent of the worktree, from a snap service, another user's Flatpak or bwrap, or -v /home:/home, no longer holds every slot on its own, whether /home is its own partition or a bind of /home from the root filesystem. A mirror at or inside the worktree still counts, and so does a writable parent bind at another path, such as -v /home:/data. The "other user can enter" rule is unchanged. A root process can't be read, so a root container that only mirrors /home and works in a slot is no longer seen.
  • Raw paths (host.rs): an own process in another mount namespace keeps its raw cwd, fd and map paths next to the mapped ones, so a same-path bind still matches when a deeper host mount on the same device wins the mapping.
  • Cost (host.rs): the mount mapping, including each mount's canonical host path, is built once per mount namespace and shared by every process in that namespace.
  • Tests:
    • add now reports an oversized user.bazelrc with the code include_too_large, built from ErrorKind::FileTooLarge, and the test checks that code.
    • The own-process "/" case now goes through a parent bind at another path, so the test fails if the mapping breaks.

Regression tests:

  • a_parent_mount_holds_the_worktree_only_when_writable_and_not_a_mirror (table; replaces the read-only-bind test)
  • a_same_path_bind_counts_when_a_deeper_host_mount_wins_the_mapping
  • processes_in_one_mount_namespace_share_one_mapping
  • an_own_process_in_another_mount_namespace_counts_where_its_paths_lead_on_the_host (updated)
  • add_copies_user_bazelrc_only_from_a_bounded_regular_file (updated)
  • mounts_outside_the_own_namespace_map_back_to_host_directories (mirror flag)

Docs: docs/cli/commands/worktree.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xut2hw5ZsSt78ouJoi3QnQ

…hed namespace views (part of #15298)

- a mount that shows a parent of the worktree at the host's own path, as a
  snap service, Flatpak or -v /home:/home does, no longer holds every slot
  on its own; the other-user entry rule is unchanged
- an own process in another mount namespace keeps its raw paths next to
  the mapped ones, so a same-path bind still matches
- the mount mapping is built once per mount namespace
- add reports an oversized user.bazelrc as include_too_large
@TrapsterDK
TrapsterDK merged commit 70d1e49 into main Dec 6, 2026
0 of 7 checks passed
@TrapsterDK
TrapsterDK deleted the prune-safe-7 branch December 6, 2026 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant