Skip to main content

CpioBuilder

Struct CpioBuilder 

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

A builder for creating cpio newc archives suitable for Linux initramfs.

Implementations§

Source§

impl CpioBuilder

Source

pub fn new() -> Self

Create a new, empty cpio archive builder.

Source

pub fn add_dir(&mut self, path: &str)

Add a directory entry to the archive.

path must not include a leading / in the archive (e.g., “bin”, “etc”). Mode 0o755 is used for directories.

Source

pub fn add_file(&mut self, path: &str, mode: u32, content: &[u8])

Add a regular file to the archive.

path is the archive-internal path (e.g., “init”, “bin/busybox”). mode is the Unix file mode (e.g., 0o100755 for executable).

Add a symlink to the archive.

The symlink path will point to target.

Source

pub fn add_device( &mut self, path: &str, mode: u32, devmajor: u32, devminor: u32, )

Add a device node (character or block).

mode should include the device type bits (e.g., 0o020666 for char device). devmajor and devminor are the device major/minor numbers.

Source

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

Finalize the archive by appending the TRAILER!!! entry.

Returns the raw (uncompressed) cpio archive bytes.

Source

pub fn finish_gzipped(self) -> Result<Vec<u8>, KernelError>

Finalize and gzip-compress the archive.

Returns the gzipped cpio archive suitable for use as a Linux initramfs.

Trait Implementations§

Source§

impl Default for CpioBuilder

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> Same for T

Source§

type Output = T

Should always be Self
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.