Skip to content

Commit 5b52216

Browse files
ostree/usr-overlay: Check if an overlay already exists
Similar to what we have in the composefs path, check if there already exists an overlay at `/usr`. This fixes the error in `test-install-repart.nu` where a second install was failing for ostree due to an overlay already existing on `/usr` Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 0b6e341 commit 5b52216

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

crates/lib/src/bootc_composefs/state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ pub(crate) async fn write_composefs_state(
329329
}
330330

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

354-
pub(crate) fn get_composefs_usr_overlay_status() -> Result<Option<FilesystemOverlay>> {
354+
pub(crate) fn get_usr_overlay_status() -> Result<Option<FilesystemOverlay>> {
355355
let usr = Dir::open_ambient_dir("/usr", ambient_authority()).context("Opening /usr")?;
356356
let is_usr_mounted = usr
357357
.is_mountpoint(".")

crates/lib/src/bootc_composefs/status.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{
1414
bootc_composefs::{
1515
boot::BootType,
1616
selinux::are_selinux_policies_compatible,
17-
state::{get_composefs_usr_overlay_status, read_origin},
17+
state::{get_usr_overlay_status, read_origin},
1818
utils::{compute_store_boot_digest_for_uki, get_uki_cmdline},
1919
},
2020
composefs_consts::{
@@ -1059,7 +1059,7 @@ async fn composefs_deployment_status_from(
10591059
host.spec.boot_order = BootOrder::Rollback
10601060
};
10611061

1062-
host.status.usr_overlay = get_composefs_usr_overlay_status().ok().flatten();
1062+
host.status.usr_overlay = get_usr_overlay_status().ok().flatten();
10631063

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

crates/lib/src/cli.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ use serde::{Deserialize, Serialize};
4141
use crate::bootc_composefs::delete::delete_composefs_deployment;
4242
use crate::bootc_composefs::gc::{GCOpts, composefs_gc};
4343
use crate::bootc_composefs::soft_reboot::{prepare_soft_reboot_composefs, reset_soft_reboot};
44+
use crate::bootc_composefs::state::get_usr_overlay_status;
4445
use crate::bootc_composefs::{
4546
digest::{compute_composefs_digest, new_temp_composefs_repo},
4647
finalize::{composefs_backend_finalize, get_etc_diff},
@@ -1664,6 +1665,12 @@ async fn edit(opts: EditOpts) -> Result<()> {
16641665

16651666
/// Implementation of `bootc usroverlay`
16661667
async fn usroverlay(access_mode: FilesystemOverlayAccessMode) -> Result<()> {
1668+
let status = get_usr_overlay_status()?;
1669+
if status.is_some() {
1670+
println!("An overlayfs is already mounted on /usr");
1671+
return Ok(());
1672+
}
1673+
16671674
// This is just a pass-through today. At some point we may make this a libostree API
16681675
// or even oxidize it.
16691676
let args = match access_mode {

0 commit comments

Comments
 (0)