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

Function find_kernel_dir_fs

crates/ostree-ext/src/bootabletree.rs:60–90  ·  view source on GitHub ↗

Find the kernel modules directory in checked out directory tree. The target directory will have a `vmlinuz` file representing the kernel binary.

(root: &Dir)

Source from the content-addressed store, hash-verified

58/// Find the kernel modules directory in checked out directory tree.
59/// The target directory will have a `vmlinuz` file representing the kernel binary.
60pub fn find_kernel_dir_fs(root: &Dir) -> Result<Option<Utf8PathBuf>> {
61 let mut r = None;
62 let entries = if let Some(entries) = read_dir_optional(root, MODULES)? {
63 entries
64 } else {
65 return Ok(None);
66 };
67 for child in entries {
68 let child = &child?;
69 if !child.file_type()?.is_dir() {
70 continue;
71 }
72 let name = child.file_name();
73 let name = if let Some(n) = name.to_str() {
74 n
75 } else {
76 continue;
77 };
78 let mut pbuf = Utf8Path::new(MODULES).to_owned();
79 pbuf.push(name);
80 pbuf.push(VMLINUZ);
81 if !root.try_exists(&pbuf)? {
82 continue;
83 }
84 pbuf.pop();
85 if r.replace(pbuf).is_some() {
86 anyhow::bail!("Found multiple subdirectories in {}", MODULES);
87 }
88 }
89 Ok(r)
90}
91
92/// Check if there is an aboot image in the kernel tree dir
93pub fn commit_has_aboot_img(

Callers 2

check_kernelFunction · 0.85
find_kernelFunction · 0.85

Calls 2

read_dir_optionalFunction · 0.85
to_strMethod · 0.80

Tested by

no test coverage detected