128 __PRINT1(_L("TDrive::CreateL(%d)"),aDriveNumber); |
128 __PRINT1(_L("TDrive::CreateL(%d)"),aDriveNumber); |
129 iDriveNumber=aDriveNumber; |
129 iDriveNumber=aDriveNumber; |
130 iMount=TheContainer->CreateL(); |
130 iMount=TheContainer->CreateL(); |
131 TInt r=iLock.CreateLocal(); |
131 TInt r=iLock.CreateLocal(); |
132 User::LeaveIfError(r); |
132 User::LeaveIfError(r); |
|
133 |
|
134 iDeferredDismountRequest = new(ELeave) CFsInternalRequest; |
|
135 iDeferredDismountRequest->Set(DeferredDismountOp,NULL); |
|
136 iDeferredDismountRequest->SetDriveNumber(aDriveNumber); |
133 } |
137 } |
134 |
138 |
135 TInt TDrive::CheckMountAndEntryName(const TDesC& aName) |
139 TInt TDrive::CheckMountAndEntryName(const TDesC& aName) |
136 // |
140 // |
137 // Check drive is mounted then check aName is legal |
141 // Check drive is mounted then check aName is legal |
2343 */ |
2347 */ |
2344 TBool TDrive::DismountLocked() const |
2348 TBool TDrive::DismountLocked() const |
2345 { return(iDismountLock); } |
2349 { return(iDismountLock); } |
2346 |
2350 |
2347 |
2351 |
2348 |
2352 /** |
2349 |
2353 DismountClientAdded() - |
2350 /** |
2354 |
2351 Pending flag - set while waiting for clients to accept the dismount |
2355 Increments the count of clients which need to respond to a dismount request - by calling RFs::AllowDismount() - |
|
2356 before the dismount can process |
|
2357 |
|
2358 Called when a EFsDismountRegisterClient request is completed by RFs::NotifyDismount(,,EFsDismountNotifyClients) |
|
2359 */ |
|
2360 void TDrive::DismountClientAdded() |
|
2361 { |
|
2362 __e32_atomic_add_ord32(&iDismountClientCount, (TUint32) 1); |
|
2363 } |
|
2364 |
|
2365 /** |
|
2366 DismountClientRemoved() - |
|
2367 Called when a EFsDismountRegisterClient request is deleted. E.g. by RFs::AllowDismount() |
|
2368 */ |
|
2369 void TDrive::DismountClientRemoved() |
|
2370 { |
|
2371 ASSERT(iDismountClientCount > 0); |
|
2372 if ((__e32_atomic_add_ord32(&iDismountClientCount, (TUint32) -1) == 1) && |
|
2373 (!FsThreadManager::IsDriveThread(iDriveNumber,EFalse)) && |
|
2374 DismountDeferred()) |
|
2375 { |
|
2376 iDeferredDismountRequest->Dispatch(); |
|
2377 } |
|
2378 } |
|
2379 |
|
2380 TInt TDrive::DismountClientCount() |
|
2381 { |
|
2382 return iDismountClientCount; |
|
2383 } |
|
2384 |
|
2385 |
|
2386 /* |
|
2387 Dismount the file system if a deferred dismount has been schedulued and there are no waiting clients and no clamps |
|
2388 */ |
|
2389 TInt TDrive::DeferredDismountCheck() |
|
2390 { |
|
2391 // Don't dismount if no deferred dismount is scheduled |
|
2392 if (!DismountDeferred()) |
|
2393 return KErrNone; |
|
2394 |
|
2395 // Don't dismount if clients are waiting |
|
2396 if (DismountClientCount() > 0) |
|
2397 return KErrNone; |
|
2398 |
|
2399 // Don't dismount if files are clamped |
|
2400 TInt clampErr = ClampsOnDrive(); |
|
2401 if (clampErr != 0 && clampErr != KErrNotSupported) |
|
2402 return KErrNone; |
|
2403 |
|
2404 // Nothing to wait for, so dismount immediately |
|
2405 __ASSERT_DEBUG(GetFSys(), Fault(EAllowDismount)); |
|
2406 return DeferredDismount(); |
|
2407 } |
|
2408 |
|
2409 |
|
2410 /** |
|
2411 Dismount deferred flag - set while waiting for clients to accept the dismount or files to become unclamped |
2352 */ |
2412 */ |
2353 void TDrive::SetDismountDeferred(TBool aPending) |
2413 void TDrive::SetDismountDeferred(TBool aPending) |
2354 { |
2414 { |
2355 if(aPending) |
2415 if(aPending) |
2356 iDriveFlags |= EDismountDeferred; |
2416 iDriveFlags |= EDismountDeferred; |
2527 return KErrNone; |
2587 return KErrNone; |
2528 } |
2588 } |
2529 |
2589 |
2530 //---------------------------------------------------------------------------- |
2590 //---------------------------------------------------------------------------- |
2531 /** |
2591 /** |
2532 Complete, remove and delete notification requests |
2592 a helper method that allows forced unmounting current mount for volume formatting. |
2533 @param aCompletionCode completion code for some notifications |
|
2534 */ |
|
2535 void TDrive::DoCompleteDismountNotify(TInt aCompletionCode) |
|
2536 { |
|
2537 FsNotify::HandleDismount(EFsDismountRegisterClient, iDriveNumber, ETrue, KErrNone); |
|
2538 FsNotify::HandleDismount(EFsDismountNotifyClients, iDriveNumber, ETrue, aCompletionCode); |
|
2539 FsNotify::HandleDismount(EFsDismountForceDismount, iDriveNumber, ETrue, aCompletionCode); |
|
2540 } |
|
2541 |
|
2542 //---------------------------------------------------------------------------- |
|
2543 /** |
|
2544 a helper method that allows forced dismounting current mount for volume formatting. |
|
2545 */ |
2593 */ |
2546 TInt TDrive::ForceUnmountFileSystemForFormatting() |
2594 TInt TDrive::ForceUnmountFileSystemForFormatting() |
2547 { |
2595 { |
2548 TInt nRes; |
2596 TInt nRes; |
2549 |
2597 |