Skip to content

Commit dfc9b9a

Browse files
committed
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 osbuild/bootc-image-builder#18 (comment)
1 parent 4515bf6 commit dfc9b9a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/src/install.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,12 +827,20 @@ fn ensure_var() -> Result<()> {
827827
pub(crate) fn propagate_tmp_mounts_to_host() -> Result<()> {
828828
// Point our /tmp and /var/tmp at the host, via the /proc/1/root magic link
829829
for path in ["/tmp", "/var/tmp"].map(Utf8Path::new) {
830+
if path.try_exists()? {
831+
let st = rustix::fs::statfs(path.as_std_path()).context(path)?;
832+
if st.f_type != libc::OVERLAYFS_SUPER_MAGIC {
833+
tracing::trace!("Already have {path} with f_type={}", st.f_type);
834+
continue;
835+
}
836+
}
830837
let target = format!("/proc/1/root/{path}");
831838
let tmp = format!("{path}.tmp");
832839
// Ensure idempotence in case we're re-executed
833840
if path.is_symlink() {
834841
continue;
835842
}
843+
tracing::debug!("Retargeting {path} to host");
836844
if path.try_exists()? {
837845
std::os::unix::fs::symlink(&target, &tmp)
838846
.with_context(|| format!("Symlinking {target} to {tmp}"))?;

0 commit comments

Comments
 (0)