From 1da68dba625c904e7f5ce6cfdf23a6ca4ba3aa18 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..c77526eb14 100644 --- a/rust/src/cliwrap/kernel_install.rs +++ b/rust/src/cliwrap/kernel_install.rs @@ -9,8 +9,11 @@ use cap_std::fs_utf8::Dir as Utf8Dir; use cap_std_ext::cap_std; use fn_error_context::context; use std::os::fd::AsRawFd; +use std::path::Path; use std::process::Command; +const INITOVERLAY_INSTALL_CMD: &str = "/usr/bin/initoverlayfs-install"; + /// Primary entrypoint to running our wrapped `kernel-install` handling. #[context("rpm-ostree kernel-install wrapper")] pub(crate) fn main(argv: &[&str]) -> Result<()> { @@ -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(()) }