find_kernel

Function find_kernel 

Source
pub fn find_kernel() -> Result<Option<PathBuf>>
Expand description

Find a bootable kernel image on the host.

Resolution chain:

  1. KTSTR_KERNEL env var, parsed via KernelId:
    • Path: search that directory for an arch-specific image
    • Version/CacheKey: require cache access (error if cache directory cannot be opened); on cache miss, skip the general cache scan (step 2) and fall to filesystem
  2. XDG cache: most recent cached image (newest first)
  3. Local build trees (./linux, ../linux, /lib/modules/{release}/build)
  4. Host paths (/lib/modules/{release}/vmlinuz, /boot/vmlinuz-{release}, /boot/vmlinuz)

Returns Err when KTSTR_KERNEL is a path that does not contain a kernel image, or when it is a version/cache key and the cache directory cannot be opened. Returns Ok(None) when no kernel is found.