From 94a45bd982b40308721e0df7d788808570a27575 Mon Sep 17 00:00:00 2001 From: "Brad P. Crochet" Date: Mon, 25 Mar 2024 21:22:38 -0400 Subject: [PATCH] Ensure /dev is mounted before losetup is called 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 rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED --- lib/src/install.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/src/install.rs b/lib/src/install.rs index 96002fb6..3ed0e325 100644 --- a/lib/src/install.rs +++ b/lib/src/install.rs @@ -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"; @@ -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.