Skip to content

Commit

Permalink
install: Don't retarget /tmp or /var/tmp if they're not overlayfs
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
cgwalters committed Dec 14, 2023
1 parent 4515bf6 commit dfc9b9a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"))?;
Expand Down

0 comments on commit dfc9b9a

Please sign in to comment.