Skip to content

Commit

Permalink
src: add internal erofs writer code
Browse files Browse the repository at this point in the history
With this change, we create the erofs filesystem for ourselves, instead
of using the external mkcomposefs CLI.

This currently produces a different output than the output of
mkcomposefs.  We're planning to make changes here to make the output
more similar to mkcomposefs while pursuing changes in mkcomposefs to
make it more similar to our format.  This work is being tracked as an
issue in containers/composefs#198 and a first
pull request in containers/composefs#410 .

Closes containers#56

Signed-off-by: Allison Karlitskaya <[email protected]>
  • Loading branch information
allisonkarlitskaya committed Jan 30, 2025
1 parent 8f9c3ac commit 600e69f
Show file tree
Hide file tree
Showing 16 changed files with 2,446 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: sudo tune2fs -O verity $(findmnt -vno SOURCE /)

- name: Install dependencies
run: sudo apt-get install -y meson mtools qemu-system systemd-boot-efi erofs-utils
run: sudo apt-get install -y meson mtools qemu-system systemd-boot-efi

- name: Get a newer podman for heredoc support (from debian testing)
run: |
Expand Down
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ anyhow = { version = "1.0.89", default-features = false }
async-compression = { version = "0.4.17", default-features = false, features = ["tokio", "gzip"] }
clap = { version = "4.5.19", default-features = false, features = ["std", "help", "usage", "derive"] }
containers-image-proxy = "0.7.0"
env_logger = "0.11.5"
hex = "0.4.3"
indicatif = { version = "0.17.8", features = ["tokio"] }
log = "0.4.22"
oci-spec = "0.7.0"
regex-automata = { version = "0.4.8", default-features = false }
rustix = { version = "0.38.37", features = ["fs", "mount", "process"] }
Expand All @@ -26,10 +28,12 @@ tar = { version = "0.4.42", default-features = false }
tempfile = "3.13.0"
thiserror = "2.0.4"
tokio = "1.41.0"
zerocopy = "0.8.13"
xxhash-rust = { version = "0.8.12", features = ["xxh32"] }
zerocopy = { version = "0.8.13", features = ["derive"] }
zstd = "0.13.2"

[dev-dependencies]
insta = "1.42.0"
similar-asserts = "1.6.0"
test-with = { version = "0.14", default-features = false, features = ["executable"] }

Expand Down
2 changes: 2 additions & 0 deletions src/bin/cfsctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ enum Command {
}

fn main() -> Result<()> {
env_logger::init();

let args = App::parse();

let repo = (if let Some(path) = args.repo {
Expand Down
25 changes: 25 additions & 0 deletions src/bin/erofs-debug.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use std::{fs::File, io::Read, path::PathBuf};

use clap::Parser;

use composefs::erofs::debug::debug_img;

/// Produce a detailed dump of an entire erofs image
///
/// The output is in a diff-friendly format, such that every distinct image produces a distinct
/// output (ie: an injective mapping). This is useful for determining the exact ways in which two
/// different images are different.
#[derive(Parser)]
struct Args {
/// The path to the image file to dump
image: PathBuf,
}

fn main() {
let args = Args::parse();
let mut image = File::open(args.image).expect("Opening file");

let mut data = vec![];
image.read_to_end(&mut data).expect("read_to_end() failed");
debug_img(&mut std::io::stdout(), &data).unwrap();
}
Loading

0 comments on commit 600e69f

Please sign in to comment.