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]>
Co-authored-by: Colin Walters <[email protected]>
  • Loading branch information
dougsland and cgwalters committed Feb 15, 2024
1 parent fc39c53 commit 96e5270
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion rust/src/cliwrap/kernel_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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(())
Expand All @@ -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())?;
Expand Down Expand Up @@ -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(())
}

0 comments on commit 96e5270

Please sign in to comment.