@@ -128,7 +128,7 @@ impl Efi {
128128 } else {
129129 self . mount_esp_device ( root, esp_device) ?
130130 } ;
131- Ok ( destdir)
131+ Ok ( destdir. join ( "EFI" ) )
132132 }
133133
134134 fn unmount ( & self ) -> Result < ( ) > {
@@ -280,7 +280,7 @@ impl Component for Efi {
280280 }
281281 let destpath = & self . ensure_mounted_esp ( sysroot. path . as_ref ( ) , Path :: new ( & esp) ) ?;
282282
283- let destdir = & openat:: Dir :: open ( & destpath. join ( "EFI" ) )
283+ let destdir = & openat:: Dir :: open ( destpath)
284284 . with_context ( || format ! ( "opening EFI dir {}" , destpath. display( ) ) ) ?;
285285 validate_esp ( & destdir) ?;
286286 let updated = sysroot
@@ -313,13 +313,19 @@ impl Component for Efi {
313313 log:: debug!( "Found metadata {}" , meta. version) ;
314314 let srcdir_name = component_updatedirname ( self ) ;
315315 let ft = crate :: filetree:: FileTree :: new_from_dir ( & src_root. sub_dir ( & srcdir_name) ?) ?;
316- // get esp device via /dev/disk/by-partlabel
317- let esp_device = self
318- . get_esp_device ( )
319- . ok_or_else ( || anyhow:: anyhow!( "Failed to find ESP device" ) ) ?;
320- let destpath = & self . ensure_mounted_esp ( Path :: new ( dest_root) , & esp_device) ?;
321316
322- let destd = & openat:: Dir :: open ( destpath)
317+ // Reusing mounted esp
318+ let destpath = if let Some ( destdir) = self . get_mounted_esp ( Path :: new ( dest_root) ) ? {
319+ destdir
320+ } else {
321+ // get esp device via /dev/disk/by-partlabel
322+ let esp_device = self
323+ . get_esp_device ( )
324+ . ok_or_else ( || anyhow:: anyhow!( "Failed to find ESP device" ) ) ?;
325+ self . mount_esp_device ( Path :: new ( dest_root) , & esp_device) ?
326+ } ;
327+
328+ let destd = & openat:: Dir :: open ( & destpath)
323329 . with_context ( || format ! ( "opening dest dir {}" , destpath. display( ) ) ) ?;
324330 validate_esp ( destd) ?;
325331
@@ -375,7 +381,7 @@ impl Component for Efi {
375381 }
376382 let destpath = & self . ensure_mounted_esp ( sysroot. path . as_ref ( ) , Path :: new ( & esp) ) ?;
377383
378- let destdir = & openat:: Dir :: open ( & destpath. join ( "EFI" ) )
384+ let destdir = & openat:: Dir :: open ( destpath)
379385 . with_context ( || format ! ( "opening EFI dir {}" , destpath. display( ) ) ) ?;
380386 validate_esp ( & destdir) ?;
381387 log:: trace!( "applying diff: {}" , & diff) ;
@@ -453,7 +459,7 @@ impl Component for Efi {
453459 }
454460 let destpath = & self . ensure_mounted_esp ( Path :: new ( "/" ) , Path :: new ( & esp) ) ?;
455461
456- let efidir = & openat:: Dir :: open ( & destpath. join ( "EFI" ) )
462+ let efidir = & openat:: Dir :: open ( destpath)
457463 . with_context ( || format ! ( "opening EFI dir {}" , destpath. display( ) ) ) ?;
458464
459465 let diff = currentf. relative_diff_to ( & efidir) ?;
0 commit comments