resolve_kernel_dir_to_entry

Function resolve_kernel_dir_to_entry 

Source
pub fn resolve_kernel_dir_to_entry(
    path: &Path,
    cli_label: &str,
    cpu_cap: Option<CpuCap>,
) -> Result<KernelDirOutcome>
Expand description

Resolve a source-tree path through the local-kernel cache, returning a KernelDirOutcome that carries the boot-image directory, the cache-hit signal, and the dirty-tree flag.

For a clean source tree:

  • Cache hit → outcome.dir is the cache entry directory, outcome.cache_hit is Some(KernelDirCacheHit), outcome.is_dirty is false. The build pipeline does not run.
  • Cache miss, no mid-build mutation → runs kernel_build_pipeline which builds in the source tree and stores a stripped vmlinux + boot image under the cache entry; outcome.dir is the cache entry directory, outcome.cache_hit is None, outcome.is_dirty is false.
  • Cache miss, mid-build mutation observed by the pipeline’s post-build re-check → the cache store is skipped to avoid recording a stale identity, outcome.dir is the canonical source-tree directory, outcome.cache_hit is None, outcome.is_dirty is true.

For a dirty source tree:

  • kernel_build_pipeline skips the cache store (is_dirty short-circuit at the cache-store boundary) and returns the source-tree image. outcome.dir is the canonical source-tree directory (boot image at <source>/arch/x86/boot/bzImage (x86_64) or <source>/arch/arm64/boot/Image (aarch64) — the kernel build-tree arch subdir (x86/arm64), not the arch_info() name), outcome.cache_hit is None, outcome.is_dirty is true. Callers use the dirty flag to mark the run as non-reproducible in test reports — e.g. cargo-ktstr’s Path-spec resolver appends _dirty to the kernel label so a path_linux_a3b1c2_dirty row in the gauntlet output surfaces the divergence from the cache-stored path_linux_a3b1c2 clean variant.

Both directory return shapes are valid inputs to crate::kernel_path::find_image_in_dir, which probes both layouts. Callers that need the boot-image FILE path (not the directory) should use resolve_kernel_dir instead — that function applies the same pipeline but returns the image path.

Used by cargo-ktstr’s Path-spec resolver to wire --kernel PATH invocations through the same cache pipeline that Version/CacheKey/Git specs use, so a clean source-tree rebuild hits the cache instead of re-running make.

cli_label prefixes status output and is threaded into kernel_build_pipeline’s diagnostic surface. cpu_cap forwards the resource-budget cap; None keeps the 30%-of-allowed default. See resolve_kernel_dir for the matching image-returning sibling’s cpu_cap rationale — identical here because both functions reach the same pipeline.