parse_ld_cache

Function parse_ld_cache 

Source
pub fn parse_ld_cache(input: &[u8]) -> Result<LdCache, CacheError>
Expand description

Parses an ld.so.cache file from raw bytes.

This is the main entry point for parsing cache files. It automatically detects the format (old, new, or combined) and delegates to the appropriate parser.

§Arguments

  • input - Raw bytes of the cache file

§Returns

A parsed LdCache structure containing all discovered cache data.

§Errors

  • CacheError::TruncatedFile - Input is too short to contain valid cache data
  • CacheError::InvalidMagic - File doesn’t start with a recognized magic number
  • CacheError::ParseError - Parsing failed due to malformed data

§Examples

use ld_so_cache::parsers::parse_ld_cache;
use std::fs;

let data = fs::read("/etc/ld.so.cache")?;
let cache = parse_ld_cache(&data)?;

println!("Found {} library entries", cache.get_entries()?.len());