kernel_list

Function kernel_list 

Source
pub fn kernel_list(json: bool) -> Result<()>
Expand description

List cached kernel images.

§JSON output schema (--json)

{
  "current_ktstr_kconfig_hash": "abc123...",
  "active_prefixes_fetch_error": null,
  "entries": [
    {
      "key": "7.1.0-rc2",
      "path": "/path/to/cache/entry",
      "version": "7.1.0-rc2",
      "source": { "type": "tarball" },
      "arch": "x86_64",
      "built_at": "2026-04-15T12:34:56Z",
      "ktstr_kconfig_hash": "abc123...",
      "extra_kconfig_hash": null,
      "kconfig_status": "matches",
      "eol": false,
      "config_hash": "def456...",
      "image_name": "bzImage",
      "image_path": "/path/to/cache/entry/bzImage",
      "has_vmlinux": true,
      "vmlinux_stripped": true
    },
    {
      "key": "6.12.0-broken",
      "path": "/path/to/cache/broken-entry",
      "error": "metadata.json schema drift: missing field `source` at line 1 column 21",
      "error_kind": "schema_drift"
    }
  ]
}

Wrapper fields:

  • current_ktstr_kconfig_hash: hex digest of the kconfig fragment the running binary was built against, so consumers can detect entries that were built with a different fragment.
  • active_prefixes_fetch_error: null on success, human-readable error string on failure to fetch the active kernel-series list from kernel.org. When non-null, eol annotation is disabled for the run (no series data to compare against) and every entry’s eol is false regardless of actual support status — so consumers must check this field before trusting eol.
  • entries: heterogeneous array; each element is either a valid entry (object with the full field set) or a corrupt entry (object with key, path, error, and error_kind). Corrupt entries have a structurally different shape — consumers should detect the "error" key and branch.

Entry fields (valid entries):

  • kconfig_status: one of "matches", "stale", or "untracked" (the Display forms of cache::KconfigStatus). matches means the entry’s ktstr_kconfig_hash equals current_ktstr_kconfig_hash; stale means they differ; untracked means the entry has no recorded kconfig hash (pre-dates kconfig hash tracking).
  • extra_kconfig_hash: CRC32 (8 hex chars, lowercase) of the user --extra-kconfig fragment as raw bytes (no canonicalization), or null when the entry was built without --extra-kconfig. Cache keys grow from kc{baked} to kc{baked}-xkc{extra} when extras are present; this field stores the xkc segment so kernel list is self-describing for entries that carry user modifications. Independent of kconfig_status — an entry can match the baked-in hash AND carry a non-null extras hash.
  • eol: true iff the entry’s version series does not appear in the active-prefix list. Only meaningful when active_prefixes_fetch_error is null.
  • has_vmlinux: whether the cache entry includes the uncompressed vmlinux (needed for DWARF-driven probes); when false, only the compressed image_path is available.
  • vmlinux_stripped: whether the cached vmlinux came from a successful strip pass (true) or the raw-fallback path (false). A false here indicates the strip pipeline errored on this kernel and the unstripped bytes were copied instead — the entry still works but carries a large on-disk payload that signals a parseability regression worth investigating. Always false when has_vmlinux is false.
  • source: tagged object (serde internally tagged on "type"). Variants: {"type": "tarball"}, {"type": "git", "git_hash": ?, "ref": ?}, {"type": "local", "source_tree_path": ?, "git_hash": ?}. Variant-specific fields are nullable — consumers must dispatch on "type" before reading them. See cache::KernelSource.

Entry fields (corrupt entries):

  • error: human-readable reason from cache::read_metadata, prefixed by failure class so programmatic consumers can branch on starts_with without parsing the free-form tail. Prefixes:

    • "metadata.json missing" — file absent (not a cache entry).
    • "metadata.json unreadable: ..." — I/O error on fs::read_to_string other than ENOENT (e.g. EISDIR, permission).
    • "metadata.json schema drift: ..." — JSON parsed but does not match the KernelMetadata shape (serde_json Category::Data). Typical cause: older cache from a ktstr whose schema has since changed.
    • "metadata.json malformed: ..." — not valid JSON at all (serde_json Category::Syntax).
    • "metadata.json truncated: ..." — JSON ends mid-value (serde_json Category::Eof), e.g. a partially-written metadata from a crashed store().
    • "metadata.json parse error: ..." — fallback for an unexpected Category::Io from from_str; does not fire on the current serde_json version but kept as a defense-in-depth fallback so the field is never absent.
    • "image file <name> missing from entry directory" — metadata parsed cleanly but the declared image file is gone (partial download, manual deletion, failed strip+rename).

    The example above shows the schema-drift case; consumers that treat corrupt entries as a single category can key on the "error" key alone.

  • error_kind: machine-readable classification of the failure mode — a stable snake_case identifier CI scripts can dispatch on without parsing the free-form error. Values: "missing", "unreadable", "schema_drift", "malformed", "truncated", "parse_error", "image_missing", and "unknown" as a defensive fallback for a future producer prefix that has not yet been taught to the classifier. Always present on corrupt entries; always absent on valid entries. See crate::cache::ListedEntry::error_kind for the classifier contract.