File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,9 +87,12 @@ pub(crate) fn is_efi_booted() -> Result<bool> {
8787 . map_err ( Into :: into)
8888}
8989
90- #[ derive( Default ) ]
90+ #[ derive( Default , Debug ) ]
9191pub ( crate ) struct Efi {
9292 mountpoint : RefCell < Option < PathBuf > > ,
93+ /// Whether the above mountpoint was already mounted or not
94+ /// Won't unmount if it was already mounted
95+ was_mounted : RefCell < bool > ,
9396}
9497
9598impl Efi {
@@ -116,6 +119,7 @@ impl Efi {
116119 continue ;
117120 }
118121 util:: ensure_writable_mount ( & path) ?;
122+ * self . was_mounted . borrow_mut ( ) = true ;
119123 found_mount = Some ( path) ;
120124 break ;
121125 }
@@ -148,6 +152,7 @@ impl Efi {
148152 if is_mount_point ( & mnt) ? {
149153 log:: debug!( "ESP already mounted at {mnt:?}, reusing" ) ;
150154 mountpoint = Some ( mnt) ;
155+ * self . was_mounted . borrow_mut ( ) = true ;
151156 break ;
152157 }
153158 }
@@ -704,7 +709,12 @@ impl Component for Efi {
704709
705710impl Drop for Efi {
706711 fn drop ( & mut self ) {
707- log:: debug!( "Unmounting" ) ;
712+ if * self . was_mounted . borrow ( ) {
713+ log:: debug!( "mountpoint was already mounted. Won't unmount" , ) ;
714+ return ;
715+ }
716+
717+ log:: debug!( "Unmounting {:?}" , self . mountpoint) ;
708718 let _ = self . unmount ( ) ;
709719 }
710720}
You can’t perform that action at this time.
0 commit comments