@@ -10,6 +10,7 @@ use std::path::{Path, PathBuf};
1010use std:: process:: Command ;
1111
1212use anyhow:: { bail, Context , Result } ;
13+ use bootc_utils:: CommandRunExt ;
1314use cap_std:: fs:: Dir ;
1415use cap_std_ext:: cap_std;
1516use fn_error_context:: context;
@@ -22,7 +23,7 @@ use widestring::U16CString;
2223use crate :: bootupd:: RootContext ;
2324use crate :: model:: * ;
2425use crate :: ostreeutil;
25- use crate :: util:: { self , CommandRunExt } ;
26+ use crate :: util;
2627use crate :: { blockdev, filetree} ;
2728use crate :: { component:: * , packagesystem} ;
2829
@@ -266,14 +267,18 @@ impl Component for Efi {
266267 for esp in esp_devices {
267268 let destpath = & self . ensure_mounted_esp ( rootcxt. path . as_ref ( ) , Path :: new ( & esp) ) ?;
268269
269- let esp = openat:: Dir :: open ( & destpath. join ( "EFI" ) ) . context ( "opening EFI dir" ) ?;
270- validate_esp_fstype ( & esp ) ?;
270+ let efidir = openat:: Dir :: open ( & destpath. join ( "EFI" ) ) . context ( "opening EFI dir" ) ?;
271+ validate_esp_fstype ( & efidir ) ?;
271272
272273 // For adoption, we should only touch files that we know about.
273- let diff = updatef. relative_diff_to ( & esp ) ?;
274+ let diff = updatef. relative_diff_to ( & efidir ) ?;
274275 log:: trace!( "applying adoption diff: {}" , & diff) ;
275- filetree:: apply_diff ( & updated, & esp , & diff, None )
276+ filetree:: apply_diff ( & updated, & efidir , & diff, None )
276277 . context ( "applying filesystem changes" ) ?;
278+
279+ // Do the sync before unmount
280+ efidir. syncfs ( ) ?;
281+ drop ( efidir) ;
277282 self . unmount ( ) . context ( "unmount after adopt" ) ?;
278283 }
279284 Ok ( Some ( InstalledContent {
@@ -356,6 +361,10 @@ impl Component for Efi {
356361 log:: trace!( "applying diff: {}" , & diff) ;
357362 filetree:: apply_diff ( & updated, & destdir, & diff, None )
358363 . context ( "applying filesystem changes" ) ?;
364+
365+ // Do the sync before unmount
366+ destdir. syncfs ( ) ?;
367+ drop ( destdir) ;
359368 self . unmount ( ) . context ( "unmount after update" ) ?;
360369 }
361370
@@ -422,7 +431,7 @@ impl Component for Efi {
422431 for esp in esp_devices. iter ( ) {
423432 let destpath = & self . ensure_mounted_esp ( Path :: new ( "/" ) , Path :: new ( & esp) ) ?;
424433
425- let efidir = & openat:: Dir :: open ( & destpath. join ( "EFI" ) )
434+ let efidir = openat:: Dir :: open ( & destpath. join ( "EFI" ) )
426435 . with_context ( || format ! ( "opening EFI dir {}" , destpath. display( ) ) ) ?;
427436 let diff = currentf. relative_diff_to ( & efidir) ?;
428437
@@ -433,6 +442,7 @@ impl Component for Efi {
433442 errs. push ( format ! ( "Removed: {}" , f) ) ;
434443 }
435444 assert_eq ! ( diff. additions. len( ) , 0 ) ;
445+ drop ( efidir) ;
436446 self . unmount ( ) . context ( "unmount after validate" ) ?;
437447 }
438448
0 commit comments