Browse Source

feat(cpio): add newc archive creation utility

dracut-cpio is a minimal cpio archive creation utility written in Rust.
It provides support for a minimal set of features needed to create
performant and space-efficient initramfs archives:
- "newc" archive format only
- reproducible; inode numbers, uid/gid and mtime can be explicitly set
- data segment copy-on-write reflinks
  + using Rust io::copy()'s native copy_file_range() support[1]
  + optional archive data segment alignment for optimal reflink use[2]
- hardlink support
- comprehensive tests asserting GNU cpio binary output compatibility

1. Rust io::copy() copy_file_range()
   https://github.com/rust-lang/rust/pull/75272

2. Data segment alignment
   We're bending the newc spec a bit to inject zeros after the file path
   to provide data segment alignment. These zeros are accounted for in
   the namesize, but some applications may only expect a single
   zero-terminator (and 4 byte alignment). GNU cpio and Linux initramfs
   handle this fine as long as PATH_MAX isn't exceeded.

Signed-off-by: David Disseldorp <ddiss@suse.de>
master
David Disseldorp 3 years ago committed by Harald Hoyer
parent
commit
a9c6704643
  1. 12
      src/dracut-cpio/Cargo.lock
  2. 11
      src/dracut-cpio/Cargo.toml
  3. 1717
      src/dracut-cpio/src/main.rs

12
src/dracut-cpio/Cargo.lock generated

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "crosvm"
version = "0.1.0"

[[package]]
name = "dracut-cpio"
version = "0.1.0"
dependencies = [
"crosvm",
]

11
src/dracut-cpio/Cargo.toml

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
[package]
name = "dracut-cpio"
description = "cpio archive generator for Dracut"
authors = ["David Disseldorp"]
license = "GPL-2.0"
version = "0.1.0"
edition = "2018"

[dependencies]
crosvm = { path = "third_party/crosvm" }
# please avoid adding any more dependencies

1717
src/dracut-cpio/src/main.rs

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save