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::DoFreedClustersNotifyL(RClusterArray &aFreedClusters) |
405 void CFatTable::DoFreedClustersNotify(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 = DataPositionInBytesL(currCluster); //-- start of the media range |
426 byteAddress = DataPositionInBytes(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::DoFreedClustersNotifyL() DeleteNotify failure! drv:%d err:%d, PlatSec:%d"),iOwner->DriveNumber(), r, platSecEnabled); |
441 __PRINT3(_L("CFatTable::DoFreedClustersNotify() 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 DoFreedClustersNotifyL(deletedClusters); |
524 DoFreedClustersNotify(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 DoFreedClustersNotifyL(deletedClusters); |
534 DoFreedClustersNotify(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 } |
674 |
682 |
675 |
683 |
676 |
684 |
677 //####################################################################################################################################### |
685 //####################################################################################################################################### |
678 //# CAtaFatTable class implementation |
686 //# CAtaFatTable class implementation |
682 Constructor |
690 Constructor |
683 */ |
691 */ |
684 CAtaFatTable::CAtaFatTable(CFatMountCB& aOwner) |
692 CAtaFatTable::CAtaFatTable(CFatMountCB& aOwner) |
685 :CFatTable(aOwner), iDriveInteface(aOwner.DriveInterface()) |
693 :CFatTable(aOwner), iDriveInteface(aOwner.DriveInterface()) |
686 { |
694 { |
687 iState = ENotInitialised; |
695 iState = ENotInitialised; |
688 } |
696 } |
689 |
697 |
690 |
698 |
691 CAtaFatTable::~CAtaFatTable() |
699 CAtaFatTable::~CAtaFatTable() |
692 { |
700 { |
1034 if(pFatBitCache) |
1042 if(pFatBitCache) |
1035 {//-- bit cache is present, we need to populate (or repopulate it) |
1043 {//-- bit cache is present, we need to populate (or repopulate it) |
1036 //-- create helper thread object and start the thread |
1044 //-- create helper thread object and start the thread |
1037 ipHelperThread = CFat32BitCachePopulator::NewL(*this); |
1045 ipHelperThread = CFat32BitCachePopulator::NewL(*this); |
1038 |
1046 |
1039 ipHelperThread->Launch(); |
1047 if(ipHelperThread->Launch() != KErrNone) |
1040 //-- background FAT bit cache populating thread is running now. |
1048 {//-- failed for some reason |
1041 //-- the result of thread start up and completion isn't very interesting: If it fails to |
1049 DestroyHelperThread(); |
1042 //-- properly populate the cache, nothing fatal will happen. |
1050 } |
|
1051 else |
|
1052 { |
|
1053 //-- background FAT bit cache populating thread is running now. |
|
1054 //-- the result of thread start up and completion isn't very interesting: If it fails to |
|
1055 //-- properly populate the cache, nothing fatal will happen. |
|
1056 } |
1043 } |
1057 } |
1044 |
1058 |
1045 //-- CFat32BitCachePopulator doesn't affect FAT table state. |
1059 //-- CFat32BitCachePopulator doesn't affect FAT table state. |
1046 SetState(EMounted); |
1060 SetState(EMounted); |
1047 return; |
1061 return; |
1470 TInt nMntDebugFlags; |
1484 TInt nMntDebugFlags; |
1471 if(bFat32BkGndScan && RProperty::Get(KSID_Test1, iOwner->DriveNumber(), nMntDebugFlags) == KErrNone) |
1485 if(bFat32BkGndScan && RProperty::Get(KSID_Test1, iOwner->DriveNumber(), nMntDebugFlags) == KErrNone) |
1472 {//-- test property for this drive is defined |
1486 {//-- test property for this drive is defined |
1473 if(nMntDebugFlags & KMntDisable_FatBkGndScan) |
1487 if(nMntDebugFlags & KMntDisable_FatBkGndScan) |
1474 { |
1488 { |
1475 __PRINT(_L("#- FAT32 BkGnd scan is disabled is disabled by debug interface.")); |
1489 __PRINT(_L("#- FAT32 BkGnd scan is disabled by debug interface.")); |
1476 bFat32BkGndScan = EFalse; |
1490 bFat32BkGndScan = EFalse; |
1477 } |
1491 } |
1478 |
1492 |
1479 } |
1493 } |
1480 #endif |
1494 #endif |
1534 //-- 2. create helper thread object and start the thread |
1548 //-- 2. create helper thread object and start the thread |
1535 ipHelperThread = CFat32FreeSpaceScanner::NewL(*this); |
1549 ipHelperThread = CFat32FreeSpaceScanner::NewL(*this); |
1536 |
1550 |
1537 SetState(EFreeClustersScan); |
1551 SetState(EFreeClustersScan); |
1538 |
1552 |
1539 ipHelperThread->Launch(); |
1553 User::LeaveIfError(ipHelperThread->Launch()); |
|
1554 |
1540 //-- background FAT scanning thread is running now |
1555 //-- background FAT scanning thread is running now |
1541 } |
1556 } |
1542 |
1557 |
1543 //----------------------------------------------------------------------------- |
1558 //----------------------------------------------------------------------------- |
1544 /** |
1559 /** |
1779 FlushL(); |
1794 FlushL(); |
1780 } |
1795 } |
1781 |
1796 |
1782 |
1797 |
1783 /** |
1798 /** |
1784 Return media position in bytes of the cluster start |
1799 Return the location of a Cluster in the data section of the media |
1785 |
1800 |
1786 @param aCluster to find location of |
1801 @param aCluster to find location of |
1787 @return Byte offset of the cluster data |
1802 @return Byte offset of the cluster data |
1788 */ |
1803 */ |
1789 TInt64 CAtaFatTable::DataPositionInBytesL(TUint32 aCluster) const |
1804 TInt64 CAtaFatTable::DataPositionInBytes(TUint32 aCluster) const |
1790 { |
1805 { |
1791 if(!ClusterNumberValid(aCluster)) |
1806 |
1792 { |
1807 __ASSERT_DEBUG(ClusterNumberValid(aCluster), Fault(EFatTable_InvalidIndex)); |
1793 __ASSERT_DEBUG(0, Fault(EFatTable_InvalidIndex)); |
1808 |
1794 User::Leave(KErrCorrupt); |
1809 const TInt clusterBasePosition=iOwner->ClusterBasePosition(); |
1795 } |
|
1796 |
|
1797 const TUint32 clusterBasePosition=iOwner->ClusterBasePosition(); |
|
1798 return(((TInt64(aCluster)-KFatFirstSearchCluster) << iOwner->ClusterSizeLog2()) + clusterBasePosition); |
1810 return(((TInt64(aCluster)-KFatFirstSearchCluster) << iOwner->ClusterSizeLog2()) + clusterBasePosition); |
1799 } |
1811 } |
1800 |
1812 |
1801 |
1813 |
1802 |
1814 |
1957 ForceStop(); |
1969 ForceStop(); |
1958 ASSERT(0); |
1970 ASSERT(0); |
1959 return nRes; |
1971 return nRes; |
1960 } |
1972 } |
1961 |
1973 |
1962 //-- Helper FAT thread is running now |
1974 //-- Helper FAT thread is running now |
1963 return KErrNone; |
1975 return KErrNone; |
1964 } |
1976 } |
1965 |
1977 |
1966 |
1978 |
1967 //####################################################################################################################################### |
1979 //####################################################################################################################################### |
1968 //# CFat32ScanThread implementation |
1980 //# CFat32ScanThread implementation |
1976 |
1988 |
1977 //----------------------------------------------------------------------------- |
1989 //----------------------------------------------------------------------------- |
1978 |
1990 |
1979 /** |
1991 /** |
1980 Launches the FAT32_ScanThread scaner thread. |
1992 Launches the FAT32_ScanThread scaner thread. |
1981 @return standard error code |
1993 @return KErrNone if the thread launched OK |
|
1994 standard error code otherwise |
1982 */ |
1995 */ |
1983 TInt CFat32ScanThread::Launch() |
1996 TInt CFat32ScanThread::Launch() |
1984 { |
1997 { |
1985 return DoLaunchThread(FAT32_ScanThread, this); |
1998 return DoLaunchThread(FAT32_ScanThread, this); |
1986 } |
1999 } |