Skip to content

Commit 0ea5d52

Browse files
cgwaltersgiuseppe
authored andcommitted
composefs-oci,composefs-boot: Extend V1 EROFS to OCI and booting
Migrate OCI crate callers to the new RepositoryConfig API and add dual-format (V1+V2) EROFS image generation during OCI pull. The V1 kernel cmdline karg uses a new self-describing format: composefs.digest=v1-sha256-12:<hex> composefs.digest=v1-sha512-12:<hex> The value encodes the EROFS format version, hash algorithm, and block size before the digest, mirroring how meta.json uses fsverity-sha256-12. The stable key name composefs.digest works naturally with ConditionKernelCommandLine= and allows multiple entries on the same cmdline for different algorithm/format combinations. The initramfs (composefs-setup-root) parses all composefs kargs from the kernel cmdline in order, then tries to mount each image in sequence — the first image that actually exists in the repository wins. mount_composefs_image_if_exists() maps ImageNotFound to Ok(None), letting the mount loop skip missing images without swallowing real errors (verity mismatch, permissions, etc.). The legacy composefs=<hex> karg continues to work for V2 EROFS. Assisted-by: OpenCode (Claude Opus 4) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 3097f6e commit 0ea5d52

38 files changed

Lines changed: 2356 additions & 344 deletions

File tree

.github/workflows/bootc-revdep.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ jobs:
4848
# Use bootc branch adapted to composefs-rs API changes
4949
# TODO: revert to main once bootc-dev/bootc merges these adaptations
5050
COMPOSEFS_BOOTC_REPO: https://github.com/cgwalters/bootc
51-
COMPOSEFS_BOOTC_REF: adapt-composefs-rs-api
51+
COMPOSEFS_BOOTC_REF: adapt-composefs-rs-v1-erofs-2

crates/composefs-boot/src/bootloader.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use composefs::{
1919
tree::{DirectoryRef, FileSystem, ImageError, Inode, LeafContent, RegularFile},
2020
};
2121

22-
use crate::cmdline::{make_cmdline_composefs, split_cmdline};
22+
use crate::cmdline::split_cmdline;
2323

2424
/// Strips the key (if it matches) plus the following whitespace from a single line in a "Type #1
2525
/// Boot Loader Specification Entry" file.
@@ -139,11 +139,15 @@ impl BootLoaderEntryFile {
139139
self.lines.push(format!("options {arg}"));
140140
}
141141

142-
/// Adjusts the kernel command-line arguments by adding a composefs= parameter (if appropriate)
143-
/// and adding additional arguments, as requested.
144-
pub fn adjust_cmdline(&mut self, composefs: Option<&str>, insecure: bool, extra: &[&str]) {
145-
if let Some(id) = composefs {
146-
self.add_cmdline(&make_cmdline_composefs(id, insecure));
142+
/// Adjusts the kernel command-line arguments by adding a composefs karg (if provided)
143+
/// and adding additional arguments.
144+
///
145+
/// `karg` should be a complete kernel argument string such as
146+
/// `"composefs.digest=v1-sha256-12:abc123"` or `"composefs=abc123"` as produced by
147+
/// [`composefs_boot::cmdline::ComposefsCmdline::to_cmdline_arg`].
148+
pub fn adjust_cmdline(&mut self, karg: Option<&str>, extra: &[&str]) {
149+
if let Some(k) = karg {
150+
self.add_cmdline(k);
147151
}
148152

149153
for item in extra {
@@ -776,7 +780,7 @@ mod tests {
776780
#[test]
777781
fn test_adjust_cmdline_with_composefs() {
778782
let mut entry = BootLoaderEntryFile::new("title Test Entry\nlinux /vmlinuz\n");
779-
entry.adjust_cmdline(Some("abc123"), false, &["quiet", "splash"]);
783+
entry.adjust_cmdline(Some("composefs=abc123"), &["quiet", "splash"]);
780784

781785
assert_eq!(entry.lines.len(), 3);
782786
assert_eq!(entry.lines[2], "options composefs=abc123 quiet splash");
@@ -785,17 +789,16 @@ mod tests {
785789
#[test]
786790
fn test_adjust_cmdline_with_composefs_insecure() {
787791
let mut entry = BootLoaderEntryFile::new("title Test Entry\nlinux /vmlinuz\n");
788-
entry.adjust_cmdline(Some("abc123"), true, &[]);
792+
entry.adjust_cmdline(Some("composefs=?abc123"), &[]);
789793

790794
assert_eq!(entry.lines.len(), 3);
791-
// Assuming make_cmdline_composefs adds digest=off for insecure mode
792-
assert!(entry.lines[2].contains("abc123"));
795+
assert_eq!(entry.lines[2], "options composefs=?abc123");
793796
}
794797

795798
#[test]
796799
fn test_adjust_cmdline_no_composefs() {
797800
let mut entry = BootLoaderEntryFile::new("title Test Entry\nlinux /vmlinuz\n");
798-
entry.adjust_cmdline(None, false, &["quiet", "splash"]);
801+
entry.adjust_cmdline(None, &["quiet", "splash"]);
799802

800803
assert_eq!(entry.lines.len(), 3);
801804
assert_eq!(entry.lines[2], "options quiet splash");
@@ -804,7 +807,7 @@ mod tests {
804807
#[test]
805808
fn test_adjust_cmdline_existing_options() {
806809
let mut entry = BootLoaderEntryFile::new("title Test Entry\noptions root=/dev/sda1\n");
807-
entry.adjust_cmdline(Some("abc123"), false, &["quiet"]);
810+
entry.adjust_cmdline(Some("composefs=abc123"), &["quiet"]);
808811

809812
assert_eq!(entry.lines.len(), 2);
810813
assert!(entry.lines[1].contains("root=/dev/sda1"));

0 commit comments

Comments
 (0)