1- #![ allow( dead_code) ]
2-
31use std:: path:: Path ;
42
53use crate :: bootc_composefs:: boot:: { get_esp_partition, get_sysroot_parent_dev, BootType } ;
@@ -9,13 +7,12 @@ use crate::{
97 bootc_composefs:: status:: composefs_deployment_status, composefs_consts:: STATE_DIR_ABS ,
108} ;
119use anyhow:: { Context , Result } ;
12- use bootc_initramfs_setup:: { mount_at_wrapper , mount_composefs_image, open_dir} ;
10+ use bootc_initramfs_setup:: { mount_composefs_image, open_dir} ;
1311use bootc_mount:: tempmount:: TempMount ;
1412use cap_std_ext:: cap_std:: { ambient_authority, fs:: Dir } ;
1513use cap_std_ext:: dirext:: CapStdExtDirExt ;
1614use etc_merge:: { compute_diff, merge, traverse_etc} ;
1715use rustix:: fs:: { fsync, renameat, CWD } ;
18- use rustix:: mount:: { unmount, UnmountFlags } ;
1916use rustix:: path:: Arg ;
2017
2118use fn_error_context:: context;
@@ -38,11 +35,11 @@ pub(crate) async fn composefs_native_finalize() -> Result<()> {
3835 let sysroot = open_dir ( CWD , "/sysroot" ) ?;
3936 let composefs_fd = mount_composefs_image ( & sysroot, & booted_composefs. verity , false ) ?;
4037
41- let tempdir = tempfile:: tempdir ( ) . context ( "Creating tempdir" ) ?;
42- mount_at_wrapper ( composefs_fd, CWD , tempdir. path ( ) ) ?;
38+ let erofs_tmp_mnt = TempMount :: mount_fd ( & composefs_fd) ?;
4339
4440 // Perform the /etc merge
45- let pristine_etc = Dir :: open_ambient_dir ( tempdir. path ( ) , ambient_authority ( ) ) ?;
41+ let pristine_etc =
42+ Dir :: open_ambient_dir ( erofs_tmp_mnt. dir . path ( ) . join ( "etc" ) , ambient_authority ( ) ) ?;
4643 let current_etc = Dir :: open_ambient_dir ( "/etc" , ambient_authority ( ) ) ?;
4744
4845 let new_etc_path = Path :: new ( STATE_DIR_ABS )
@@ -57,7 +54,8 @@ pub(crate) async fn composefs_native_finalize() -> Result<()> {
5754 let diff = compute_diff ( & pristine_files, & current_files) ?;
5855 merge ( & current_etc, & current_files, & new_etc, & new_files, diff) ?;
5956
60- unmount ( tempdir. path ( ) , UnmountFlags :: DETACH ) . context ( "Unmounting tempdir" ) ?;
57+ // Unmount EROFS
58+ drop ( erofs_tmp_mnt) ;
6159
6260 let sysroot_parent = get_sysroot_parent_dev ( ) ?;
6361 // NOTE: Assumption here that ESP will always be present
0 commit comments