Skip to content

Commit

Permalink
initoverlayfs: Add initial initoverlayfs support
Browse files Browse the repository at this point in the history
Run initoverlayfs in case the binary exists.

Signed-off-by: Douglas Schilling Landgraf <[email protected]>
  • Loading branch information
dougsland committed Feb 20, 2024
1 parent fc39c53 commit b97349d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions rust/src/cliwrap/kernel_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down Expand Up @@ -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(())
Expand All @@ -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)
Expand Down

0 comments on commit b97349d

Please sign in to comment.