Skip to content

Commit

Permalink
Merge pull request #225 from cgwalters/idempotent-tmp-mounts
Browse files Browse the repository at this point in the history
install: Don't retarget /tmp or /var/tmp if they're not overlayfs
  • Loading branch information
vrothberg authored Dec 15, 2023
2 parents 4515bf6 + 05b4f6a commit 2582ef2
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 2582ef2

Please sign in to comment.