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>,
)
| 17 | /// Find the kernel modules directory in a bootable OSTree commit. |
| 18 | /// The target directory will have a `vmlinuz` file representing the kernel binary. |
| 19 | pub 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 | |
| 47 | fn read_dir_optional( |
| 48 | d: &Dir, |
no outgoing calls