equal
deleted
inserted
replaced
400 |
400 |
401 /** |
401 /** |
402 Notify the media drive about media areas that shall be treated as "deleted" if this feature is supported. |
402 Notify the media drive about media areas that shall be treated as "deleted" if this feature is supported. |
403 @param aFreedClusters array with FAT numbers of clusters that shall be marked as "deleted" |
403 @param aFreedClusters array with FAT numbers of clusters that shall be marked as "deleted" |
404 */ |
404 */ |
405 void CFatTable::DoFreedClustersNotify(RClusterArray &aFreedClusters) |
405 void CFatTable::DoFreedClustersNotifyL(RClusterArray &aFreedClusters) |
406 { |
406 { |
407 ASSERT(iMediaAtt & KMediaAttDeleteNotify); |
407 ASSERT(iMediaAtt & KMediaAttDeleteNotify); |
408 |
408 |
409 const TUint clusterCount = aFreedClusters.Count(); |
409 const TUint clusterCount = aFreedClusters.Count(); |
410 |
410 |
421 for (TUint i=0; i<clusterCount; ++i) |
421 for (TUint i=0; i<clusterCount; ++i) |
422 { |
422 { |
423 const TUint currCluster = aFreedClusters[i]; |
423 const TUint currCluster = aFreedClusters[i]; |
424 |
424 |
425 if (deleteLen == 0) |
425 if (deleteLen == 0) |
426 byteAddress = DataPositionInBytes(currCluster); //-- start of the media range |
426 byteAddress = DataPositionInBytesL(currCluster); //-- start of the media range |
427 |
427 |
428 deleteLen += bytesPerCluster; |
428 deleteLen += bytesPerCluster; |
429 |
429 |
430 //-- if this is the last entry in the array or the net cluster number is not consecutive, notify the driver |
430 //-- if this is the last entry in the array or the net cluster number is not consecutive, notify the driver |
431 if ((i+1) == clusterCount || aFreedClusters[i+1] != (currCluster+1)) |
431 if ((i+1) == clusterCount || aFreedClusters[i+1] != (currCluster+1)) |
436 const TInt r = iOwner->LocalDrive()->DeleteNotify(byteAddress, deleteLen); |
436 const TInt r = iOwner->LocalDrive()->DeleteNotify(byteAddress, deleteLen); |
437 if(r != KErrNone) |
437 if(r != KErrNone) |
438 {//-- if DeleteNotify() failed, it means that something terribly wrong happened to the NAND media; |
438 {//-- if DeleteNotify() failed, it means that something terribly wrong happened to the NAND media; |
439 //-- in normal circumstances it can not happen. One of the reasons: totally worn out media. |
439 //-- in normal circumstances it can not happen. One of the reasons: totally worn out media. |
440 const TBool platSecEnabled = PlatSec::ConfigSetting(PlatSec::EPlatSecEnforcement); |
440 const TBool platSecEnabled = PlatSec::ConfigSetting(PlatSec::EPlatSecEnforcement); |
441 __PRINT3(_L("CFatTable::DoFreedClustersNotify() DeleteNotify failure! drv:%d err:%d, PlatSec:%d"),iOwner->DriveNumber(), r, platSecEnabled); |
441 __PRINT3(_L("CFatTable::DoFreedClustersNotifyL() DeleteNotify failure! drv:%d err:%d, PlatSec:%d"),iOwner->DriveNumber(), r, platSecEnabled); |
442 |
442 |
443 if(platSecEnabled) |
443 if(platSecEnabled) |
444 { |
444 { |
445 //-- if PlatSec is enabled, we can't afford jeopardize the security; without DeleteNotify() |
445 //-- if PlatSec is enabled, we can't afford jeopardize the security; without DeleteNotify() |
446 //-- it's possible to pick up data from deleted files, so, panic the file server. |
446 //-- it's possible to pick up data from deleted files, so, panic the file server. |
519 {//-- reached a limit of the entries in the array. Flush FAT cache, notify the driver and empty the array. |
519 {//-- reached a limit of the entries in the array. Flush FAT cache, notify the driver and empty the array. |
520 IncrementFreeClusterCount(cntFreedClusters); |
520 IncrementFreeClusterCount(cntFreedClusters); |
521 cntFreedClusters = 0; |
521 cntFreedClusters = 0; |
522 |
522 |
523 SetFreeClusterHint(lastKnownFreeCluster); |
523 SetFreeClusterHint(lastKnownFreeCluster); |
524 DoFreedClustersNotify(deletedClusters); |
524 DoFreedClustersNotifyL(deletedClusters); |
525 } |
525 } |
526 |
526 |
527 } |
527 } |
528 |
528 |
529 //-- increase the number of free clusters and notify the driver if required. |
529 //-- increase the number of free clusters and notify the driver if required. |
530 IncrementFreeClusterCount(cntFreedClusters); |
530 IncrementFreeClusterCount(cntFreedClusters); |
531 SetFreeClusterHint(lastKnownFreeCluster); |
531 SetFreeClusterHint(lastKnownFreeCluster); |
532 |
532 |
533 if(bFreeClustersNotify) |
533 if(bFreeClustersNotify) |
534 DoFreedClustersNotify(deletedClusters); |
534 DoFreedClustersNotifyL(deletedClusters); |
535 |
535 |
536 CleanupStack::PopAndDestroy(&deletedClusters); |
536 CleanupStack::PopAndDestroy(&deletedClusters); |
537 } |
537 } |
538 |
538 |
539 //----------------------------------------------------------------------------- |
539 //----------------------------------------------------------------------------- |
669 //__PRINT1(_L("#- CFatTable::RequestFreeClusters(%d)"),aClustersRequired); |
669 //__PRINT1(_L("#- CFatTable::RequestFreeClusters(%d)"),aClustersRequired); |
670 ASSERT(aClustersRequired >0); |
670 ASSERT(aClustersRequired >0); |
671 return (NumberOfFreeClusters() >= aClustersRequired); |
671 return (NumberOfFreeClusters() >= aClustersRequired); |
672 } |
672 } |
673 |
673 |
674 //----------------------------------------------------------------------------- |
|
675 /** |
|
676 @return ETrue if the cluster number aClusterNo is valid, i.e. belongs to the FAT table |
|
677 */ |
|
678 TBool CFatTable::ClusterNumberValid(TUint32 aClusterNo) const |
|
679 { |
|
680 return (aClusterNo >= KFatFirstSearchCluster) && (aClusterNo < iMaxEntries); |
|
681 } |
|
682 |
674 |
683 |
675 |
684 |
676 |
685 //####################################################################################################################################### |
677 //####################################################################################################################################### |
686 //# CAtaFatTable class implementation |
678 //# CAtaFatTable class implementation |
1794 FlushL(); |
1786 FlushL(); |
1795 } |
1787 } |
1796 |
1788 |
1797 |
1789 |
1798 /** |
1790 /** |
1799 Return the location of a Cluster in the data section of the media |
1791 Return media position in bytes of the cluster start |
1800 |
1792 |
1801 @param aCluster to find location of |
1793 @param aCluster to find location of |
1802 @return Byte offset of the cluster data |
1794 @return Byte offset of the cluster data |
1803 */ |
1795 */ |
1804 TInt64 CAtaFatTable::DataPositionInBytes(TUint32 aCluster) const |
1796 TInt64 CAtaFatTable::DataPositionInBytesL(TUint32 aCluster) const |
1805 { |
1797 { |
1806 |
1798 if(!ClusterNumberValid(aCluster)) |
1807 __ASSERT_DEBUG(ClusterNumberValid(aCluster), Fault(EFatTable_InvalidIndex)); |
1799 { |
1808 |
1800 __ASSERT_DEBUG(0, Fault(EFatTable_InvalidIndex)); |
1809 const TInt clusterBasePosition=iOwner->ClusterBasePosition(); |
1801 User::Leave(KErrCorrupt); |
|
1802 } |
|
1803 |
|
1804 const TUint32 clusterBasePosition=iOwner->ClusterBasePosition(); |
1810 return(((TInt64(aCluster)-KFatFirstSearchCluster) << iOwner->ClusterSizeLog2()) + clusterBasePosition); |
1805 return(((TInt64(aCluster)-KFatFirstSearchCluster) << iOwner->ClusterSizeLog2()) + clusterBasePosition); |
1811 } |
1806 } |
1812 |
1807 |
1813 |
1808 |
1814 |
1809 |
2551 |
2546 |
2552 |
2547 |
2553 //-- allow this thread to be preempted by another one that wants to access the media driver. |
2548 //-- allow this thread to be preempted by another one that wants to access the media driver. |
2554 //-- without this wait we will have priority inversion, because this (low priority) thread continiously reads data by big chunks |
2549 //-- without this wait we will have priority inversion, because this (low priority) thread continiously reads data by big chunks |
2555 //-- and doesn't allow others to access the driver. |
2550 //-- and doesn't allow others to access the driver. |
2556 //-- On the other hand, if the thread's priority is boosted, there is no reason to be polite. |
2551 //-- On the other hand, if the thread's priority is boosted, there is no reason to be so polite. |
2557 if(!pSelf->IsPriorityBoosted()) |
2552 if(!pSelf->IsPriorityBoosted()) |
2558 User::After(K1mSec); //-- User::After() granularity can be much coarser than 1ms |
2553 {//-- User::After() granularity can be much coarser than 1ms, e.g. 1/64 Sec. This will add up to the scanning time |
|
2554 User::After(K1mSec); |
|
2555 } |
|
2556 else |
|
2557 {//-- use much less coarse granularity to allow this thread to be preempted even if its priority is boosted. |
|
2558 User::AfterHighRes(128); |
|
2559 } |
2559 |
2560 |
2560 //------------------------------------------- |
2561 //------------------------------------------- |
2561 mediaPos += bytesToRead; |
2562 mediaPos += bytesToRead; |
2562 rem -= bytesToRead; |
2563 rem -= bytesToRead; |
2563 |
2564 |