diff --git a/lib/src/install.rs b/lib/src/install.rs index 430d67054..e7fa2f9f4 100644 --- a/lib/src/install.rs +++ b/lib/src/install.rs @@ -40,7 +40,6 @@ use ostree_ext::ostree; use ostree_ext::prelude::Cast; use ostree_ext::sysroot::SysrootLock; use rustix::fs::{FileTypeExt, MetadataExt as _}; -use rustix::thread::Pid; use serde::{Deserialize, Serialize}; use self::baseline::InstallBlockDeviceOpts; @@ -1641,9 +1640,10 @@ pub(crate) async fn install_to_filesystem( && fsopts.root_path.as_str() == ALONGSIDE_ROOT_MOUNT && !fsopts.root_path.try_exists()? { + tracing::debug!("Mounting host / to {ALONGSIDE_ROOT_MOUNT}"); std::fs::create_dir(ALONGSIDE_ROOT_MOUNT)?; crate::mount::bind_mount_from_pidns( - Pid::from_raw(1).unwrap(), + crate::mount::PID1, "/".into(), ALONGSIDE_ROOT_MOUNT.into(), true, diff --git a/lib/src/mount.rs b/lib/src/mount.rs index d4785b179..037dbef56 100644 --- a/lib/src/mount.rs +++ b/lib/src/mount.rs @@ -23,6 +23,14 @@ use serde::Deserialize; use crate::task::Task; +/// Well known identifier for pid 1 +pub(crate) const PID1: Pid = const { + match Pid::from_raw(1) { + Some(v) => v, + None => panic!("Expected to parse pid1"), + } +}; + #[derive(Deserialize, Debug)] #[serde(rename_all = "kebab-case")] #[allow(dead_code)] @@ -266,5 +274,5 @@ pub(crate) fn ensure_mirrored_host_mount(path: impl AsRef) -> Result<( return Ok(()); } tracing::debug!("Propagating host mount: {path}"); - bind_mount_from_pidns(Pid::from_raw(1).unwrap(), path, path, true) + bind_mount_from_pidns(PID1, path, path, true) }