userlibandfileserver/fileserver/sfile/sf_drv.cpp
changeset 199 189ece41fa29
parent 176 af6ec97d9189
child 244 a77889bee936
equal deleted inserted replaced
189:a5496987b1da 199:189ece41fa29
  2171 
  2171 
  2172 
  2172 
  2173 
  2173 
  2174 
  2174 
  2175 /**
  2175 /**
  2176 Dismounts the current mount. This is method is called from outside, so do some finalisation work on mount.
  2176     Gracefully dismounts the current mount. This is method is called from outside, so do some finalisation work on mount.
  2177 After calling this function there is no current mount on the drive.
  2177 After calling this function there is no current mount on the drive.
       
  2178 
  2178 */
  2179 */
  2179 EXPORT_C void TDrive::Dismount()
  2180 EXPORT_C void TDrive::Dismount()
  2180 	{
  2181 	{
  2181 	__PRINT1(_L("TDrive::Dismount() iCurrentMount:0x%x"),iCurrentMount);
  2182 	__PRINT1(_L("TDrive::Dismount() iCurrentMount:0x%x"),iCurrentMount);
  2182 
  2183 
  2183 	iMountFailures = 0;
  2184 	iMountFailures = 0;
  2184 	if (!iCurrentMount)
  2185 	if (!iCurrentMount)
  2185 		return;
  2186 		return;
  2186 
  2187 
       
  2188     //-- try to do the best flushing file caches
  2187     TRAP_IGNORE(FlushCachedFileInfoL());
  2189     TRAP_IGNORE(FlushCachedFileInfoL());
  2188 
  2190 
  2189     //-- try our best to finalise the mount (the mount can decide to do some job during finalisation, e.g. write some data)
  2191     //-- try our best to finalise the mount (the mount can decide to do some job during finalisation, e.g. write some data)
  2190     TRAP_IGNORE(iCurrentMount->FinaliseMountL());
  2192     //-- finalise the mount in RO mode, we are dismounting the FS anyway
       
  2193     TRAP_IGNORE(iCurrentMount->FinaliseMountL(RFs::EFinal_RO));
  2191     
  2194     
  2192     DoDismount();
  2195     DoDismount();
  2193 	}
  2196 	}
  2194 
  2197 
  2195 
  2198 
  2196 
  2199 
  2197 
  2200 
  2198 /**
  2201 /**
  2199 Forcibly dismounts the current mount and prevents it being remounted.
  2202     Dismounts the current mount by force.
  2200 After calling this function there is no current mount on the drive.
       
  2201 */
  2203 */
  2202 void TDrive::ForceDismount()
  2204 void TDrive::ForceDismount()
  2203 	{
  2205 	{
  2204 	__PRINT1(_L("TDrive::ForceDismount() iCurrentMount:0x%x"),iCurrentMount);
  2206 	__PRINT1(_L("TDrive::ForceDismount() iCurrentMount:0x%x"),iCurrentMount);
  2205 
  2207 
  2207 
  2209 
  2208 	if(!iCurrentMount)
  2210 	if(!iCurrentMount)
  2209 		return;
  2211 		return;
  2210   
  2212   
  2211 	TRAP_IGNORE(FlushCachedFileInfoL());
  2213 	TRAP_IGNORE(FlushCachedFileInfoL());
  2212 	iCurrentMount->SetDismounted(); //! this affects TDrive::ReMount()
  2214 
       
  2215     //-- try our best to finalise the mount (the mount can decide to do some job during finalisation, e.g. write some data)
       
  2216     //-- finalise the mount in RO mode, we are dismounting the FS anyway
       
  2217     TRAP_IGNORE(iCurrentMount->FinaliseMountL(RFs::EFinal_RO));
       
  2218 
       
  2219     //-- mark the mount as 'Dismounted'; this invalidates all object handles until the mount is successfully "remounted". 
       
  2220     //-- if there are still some objects opened on this mount, CMountCB::Close() won't destroy it until all objects are closed.
       
  2221     iCurrentMount->SetDismounted(); 
       
  2222     
  2213     DoDismount();
  2223     DoDismount();
  2214 	}
  2224 	}
  2215 
  2225 
  2216 /** 
  2226 /** 
  2217     An internal method. Dismounts and closes a current mount. 
  2227     An internal method. Dismounts and closes a current mount.