From b97349d4a0173ad650ea4775ecdcc4287b90f297 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 --- rust/src/cliwrap/kernel_install.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/rust/src/cliwrap/kernel_install.rs b/rust/src/cliwrap/kernel_install.rs index cc2a0077b0..4bd906c4b6 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,8 @@ 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); + generate_initfs(&k)?; redo_systemctl_wrap()?; } Ok(()) @@ -64,13 +68,20 @@ fn redo_systemctl_wrap() -> Result<()> { Ok(()) } -#[context("Running dracut")] -fn run_dracut(kernel_dir: &str) -> Result<()> { +#[context("Generate initfs")] +fn generate_initfs(kernel_dir: &str) -> Result<()> { let root_fs = Utf8Dir::open_ambient_dir("/", cap_std::ambient_authority())?; let tmp_dir = tempfile::tempdir()?; let tmp_initramfs_path = tmp_dir.path().join("initramfs.img"); - let cliwrap_dracut = Utf8Path::new(cliwrap::CLIWRAP_DESTDIR).join("dracut"); + let mut ramdisk_tool = String::new(); + let initoverlayfs_path = Path::new(INITOVERLAY_INSTALL_CMD); + if initoverlayfs_path.exists() { + ramdisk_tool = INITOVERLAY_INSTALL_CMD + } else { + ramdisk_tool = "dracut" + } + let cliwrap_dracut = Utf8Path::new(cliwrap::CLIWRAP_DESTDIR).join(ramdisk_tool); let dracut_path = cliwrap_dracut .exists() .then(|| cliwrap_dracut)