Skip to content
4 changes: 2 additions & 2 deletions crates/lib/src/bootc_composefs/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ pub(crate) async fn write_composefs_state(
}

pub(crate) fn composefs_usr_overlay(access_mode: FilesystemOverlayAccessMode) -> Result<()> {
let status = get_composefs_usr_overlay_status()?;
let status = get_usr_overlay_status()?;
if status.is_some() {
println!("An overlayfs is already mounted on /usr");
return Ok(());
Expand All @@ -351,7 +351,7 @@ pub(crate) fn composefs_usr_overlay(access_mode: FilesystemOverlayAccessMode) ->
Ok(())
}

pub(crate) fn get_composefs_usr_overlay_status() -> Result<Option<FilesystemOverlay>> {
pub(crate) fn get_usr_overlay_status() -> Result<Option<FilesystemOverlay>> {
let usr = Dir::open_ambient_dir("/usr", ambient_authority()).context("Opening /usr")?;
let is_usr_mounted = usr
.is_mountpoint(".")
Expand Down
4 changes: 2 additions & 2 deletions crates/lib/src/bootc_composefs/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
bootc_composefs::{
boot::BootType,
selinux::are_selinux_policies_compatible,
state::{get_composefs_usr_overlay_status, read_origin},
state::{get_usr_overlay_status, read_origin},
utils::{compute_store_boot_digest_for_uki, get_uki_cmdline},
},
composefs_consts::{
Expand Down Expand Up @@ -1059,7 +1059,7 @@ async fn composefs_deployment_status_from(
host.spec.boot_order = BootOrder::Rollback
};

host.status.usr_overlay = get_composefs_usr_overlay_status().ok().flatten();
host.status.usr_overlay = get_usr_overlay_status().ok().flatten();

set_soft_reboot_capability(storage, &mut host, sorted_bls_config, cmdline)?;

Expand Down
7 changes: 7 additions & 0 deletions crates/lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use serde::{Deserialize, Serialize};
use crate::bootc_composefs::delete::delete_composefs_deployment;
use crate::bootc_composefs::gc::{GCOpts, composefs_gc};
use crate::bootc_composefs::soft_reboot::{prepare_soft_reboot_composefs, reset_soft_reboot};
use crate::bootc_composefs::state::get_usr_overlay_status;
use crate::bootc_composefs::{
digest::{compute_composefs_digest, new_temp_composefs_repo},
finalize::{composefs_backend_finalize, get_etc_diff},
Expand Down Expand Up @@ -1733,6 +1734,12 @@ async fn edit(opts: EditOpts) -> Result<()> {

/// Implementation of `bootc usroverlay`
async fn usroverlay(access_mode: FilesystemOverlayAccessMode) -> Result<()> {
let status = get_usr_overlay_status()?;
if status.is_some() {
println!("An overlayfs is already mounted on /usr");
return Ok(());
}

// This is just a pass-through today. At some point we may make this a libostree API
// or even oxidize it.
let args = match access_mode {
Expand Down
66 changes: 36 additions & 30 deletions crates/lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1707,12 +1707,12 @@ async fn prepare_install(
println!("Digest: {digest}");
}

let root_filesystem = target_fs
.or(install_config
.as_ref()
.and_then(|c| c.filesystem_root())
.and_then(|r| r.fstype))
.ok_or_else(|| anyhow::anyhow!("No root filesystem specified"))?;
// Don't error out if a filesystem is not passed in via cli as we could have
// repart.d definitions available
let root_filesystem = target_fs.or(install_config
.as_ref()
.and_then(|c| c.filesystem_root())
.and_then(|r| r.fstype));

let mut is_uki = false;

Expand All @@ -1723,37 +1723,43 @@ async fn prepare_install(
// we hard require it in that particular case
//
// NOTE: This isn't really 100% accurate 100% of the time as the cmdline can be in an addon
match kernel {
Some(k) => match k.k_type {
crate::kernel::KernelType::Uki { cmdline, .. } => {
let allow_missing_fsverity = cmdline.is_some_and(|cmd| {
ComposefsCmdline::find_in_cmdline(&cmd)
.is_some_and(|cfs_cmdline| cfs_cmdline.allow_missing_fsverity)
});

if !allow_missing_fsverity {
anyhow::ensure!(
root_filesystem.supports_fsverity(),
"Specified filesystem {root_filesystem} does not support fs-verity"
);
}
if let Some(root_filesystem) = root_filesystem {
match kernel {
Some(k) => match k.k_type {
crate::kernel::KernelType::Uki { cmdline, .. } => {
let allow_missing_fsverity = cmdline.is_some_and(|cmd| {
ComposefsCmdline::find_in_cmdline(&cmd)
.is_some_and(|cfs_cmdline| cfs_cmdline.allow_missing_fsverity)
});

if !allow_missing_fsverity {
anyhow::ensure!(
root_filesystem.supports_fsverity(),
"Specified filesystem {root_filesystem} does not support fs-verity"
);
}

composefs_options.allow_missing_verity = allow_missing_fsverity;
is_uki = true;
}
composefs_options.allow_missing_verity = allow_missing_fsverity;
is_uki = true;
}

crate::kernel::KernelType::Vmlinuz { .. } => {}
},
crate::kernel::KernelType::Vmlinuz { .. } => {}
},

None => {}
}
None => {}
}

// If `--allow-missing-verity` is already passed via CLI, don't modify
if composefs_options.composefs_backend && !composefs_options.allow_missing_verity && !is_uki {
composefs_options.allow_missing_verity = !root_filesystem.supports_fsverity();
// If `--allow-missing-verity` is already passed via CLI, don't modify
if composefs_options.composefs_backend && !composefs_options.allow_missing_verity && !is_uki
{
composefs_options.allow_missing_verity = !root_filesystem.supports_fsverity();
}
}

tracing::info!(
root_filesystem = root_filesystem
.map(|f| f.to_string())
.unwrap_or("None".into()),
allow_missing_fsverity = composefs_options.allow_missing_verity,
uki = is_uki,
"ComposeFS install prep",
Expand Down
Loading