1
- #![ allow( dead_code) ]
2
-
3
1
use std:: path:: Path ;
4
2
5
3
use crate :: bootc_composefs:: boot:: { get_esp_partition, get_sysroot_parent_dev, BootType } ;
@@ -9,13 +7,12 @@ use crate::{
9
7
bootc_composefs:: status:: composefs_deployment_status, composefs_consts:: STATE_DIR_ABS ,
10
8
} ;
11
9
use 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} ;
13
11
use bootc_mount:: tempmount:: TempMount ;
14
12
use cap_std_ext:: cap_std:: { ambient_authority, fs:: Dir } ;
15
13
use cap_std_ext:: dirext:: CapStdExtDirExt ;
16
14
use etc_merge:: { compute_diff, merge, traverse_etc} ;
17
15
use rustix:: fs:: { fsync, renameat, CWD } ;
18
- use rustix:: mount:: { unmount, UnmountFlags } ;
19
16
use rustix:: path:: Arg ;
20
17
21
18
use fn_error_context:: context;
@@ -38,11 +35,11 @@ pub(crate) async fn composefs_native_finalize() -> Result<()> {
38
35
let sysroot = open_dir ( CWD , "/sysroot" ) ?;
39
36
let composefs_fd = mount_composefs_image ( & sysroot, & booted_composefs. verity , false ) ?;
40
37
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) ?;
43
39
44
40
// 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 ( ) ) ?;
46
43
let current_etc = Dir :: open_ambient_dir ( "/etc" , ambient_authority ( ) ) ?;
47
44
48
45
let new_etc_path = Path :: new ( STATE_DIR_ABS )
@@ -57,7 +54,8 @@ pub(crate) async fn composefs_native_finalize() -> Result<()> {
57
54
let diff = compute_diff ( & pristine_files, & current_files) ?;
58
55
merge ( & current_etc, & current_files, & new_etc, & new_files, diff) ?;
59
56
60
- unmount ( tempdir. path ( ) , UnmountFlags :: DETACH ) . context ( "Unmounting tempdir" ) ?;
57
+ // Unmount EROFS
58
+ drop ( erofs_tmp_mnt) ;
61
59
62
60
let sysroot_parent = get_sysroot_parent_dev ( ) ?;
63
61
// NOTE: Assumption here that ESP will always be present
0 commit comments