Skip to content

Composefs finalize#1604

Merged
cgwalters merged 4 commits into
bootc-dev:composefs-backendfrom
Johan-Liebert1:composefs-finalize
Sep 11, 2025
Merged

Composefs finalize#1604
cgwalters merged 4 commits into
bootc-dev:composefs-backendfrom
Johan-Liebert1:composefs-finalize

Conversation

@Johan-Liebert1

@Johan-Liebert1 Johan-Liebert1 commented Sep 10, 2025

Copy link
Copy Markdown
Collaborator

Introduce finalize-staged service

The service is intended to perform the following task at shutdown if a
staged deployment is present

  • Perform three way /etc merge for the staged deployment
  • Un-stage boot entries depending upon bootloader and boot entry type

Some assumptions made

  • ESP will always be present
  • We won't have two bootloaders at the same time

Using cap_std's symlink results in an error if the symlink target is
absolute

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Add a TempMount struct which mounts a device/partition on a tempdir and
automatically unmount on drop

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>

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

Copy link
Copy Markdown
Contributor

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 introduces a finalize-staged service for composefs, which handles the three-way /etc merge and unstages boot entries at shutdown. The changes include refactoring boot logic to reduce duplication, adding a new TempMount utility for safer mount handling, and implementing the core finalization logic. My review has identified a couple of critical issues in the new finalization logic related to redundant mount operations and incorrect path handling for the /etc merge. Additionally, there are high-severity concerns about potential resource leaks in the new TempMount utility. Addressing these points will improve the correctness and robustness of the new functionality.

Comment thread crates/lib/src/bootc_composefs/finalize.rs Outdated
Comment thread crates/lib/src/bootc_composefs/finalize.rs Outdated
Comment thread crates/mount/src/tempmount.rs Outdated
Comment thread crates/mount/src/tempmount.rs Outdated
The service is intended to perform the following task at shutdown if a
staged deployment is present

- Perform three way /etc merge for the staged deployment
- Un-stage boot entries depending upon bootloader and boot entry type

Some assumptions made

- ESP will always be present
- We won't have two bootloaders at the same time

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Allow mounting of any fds acquired using open_tree like syscalls

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
@Johan-Liebert1

Johan-Liebert1 commented Sep 11, 2025

Copy link
Copy Markdown
Collaborator Author

I had

Assuming we won't use systemd-boot for BIOS...

as a comment, which is plain wrong as we can't anyway

let dir_path = PathBuf::from(format!(
"/sysroot/boot/loader/{ROLLBACK_BOOT_LOADER_ENTRIES}",
));
let dir_path = PathBuf::from(format!("/sysroot/boot/loader/{STAGED_BOOT_LOADER_ENTRIES}",));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not new but we should centralize boot/loader path handling at some point

}

pub fn get_sysroot_parent_dev() -> Result<String> {
let sysroot = Utf8PathBuf::from("/sysroot");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This relates to #1190 (comment) in that what I think would help us overall is to pass around a Storage instance that has a canonical opened fd for the sysroot instead of having a lot of places that load it ambiently.

The biggest reason to do this is that it will work the same way at install time, where we're actually operating on a different mount point and not /sysroot.

@cgwalters cgwalters merged commit 4f49e6a into bootc-dev:composefs-backend Sep 11, 2025
2 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants