From 05b4f6a64c08c76a537b8d9d6b19bd83e6f2363b Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 14 Dec 2023 14:24:34 -0500 Subject: [PATCH] install: Don't retarget /tmp or /var/tmp if they're not overlayfs It may be that we're involved via a container flow where e.g. `/tmp` is already "properly" set up as a tmpfs. In that case we don't need to do a dance in retargeting. xref https://github.com/osbuild/bootc-image-builder/issues/18#issuecomment-1855886913 Signed-off-by: Colin Walters --- lib/src/install.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/src/install.rs b/lib/src/install.rs index 89863cf3..ccf20f19 100644 --- a/lib/src/install.rs +++ b/lib/src/install.rs @@ -827,12 +827,20 @@ fn ensure_var() -> Result<()> { pub(crate) fn propagate_tmp_mounts_to_host() -> Result<()> { // Point our /tmp and /var/tmp at the host, via the /proc/1/root magic link for path in ["/tmp", "/var/tmp"].map(Utf8Path::new) { + if path.try_exists()? { + let st = rustix::fs::statfs(path.as_std_path()).context(path)?; + if st.f_type != libc::OVERLAYFS_SUPER_MAGIC { + tracing::trace!("Already have {path} with f_type={}", st.f_type); + continue; + } + } let target = format!("/proc/1/root/{path}"); let tmp = format!("{path}.tmp"); // Ensure idempotence in case we're re-executed if path.is_symlink() { continue; } + tracing::debug!("Retargeting {path} to host"); if path.try_exists()? { std::os::unix::fs::symlink(&target, &tmp) .with_context(|| format!("Symlinking {target} to {tmp}"))?;