Skip to content

Conversation

@Johan-Liebert1
Copy link
Collaborator

For bind mounting /etc we copy the contents of the EROFS' /etc to the deployment's state directory

Mounting the EORFS requires help from the initramfs crate, so we also turn it into a library crate.

@bootc-bot bootc-bot bot requested a review from cgwalters August 29, 2025 09:27
@Johan-Liebert1
Copy link
Collaborator Author

I've started out by separating new composefs-backend related code to lib/src/bootc-composefs. @cgwalters we could go ahead with this approach or something else if you have something cleaner in mind.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the initramfs crate into a library and introduces functionality to copy /etc contents for composefs installations. The changes are logical and follow the PR's description. I've identified a couple of areas for improvement in the new copy_etc_to_state function concerning resource management and error handling, and a minor code style issue.

use camino::Utf8PathBuf;
use fn_error_context::context;

use bootc_initramfs_setup;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This use statement is redundant because crate names are already in scope in Rust 2018 and later editions. You can safely remove this line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Johan-Liebert1 Johan-Liebert1 force-pushed the bind-mnt-etc branch 2 times, most recently from 99c2823 to c5c3751 Compare August 29, 2025 09:52
@Johan-Liebert1 Johan-Liebert1 marked this pull request as draft August 29, 2025 10:11
This was referenced Aug 29, 2025
Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK, can you just fix to use tempdir, the other bits can be followups

Comment on lines 51 to 57
if !output.status.success() {
anyhow::bail!(
"Copying /etc failed with status {}: {}",
output.status,
String::from_utf8_lossy(&output.stderr)
);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a handy

fn run_capture_stderr(&mut self) -> Result<()>;
that does all this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I'll use that

Comment on lines 31 to 34
let uuid = uuid::Uuid::new_v4();
let dir = format!("/var/tmp/{uuid}");

create_dir_all(&dir).context("Creating temp directory")?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confused why we wouldn't just use tempdir::tempdir


create_dir_all(&dir).context("Creating temp directory")?;

bootc_initramfs_setup::mount_at_wrapper(composefs_fd, CWD, &dir)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, we have mount helper code in lib/...and in composefs-boot, probably again need to factor out a helper crate


bootc_initramfs_setup::mount_at_wrapper(composefs_fd, CWD, &dir)?;

let output = Command::new("cp")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm totally fine with this, but at some point I'd like to add a high level copy_recursive to e.g. cap-std-ext

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that would be ideal

])
.output()?;

// Unmount regardless of copy succeeding
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think what we want is a wrapper for tempdir that handles unmount-on-drop

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Composefs has a struct for exactly this, but again is only visible at crate level. We could make that public. https://github.com/containers/composefs-rs/blob/main/crates/composefs/src/mountcompat.rs#L129

The composefs-rs crate has a lot of helper functions which are private

@Johan-Liebert1 Johan-Liebert1 marked this pull request as ready for review August 29, 2025 11:54
For bind mounting /etc we copy the contents of the EROFS' /etc to the
deployment's state directory

Mounting the EORFS requires help from the initramfs crate, so we also
turn it into a library crate.

Signed-off-by: Johan-Liebert1 <[email protected]>
@cgwalters cgwalters merged commit fd703ec into bootc-dev:composefs-backend Aug 29, 2025
20 checks passed
@cgwalters cgwalters added the area/composefs Issues related to composefs label Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/composefs Issues related to composefs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants