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

Function find_kernel_dir

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

Find the kernel modules directory in a bootable OSTree commit. The target directory will have a `vmlinuz` file representing the kernel binary.

(
    root: &gio::File,
    cancellable: Option<&gio::Cancellable>,
)

Source from the content-addressed store, hash-verified

17/// Find the kernel modules directory in a bootable OSTree commit.
18/// The target directory will have a `vmlinuz` file representing the kernel binary.
19pub fn find_kernel_dir(
20 root: &gio::File,
21 cancellable: Option<&gio::Cancellable>,
22) -> Result<Option<gio::File>> {
23 let moddir = root.resolve_relative_path(MODULES);
24 let e = moddir.enumerate_children(
25 "standard::name",
26 gio::FileQueryInfoFlags::NOFOLLOW_SYMLINKS,
27 cancellable,
28 )?;
29 let mut r = None;
30 for child in e.clone() {
31 let child = &child?;
32 if child.file_type() != gio::FileType::Directory {
33 continue;
34 }
35 let childpath = e.child(child);
36 let vmlinuz = childpath.child(VMLINUZ);
37 if !vmlinuz.query_exists(cancellable) {
38 continue;
39 }
40 if r.replace(childpath).is_some() {
41 anyhow::bail!("Found multiple subdirectories in {}", MODULES);
42 }
43 }
44 Ok(r)
45}
46
47fn read_dir_optional(
48 d: &Dir,

Callers 3

commit_has_aboot_imgFunction · 0.85
test_tar_import_exportFunction · 0.85

Calls

no outgoing calls

Tested by 2

test_tar_import_exportFunction · 0.68