Skip to content

Commit

Permalink
Ensure /dev is mounted before losetup is called
Browse files Browse the repository at this point in the history
Not a race condition, but more of a timing issue. Just needed to make
sure the /dev mount was happening before any of the losetup calls.

Fixes #352

Signed-off-by: Brad P. Crochet <brad@redhat.com>

rh-pre-commit.version: 2.2.0
rh-pre-commit.check-secrets: ENABLED
  • Loading branch information
bcrochet committed Mar 26, 2024
1 parent cc98447 commit 94a45bd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ const SELINUXFS: &str = "/sys/fs/selinux";
#[cfg(feature = "install")]
const EFIVARFS: &str = "/sys/firmware/efi/efivars";
pub(crate) const ARCH_USES_EFI: bool = cfg!(any(target_arch = "x86_64", target_arch = "aarch64"));
/// The mount path for devtmpfs
#[cfg(feature = "install")]
const DEVTMPFS: &str = "/dev";

/// Kernel argument used to specify we want the rootfs mounted read-write by default
const RW_KARG: &str = "rw";
Expand Down Expand Up @@ -1076,6 +1079,14 @@ async fn prepare_install(
super::cli::ensure_self_unshared_mount_namespace().await?;
}

// We need to ensure that /dev is mounted before we get to any losetup tasks
for (fstype, fspath) in [("devtmpfs", DEVTMPFS)] {
let _ = Task::new(format!("Mounting {fstype} {fspath}"), "mount")
.args(["-t", fstype, fstype, fspath])
.quiet()
.run();
}

setup_sys_mount("efivarfs", EFIVARFS)?;

// Now, deal with SELinux state.
Expand Down

0 comments on commit 94a45bd

Please sign in to comment.