MCPcopy Create free account
hub / github.com/bootc-dev/bootc / find_uki_path

Function find_uki_path

crates/lib/src/kernel.rs:139–166  ·  view source on GitHub ↗

Returns the path to the first UKI found in the container root, if any. Looks in `/boot/EFI/Linux/*.efi`. If multiple UKIs are present, returns the first one in sorted order for determinism.

(root: &Dir)

Source from the content-addressed store, hash-verified

137/// Looks in `/boot/EFI/Linux/*.efi`. If multiple UKIs are present, returns
138/// the first one in sorted order for determinism.
139fn find_uki_path(root: &Dir) -> Result<Option<Utf8PathBuf>> {
140 let Some(boot) = root.open_dir_optional(crate::install::BOOT)? else {
141 return Ok(None);
142 };
143 let Some(efi_linux) = boot.open_dir_optional(EFI_LINUX)? else {
144 return Ok(None);
145 };
146
147 let mut uki_files = Vec::new();
148 for entry in efi_linux.entries()? {
149 let entry = entry?;
150 let name = entry.file_name();
151 let name_path = Path::new(&name);
152 let extension = name_path.extension().and_then(|v| v.to_str());
153 if extension == Some("efi") {
154 if let Some(name_str) = name.to_str() {
155 uki_files.push(name_str.to_owned());
156 }
157 }
158 }
159
160 // Sort for deterministic behavior when multiple UKIs are present
161 uki_files.sort();
162 Ok(uki_files
163 .into_iter()
164 .next()
165 .map(|filename| Utf8PathBuf::from(format!("boot/{EFI_LINUX}/{filename}"))))
166}
167
168#[cfg(test)]
169mod tests {

Callers 2

find_kernelFunction · 0.85

Calls 3

to_strMethod · 0.80
nextMethod · 0.45
into_iterMethod · 0.45

Tested by 1