Skip to content

Commit a1de91b

Browse files
composefs/uki: Remove stripping .staged suffix on finalize
We were stripping `.staged` suffix from UKI/UKI Addons whenever unstaging the bootloader entries for the currently staged composefs deployment. Earlier we needed this as we were putting all EFI binaries in `ESP/EFI/Linux` all of which (staged or unstaged) would be picked up by the bootloader which is not what we want. We now put all EFI binaries in `ESP/EFI/Linux/bootc` and use BLS .conf files to point to the binaries, which makes the `.staged` suffix for EFI binaries irrelevant. Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 2829403 commit a1de91b

1 file changed

Lines changed: 3 additions & 40 deletions

File tree

crates/lib/src/bootc_composefs/finalize.rs

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ use cap_std_ext::dirext::CapStdExtDirExt;
1414
use cfsctl::composefs;
1515
use composefs::generic_tree::{Directory, Stat};
1616
use etc_merge::{compute_diff, merge, print_diff, traverse_etc};
17-
use rustix::fs::{fsync, renameat};
18-
use rustix::path::Arg;
17+
use rustix::fs::fsync;
1918

2019
use fn_error_context::context;
2120

@@ -124,23 +123,17 @@ pub(crate) async fn composefs_backend_finalize(
124123

125124
let boot_dir = storage.require_boot_dir()?;
126125

127-
let esp_mount = storage.require_esp()?;
128-
129126
// NOTE: Assuming here we won't have two bootloaders at the same time
130127
match booted_composefs.bootloader {
131128
Bootloader::Grub => match staged_composefs.boot_type {
132129
BootType::Bls => {
133130
let entries_dir = boot_dir.open_dir("loader")?;
134131
rename_exchange_bls_entries(&entries_dir)?;
135132
}
136-
BootType::Uki => finalize_staged_grub_uki(&esp_mount.fd, boot_dir)?,
133+
BootType::Uki => finalize_staged_grub_uki(boot_dir)?,
137134
},
138135

139136
Bootloader::Systemd => {
140-
if matches!(staged_composefs.boot_type, BootType::Uki) {
141-
rename_staged_uki_entries(&esp_mount.fd)?;
142-
}
143-
144137
let entries_dir = boot_dir.open_dir("loader")?;
145138
rename_exchange_bls_entries(&entries_dir)?;
146139
}
@@ -152,9 +145,7 @@ pub(crate) async fn composefs_backend_finalize(
152145
}
153146

154147
#[context("Grub: Finalizing staged UKI")]
155-
fn finalize_staged_grub_uki(esp_mount: &Dir, boot_fd: &Dir) -> Result<()> {
156-
rename_staged_uki_entries(esp_mount)?;
157-
148+
fn finalize_staged_grub_uki(boot_fd: &Dir) -> Result<()> {
158149
let entries_dir = boot_fd.open_dir("grub2")?;
159150
rename_exchange_user_cfg(&entries_dir)?;
160151

@@ -163,31 +154,3 @@ fn finalize_staged_grub_uki(esp_mount: &Dir, boot_fd: &Dir) -> Result<()> {
163154

164155
Ok(())
165156
}
166-
167-
#[context("Renaming staged UKI entries")]
168-
fn rename_staged_uki_entries(esp_mount: &Dir) -> Result<()> {
169-
for entry in esp_mount.entries()? {
170-
let entry = entry?;
171-
172-
let filename = entry.file_name();
173-
let filename = filename.as_str()?;
174-
175-
if !filename.ends_with(".staged") {
176-
continue;
177-
}
178-
179-
renameat(
180-
&esp_mount,
181-
filename,
182-
&esp_mount,
183-
// SAFETY: We won't reach here if not for the above condition
184-
filename.strip_suffix(".staged").unwrap(),
185-
)
186-
.context("Renaming {filename}")?;
187-
}
188-
189-
let esp_mount = esp_mount.reopen_as_ownedfd()?;
190-
fsync(esp_mount).context("fsync")?;
191-
192-
Ok(())
193-
}

0 commit comments

Comments
 (0)