MCPcopy Create free account
hub / github.com/bootc-dev/bootc / prune_known_run_paths

Function prune_known_run_paths

crates/lib/src/lints.rs:876–896  ·  view source on GitHub ↗

Remove known container-runtime injected paths from `/run`. Podman/buildah inject files like `/run/systemd/resolve/stub-resolv.conf` for DNS resolution, creating the parent directory tree as a side effect. The file itself is usually already filtered out (it's a bind mount detected by `is_mountpoint()`), but the parent directories `/run/systemd` and `/run/systemd/resolve` remain. Remove the known

(paths: &mut BTreeSet<Utf8PathBuf>)

Source from the content-addressed store, hash-verified

874/// Remove the known file if present, then walk up removing each parent
875/// under `/run` that has no remaining children in the set.
876fn prune_known_run_paths(paths: &mut BTreeSet<Utf8PathBuf>) {
877 let run_prefix = Utf8Path::new("/run");
878 for known in CONTAINER_RUNTIME_FILES {
879 let known = Utf8Path::new(known);
880 paths.remove(known);
881 // Walk up the parent directories, removing each one only if
882 // nothing else in the set is underneath it.
883 let mut dir = known.parent();
884 while let Some(d) = dir {
885 if !d.starts_with(run_prefix) || d == run_prefix {
886 break;
887 }
888 let has_other_children = paths.iter().any(|p| p != d && p.starts_with(d));
889 if has_other_children {
890 break;
891 }
892 paths.remove(d);
893 dir = d.parent();
894 }
895 }
896}
897
898#[cfg(test)]
899mod tests {

Callers 1

check_runtime_only_dirsFunction · 0.85

Calls 2

removeMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected