Skip to main content

KdumpBuilder

Struct KdumpBuilder 

Source
pub struct KdumpBuilder { /* private fields */ }
Expand description

Build a synthetic kdump (makedumpfile) dump for testing.

Produces the disk_dump_header + kdump_sub_header + bitmaps + page descriptors + compressed page data layout used by makedumpfile and crash-utility.

File layout (block_size = 4096 by default):

  • Block 0: disk_dump_header
  • Block 1: kdump_sub_header (mostly zeros for test)
  • Blocks 2..2+N: 1st bitmap (valid PFNs)
  • Blocks 2+N..2+2N: 2nd bitmap (dumped PFNs)
  • After bitmaps: page_desc[] array (24 bytes each, block-aligned)
  • After descs: compressed page data

disk_dump_header (Block 0):

  • 0x00: signature “KDUMP “ (8 bytes, 3 trailing spaces)
  • 0x08: header_version = 6 (i32)
  • 0x0C: utsname (390 bytes = 6 fields * 65, zeros)
  • Aligned to 4 after utsname: block_size(i32) + sub_hdr_size(i32=1) + bitmap_blocks(u32) + max_mapnr(u32)

page_desc (24 bytes each):

  • offset: i64 (file offset of compressed data)
  • size: u32 (compressed size)
  • flags: u32 (compression method)
  • page_flags: u64 (kernel flags, 0 for test)

Implementations§

Source§

impl KdumpBuilder

Source

pub fn new() -> Self

Create a new builder with defaults: block_size=4096, compression=snappy (0x04).

Source

pub fn block_size(self, bs: u32) -> Self

Set the block size (must be a power of 2, typically 4096).

Source

pub fn compression(self, flags: u32) -> Self

Set the compression flags for page data.

  • 0x00: uncompressed
  • 0x01: zlib
  • 0x04: snappy
  • 0x20: zstd (stored as minimal zstd frame)
Source

pub fn add_page(self, pfn: u64, data: &[u8]) -> Self

Add a physical page at the given PFN with data (must be exactly block_size bytes).

Source

pub fn build(self) -> Vec<u8>

Build the complete kdump file as a byte vector.

Trait Implementations§

Source§

impl Default for KdumpBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.