pub struct CpioBuilder { /* private fields */ }Expand description
A builder for creating cpio newc archives suitable for Linux initramfs.
Implementations§
Source§impl CpioBuilder
impl CpioBuilder
Sourcepub fn add_dir(&mut self, path: &str)
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.
Sourcepub fn add_file(&mut self, path: &str, mode: u32, content: &[u8])
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).
Sourcepub fn add_symlink(&mut self, path: &str, target: &str)
pub fn add_symlink(&mut self, path: &str, target: &str)
Add a symlink to the archive.
The symlink path will point to target.
Sourcepub fn add_device(
&mut self,
path: &str,
mode: u32,
devmajor: u32,
devminor: u32,
)
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.
Sourcepub fn finish(self) -> Vec<u8> ⓘ
pub fn finish(self) -> Vec<u8> ⓘ
Finalize the archive by appending the TRAILER!!! entry.
Returns the raw (uncompressed) cpio archive bytes.
Sourcepub fn finish_gzipped(self) -> Result<Vec<u8>, KernelError>
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.