userlibandfileserver/fileserver/sfile/sf_drv.cpp
changeset 291 206a6eaaeb71
parent 286 48e57fb1237e
child 297 b2826f67641f
equal deleted inserted replaced
289:55a0a1279a7e 291:206a6eaaeb71
  2199 
  2199 
  2200 
  2200 
  2201 
  2201 
  2202 /**
  2202 /**
  2203     Gracefully dismounts the current mount. This is method is called from outside, so do some finalisation work on mount.
  2203     Gracefully dismounts the current mount. This is method is called from outside, so do some finalisation work on mount.
  2204 After calling this function there is no current mount on the drive.
  2204     After calling this function there is no current mount on the drive.
  2205 
       
  2206 */
  2205 */
  2207 EXPORT_C void TDrive::Dismount()
  2206 EXPORT_C void TDrive::Dismount()
  2208 	{
  2207 	{
  2209 	__PRINT1(_L("TDrive::Dismount() iCurrentMount:0x%x"),iCurrentMount);
  2208 	__PRINT1(_L("TDrive::Dismount() iCurrentMount:0x%x"),iCurrentMount);
  2210 
  2209 
  2214 
  2213 
  2215     //-- try to do the best flushing file caches
  2214     //-- try to do the best flushing file caches
  2216     TRAP_IGNORE(FlushCachedFileInfoL());
  2215     TRAP_IGNORE(FlushCachedFileInfoL());
  2217 
  2216 
  2218     //-- try our best to finalise the mount (the mount can decide to do some job during finalisation, e.g. write some data)
  2217     //-- try our best to finalise the mount (the mount can decide to do some job during finalisation, e.g. write some data)
  2219     //-- finalise the mount in RO mode, we are dismounting the FS anyway
  2218     //-- finalise the mount in RW mode
  2220     TRAP_IGNORE(iCurrentMount->FinaliseMountL(RFs::EFinal_RO));
  2219     TRAP_IGNORE(iCurrentMount->FinaliseMountL(RFs::EFinal_RW));
  2221     
  2220     
  2222     DoDismount();
  2221     DoDismount();
  2223 	}
  2222 	}
  2224 
  2223 
  2225 
  2224 
  2238 		return;
  2237 		return;
  2239   
  2238   
  2240 	TRAP_IGNORE(FlushCachedFileInfoL());
  2239 	TRAP_IGNORE(FlushCachedFileInfoL());
  2241 
  2240 
  2242     //-- try our best to finalise the mount (the mount can decide to do some job during finalisation, e.g. write some data)
  2241     //-- try our best to finalise the mount (the mount can decide to do some job during finalisation, e.g. write some data)
  2243     //-- finalise the mount in RO mode, we are dismounting the FS anyway
  2242     //-- finalise the mount in RW mode. It is possible that the mount is being forcedly dismounted with some files opened on it.
  2244     TRAP_IGNORE(iCurrentMount->FinaliseMountL(RFs::EFinal_RO));
  2243     //-- in this case further attempt to access may will result in successful remountng and re-attaching mount and its files to the media.
       
  2244     TRAP_IGNORE(iCurrentMount->FinaliseMountL(RFs::EFinal_RW));
  2245 
  2245 
  2246     //-- mark the mount as 'Dismounted'; this invalidates all object handles until the mount is successfully "remounted". 
  2246     //-- mark the mount as 'Dismounted'; this invalidates all object handles until the mount is successfully "remounted". 
  2247     //-- if there are still some objects opened on this mount, CMountCB::Close() won't destroy it until all objects are closed.
  2247     //-- if there are still some objects opened on this mount, CMountCB::Close() won't destroy it until all objects are closed.
  2248     iCurrentMount->SetDismounted(); 
  2248     iCurrentMount->SetDismounted(); 
  2249     
  2249     
  2539 
  2539 
  2540 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  2540 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  2541 TInt TDrive::ClearDeferredDismount()
  2541 TInt TDrive::ClearDeferredDismount()
  2542 // debug-only function for testing
  2542 // debug-only function for testing
  2543 	{
  2543 	{
  2544 	Lock();
       
  2545 	FsNotify::HandleDismount(EFsDismountRegisterClient, DriveNumber(), ETrue, KErrNone);
  2544 	FsNotify::HandleDismount(EFsDismountRegisterClient, DriveNumber(), ETrue, KErrNone);
  2546 	SetDismountDeferred(EFalse);
  2545 	SetDismountDeferred(EFalse);
  2547 	UnLock();
       
  2548 	return KErrNone;
  2546 	return KErrNone;
  2549 	}
  2547 	}
  2550 #endif
  2548 #endif
  2551 	
  2549 	
  2552 
  2550