Skip to content

Commit

Permalink
feat(cpio): add newc archive creation utility
Browse files Browse the repository at this point in the history
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()
   rust-lang/rust#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 <[email protected]>
(cherry picked from commit a9c6704)
  • Loading branch information
ddiss committed Dec 6, 2021
1 parent 25ac286 commit 30d1001
Show file tree
Hide file tree
Showing 3 changed files with 1,740 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/dracut-cpio/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/dracut-cpio/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 30d1001

Please sign in to comment.