Skip to content

Commit f48158e

Browse files
committed
Filter out BLS entries not managed by bootc
1 parent f9d5d2f commit f48158e

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

crates/lib/src/bootc_composefs/status.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crate::{
1919
composefs_consts::{
2020
COMPOSEFS_CMDLINE, ORIGIN_KEY_BOOT_DIGEST, ORIGIN_KEY_IMAGE, ORIGIN_KEY_MANIFEST_DIGEST,
2121
TYPE1_ENT_PATH, TYPE1_ENT_PATH_STAGED, USER_CFG, USER_CFG_STAGED,
22+
BLS_ENTRY_PREFIX,
2223
},
2324
install::EFI_LOADER_INFO,
2425
parsers::{
@@ -304,7 +305,7 @@ fn get_sorted_type1_boot_entries_helper(
304305
.to_str()
305306
.ok_or(anyhow::anyhow!("Found non UTF-8 characters in filename"))?;
306307

307-
if !file_name.ends_with(".conf") {
308+
if !(file_name.starts_with(BLS_ENTRY_PREFIX) && file_name.ends_with(".conf")) {
308309
continue;
309310
}
310311

@@ -1094,8 +1095,16 @@ mod tests {
10941095
"loader/entries/random_file.txt",
10951096
"Random file that we won't parse",
10961097
)?;
1097-
tempdir.atomic_write("loader/entries/entry1.conf", entry1)?;
1098-
tempdir.atomic_write("loader/entries/entry2.conf", entry2)?;
1098+
tempdir.atomic_write(
1099+
"loader/entries/random_file.conf",
1100+
"Random file that we won't parse",
1101+
)?;
1102+
tempdir.atomic_write(
1103+
"loader/entries/bootc_random_file.txt",
1104+
"Random file that we won't parse",
1105+
)?;
1106+
tempdir.atomic_write("loader/entries/bootc_entry1.conf", entry1)?;
1107+
tempdir.atomic_write("loader/entries/bootc_entry2.conf", entry2)?;
10991108

11001109
let result =
11011110
get_sorted_type1_boot_entries_helper(&tempdir, true, false, Bootloader::Systemd)
@@ -1257,8 +1266,8 @@ mod tests {
12571266

12581267
tempdir.create_dir_all("loader/entries")?;
12591268
tempdir.create_dir_all("loader/entries.staged")?;
1260-
tempdir.atomic_write("loader/entries/active.conf", active_entry)?;
1261-
tempdir.atomic_write("loader/entries.staged/staged.conf", staged_entry)?;
1269+
tempdir.atomic_write("loader/entries/bootc_active.conf", active_entry)?;
1270+
tempdir.atomic_write("loader/entries.staged/bootc_staged.conf", staged_entry)?;
12621271

12631272
let result = list_type1_entries(&tempdir)?;
12641273
assert_eq!(result.len(), 2);

crates/lib/src/composefs_consts.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ pub(crate) const TYPE1_BOOT_DIR_PREFIX: &str = "bootc_composefs-";
4848
/// The prefix for names of UKI and UKI Addons
4949
pub(crate) const UKI_NAME_PREFIX: &str = TYPE1_BOOT_DIR_PREFIX;
5050

51+
/// The prefix for BLS file entries
52+
pub(crate) const BLS_ENTRY_PREFIX: &str = "bootc_";
53+
5154
/// Prefix for OCI tags owned by bootc in the composefs repository.
5255
///
5356
/// Tags are created as `localhost/bootc-<manifest_digest>` to act as GC roots

0 commit comments

Comments
 (0)