@@ -79,11 +79,20 @@ impl Efi {
7979 // Get mounted point for esp
8080 pub ( crate ) fn get_mounted_esp ( & self , root : & Path ) -> Result < Option < PathBuf > > {
8181 // First check all potential mount points without holding the borrow
82- let found_mount = ESP_MOUNTS . iter ( ) . map ( |& mnt| root. join ( mnt) ) . find ( |mnt| {
83- mnt. exists ( )
84- && rustix:: fs:: statfs ( mnt) . map_or ( false , |st| st. f_type == libc:: MSDOS_SUPER_MAGIC )
85- && util:: ensure_writable_mount ( mnt) . is_ok ( )
86- } ) ;
82+ let mut found_mount = None ;
83+ for & mnt in ESP_MOUNTS . iter ( ) {
84+ let path = root. join ( mnt) ;
85+ if !path. exists ( ) {
86+ continue ;
87+ }
88+
89+ let st = rustix:: fs:: statfs ( & path) ?;
90+ if st. f_type == libc:: MSDOS_SUPER_MAGIC {
91+ util:: ensure_writable_mount ( & path) ?;
92+ found_mount = Some ( path) ;
93+ break ;
94+ }
95+ }
8796
8897 // Only borrow mutably if we found a mount point
8998 if let Some ( mnt) = found_mount {
@@ -266,8 +275,7 @@ impl Component for Efi {
266275 anyhow:: bail!( "Failed to find adoptable system" )
267276 } ;
268277
269- // Confirm that esp_devices is Some(value)
270- let esp_devices = esp_devices. unwrap ( ) ;
278+ let esp_devices = esp_devices. unwrap_or_default ( ) ;
271279 let mut devices = esp_devices. iter ( ) ;
272280 let Some ( esp) = devices. next ( ) else {
273281 anyhow:: bail!( "Failed to find esp device" ) ;
@@ -445,8 +453,7 @@ impl Component for Efi {
445453 . as_ref ( )
446454 . ok_or_else ( || anyhow:: anyhow!( "No filetree for installed EFI found!" ) ) ?;
447455
448- // Confirm that esp_devices is Some(value)
449- let esp_devices = esp_devices. unwrap ( ) ;
456+ let esp_devices = esp_devices. unwrap_or_default ( ) ;
450457 let mut devices = esp_devices. iter ( ) ;
451458 let Some ( esp) = devices. next ( ) else {
452459 anyhow:: bail!( "Failed to find esp device" ) ;
0 commit comments