From 96e52703b6c8d6c214da0b402d7f827001cec2cf Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Sat, 9 Dec 2023 09:25:42 -0500 Subject: [PATCH] initoverlayfs: Add initial initoverlayfs support Run initoverlayfs in case the binary exists. Signed-off-by: Douglas Schilling Landgraf Co-authored-by: Colin Walters --- rust/src/cliwrap/kernel_install.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/rust/src/cliwrap/kernel_install.rs b/rust/src/cliwrap/kernel_install.rs index cc2a0077b0..115359633c 100644 --- a/rust/src/cliwrap/kernel_install.rs +++ b/rust/src/cliwrap/kernel_install.rs @@ -10,6 +10,9 @@ use cap_std_ext::cap_std; use fn_error_context::context; use std::os::fd::AsRawFd; use std::process::Command; +use std::path::Path; + +const INITOVERLAY_INSTALL_CMD: &str = "/usr/bin/initoverlayfs-install"; /// Primary entrypoint to running our wrapped `kernel-install` handling. #[context("rpm-ostree kernel-install wrapper")] @@ -42,7 +45,12 @@ pub(crate) fn main(argv: &[&str]) -> Result<()> { } if let Some(k) = new_kernel { undo_systemctl_wrap()?; - run_dracut(&k)?; + let initoverlayfs_path = Path::new(INITOVERLAY_INSTALL_CMD); + if initoverlayfs_path.exists() { + run_initoverlayfs()?; + } else { + run_dracut(&k)?; + } redo_systemctl_wrap()?; } Ok(()) @@ -64,6 +72,15 @@ fn redo_systemctl_wrap() -> Result<()> { Ok(()) } +#[context("Running initoverlayfs")] +fn run_initoverlayfs() -> Result<()> { + let st = Command::new(INITOVERLAY_INSTALL_CMD).status()?; + if !st.success() { + anyhow::bail!("Failed to invoke {INITOVERLAY_INSTALL_CMD}"); + } + Ok(()) +} + #[context("Running dracut")] fn run_dracut(kernel_dir: &str) -> Result<()> { let root_fs = Utf8Dir::open_ambient_dir("/", cap_std::ambient_authority())?; @@ -108,5 +125,8 @@ fn run_dracut(kernel_dir: &str) -> Result<()> { &root_fs, (Utf8Path::new("lib/modules").join(kernel_dir)).join("initramfs.img"), )?; + + run_initoverlayfs()?; + Ok(()) }