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 |
1787 FlushL(); |
1779 FlushL(); |
1788 } |
1780 } |
1789 |
1781 |
1790 |
1782 |
1791 /** |
1783 /** |
1792 Return the location of a Cluster in the data section of the media |
1784 Return media position in bytes of the cluster start |
1793 |
1785 |
1794 @param aCluster to find location of |
1786 @param aCluster to find location of |
1795 @return Byte offset of the cluster data |
1787 @return Byte offset of the cluster data |
1796 */ |
1788 */ |
1797 TInt64 CAtaFatTable::DataPositionInBytes(TUint32 aCluster) const |
1789 TInt64 CAtaFatTable::DataPositionInBytesL(TUint32 aCluster) const |
1798 { |
1790 { |
1799 |
1791 if(!ClusterNumberValid(aCluster)) |
1800 __ASSERT_DEBUG(ClusterNumberValid(aCluster), Fault(EFatTable_InvalidIndex)); |
1792 { |
1801 |
1793 __ASSERT_DEBUG(0, Fault(EFatTable_InvalidIndex)); |
1802 const TInt clusterBasePosition=iOwner->ClusterBasePosition(); |
1794 User::Leave(KErrCorrupt); |
|
1795 } |
|
1796 |
|
1797 const TUint32 clusterBasePosition=iOwner->ClusterBasePosition(); |
1803 return(((TInt64(aCluster)-KFatFirstSearchCluster) << iOwner->ClusterSizeLog2()) + clusterBasePosition); |
1798 return(((TInt64(aCluster)-KFatFirstSearchCluster) << iOwner->ClusterSizeLog2()) + clusterBasePosition); |
1804 } |
1799 } |
1805 |
1800 |
1806 |
1801 |
1807 |
1802 |