userlibandfileserver/fileserver/sfile/sf_drv.cpp
changeset 199 189ece41fa29
parent 176 af6ec97d9189
child 244 a77889bee936
--- a/userlibandfileserver/fileserver/sfile/sf_drv.cpp	Thu Jul 01 17:57:33 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_drv.cpp	Fri Jul 09 13:13:20 2010 +0100
@@ -2173,8 +2173,9 @@
 
 
 /**
-Dismounts the current mount. This is method is called from outside, so do some finalisation work on mount.
+    Gracefully dismounts the current mount. This is method is called from outside, so do some finalisation work on mount.
 After calling this function there is no current mount on the drive.
+
 */
 EXPORT_C void TDrive::Dismount()
 	{
@@ -2184,10 +2185,12 @@
 	if (!iCurrentMount)
 		return;
 
+    //-- try to do the best flushing file caches
     TRAP_IGNORE(FlushCachedFileInfoL());
 
     //-- try our best to finalise the mount (the mount can decide to do some job during finalisation, e.g. write some data)
-    TRAP_IGNORE(iCurrentMount->FinaliseMountL());
+    //-- finalise the mount in RO mode, we are dismounting the FS anyway
+    TRAP_IGNORE(iCurrentMount->FinaliseMountL(RFs::EFinal_RO));
     
     DoDismount();
 	}
@@ -2196,8 +2199,7 @@
 
 
 /**
-Forcibly dismounts the current mount and prevents it being remounted.
-After calling this function there is no current mount on the drive.
+    Dismounts the current mount by force.
 */
 void TDrive::ForceDismount()
 	{
@@ -2209,7 +2211,15 @@
 		return;
   
 	TRAP_IGNORE(FlushCachedFileInfoL());
-	iCurrentMount->SetDismounted(); //! this affects TDrive::ReMount()
+
+    //-- try our best to finalise the mount (the mount can decide to do some job during finalisation, e.g. write some data)
+    //-- finalise the mount in RO mode, we are dismounting the FS anyway
+    TRAP_IGNORE(iCurrentMount->FinaliseMountL(RFs::EFinal_RO));
+
+    //-- mark the mount as 'Dismounted'; this invalidates all object handles until the mount is successfully "remounted". 
+    //-- if there are still some objects opened on this mount, CMountCB::Close() won't destroy it until all objects are closed.
+    iCurrentMount->SetDismounted(); 
+    
     DoDismount();
 	}