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>)
| 874 | /// Remove the known file if present, then walk up removing each parent |
| 875 | /// under `/run` that has no remaining children in the set. |
| 876 | fn 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)] |
| 899 | mod tests { |
no test coverage detected