diff -r 345b1ca54e88 -r 039a3e647356 userlibandfileserver/fileserver/sfat32/fat_table32.cpp --- a/userlibandfileserver/fileserver/sfat32/fat_table32.cpp Wed Sep 15 13:42:27 2010 +0300 +++ b/userlibandfileserver/fileserver/sfat32/fat_table32.cpp Wed Oct 13 16:04:24 2010 +0300 @@ -402,7 +402,7 @@ Notify the media drive about media areas that shall be treated as "deleted" if this feature is supported. @param aFreedClusters array with FAT numbers of clusters that shall be marked as "deleted" */ -void CFatTable::DoFreedClustersNotifyL(RClusterArray &aFreedClusters) +void CFatTable::DoFreedClustersNotify(RClusterArray &aFreedClusters) { ASSERT(iMediaAtt & KMediaAttDeleteNotify); @@ -423,7 +423,7 @@ const TUint currCluster = aFreedClusters[i]; if (deleteLen == 0) - byteAddress = DataPositionInBytesL(currCluster); //-- start of the media range + byteAddress = DataPositionInBytes(currCluster); //-- start of the media range deleteLen += bytesPerCluster; @@ -438,7 +438,7 @@ {//-- if DeleteNotify() failed, it means that something terribly wrong happened to the NAND media; //-- in normal circumstances it can not happen. One of the reasons: totally worn out media. const TBool platSecEnabled = PlatSec::ConfigSetting(PlatSec::EPlatSecEnforcement); - __PRINT3(_L("CFatTable::DoFreedClustersNotifyL() DeleteNotify failure! drv:%d err:%d, PlatSec:%d"),iOwner->DriveNumber(), r, platSecEnabled); + __PRINT3(_L("CFatTable::DoFreedClustersNotify() DeleteNotify failure! drv:%d err:%d, PlatSec:%d"),iOwner->DriveNumber(), r, platSecEnabled); if(platSecEnabled) { @@ -521,7 +521,7 @@ cntFreedClusters = 0; SetFreeClusterHint(lastKnownFreeCluster); - DoFreedClustersNotifyL(deletedClusters); + DoFreedClustersNotify(deletedClusters); } } @@ -531,7 +531,7 @@ SetFreeClusterHint(lastKnownFreeCluster); if(bFreeClustersNotify) - DoFreedClustersNotifyL(deletedClusters); + DoFreedClustersNotify(deletedClusters); CleanupStack::PopAndDestroy(&deletedClusters); } @@ -671,6 +671,14 @@ return (NumberOfFreeClusters() >= aClustersRequired); } +//----------------------------------------------------------------------------- +/** + @return ETrue if the cluster number aClusterNo is valid, i.e. belongs to the FAT table +*/ +TBool CFatTable::ClusterNumberValid(TUint32 aClusterNo) const + { + return (aClusterNo >= KFatFirstSearchCluster) && (aClusterNo < iMaxEntries); + } @@ -1036,17 +1044,11 @@ //-- create helper thread object and start the thread ipHelperThread = CFat32BitCachePopulator::NewL(*this); - if(ipHelperThread->Launch() != KErrNone) - {//-- failed for some reason - DestroyHelperThread(); - } - else - { + ipHelperThread->Launch(); //-- background FAT bit cache populating thread is running now. //-- the result of thread start up and completion isn't very interesting: If it fails to //-- properly populate the cache, nothing fatal will happen. } - } //-- CFat32BitCachePopulator doesn't affect FAT table state. SetState(EMounted); @@ -1478,7 +1480,7 @@ {//-- test property for this drive is defined if(nMntDebugFlags & KMntDisable_FatBkGndScan) { - __PRINT(_L("#- FAT32 BkGnd scan is disabled by debug interface.")); + __PRINT(_L("#- FAT32 BkGnd scan is disabled is disabled by debug interface.")); bFat32BkGndScan = EFalse; } @@ -1542,8 +1544,7 @@ SetState(EFreeClustersScan); - User::LeaveIfError(ipHelperThread->Launch()); - + ipHelperThread->Launch(); //-- background FAT scanning thread is running now } @@ -1788,20 +1789,17 @@ /** - Return media position in bytes of the cluster start + Return the location of a Cluster in the data section of the media @param aCluster to find location of @return Byte offset of the cluster data */ -TInt64 CAtaFatTable::DataPositionInBytesL(TUint32 aCluster) const +TInt64 CAtaFatTable::DataPositionInBytes(TUint32 aCluster) const { - if(!ClusterNumberValid(aCluster)) - { - __ASSERT_DEBUG(0, Fault(EFatTable_InvalidIndex)); - User::Leave(KErrCorrupt); - } - - const TUint32 clusterBasePosition=iOwner->ClusterBasePosition(); + + __ASSERT_DEBUG(ClusterNumberValid(aCluster), Fault(EFatTable_InvalidIndex)); + + const TInt clusterBasePosition=iOwner->ClusterBasePosition(); return(((TInt64(aCluster)-KFatFirstSearchCluster) << iOwner->ClusterSizeLog2()) + clusterBasePosition); } @@ -1985,8 +1983,7 @@ /** Launches the FAT32_ScanThread scaner thread. - @return KErrNone if the thread launched OK - standard error code otherwise + @return standard error code */ TInt CFat32ScanThread::Launch() { @@ -2548,15 +2545,9 @@ //-- allow this thread to be preempted by another one that wants to access the media driver. //-- without this wait we will have priority inversion, because this (low priority) thread continiously reads data by big chunks //-- and doesn't allow others to access the driver. - //-- On the other hand, if the thread's priority is boosted, there is no reason to be so polite. + //-- On the other hand, if the thread's priority is boosted, there is no reason to be polite. if(!pSelf->IsPriorityBoosted()) - {//-- User::After() granularity can be much coarser than 1ms, e.g. 1/64 Sec. This will add up to the scanning time - User::After(K1mSec); - } - else - {//-- use much less coarse granularity to allow this thread to be preempted even if its priority is boosted. - User::AfterHighRes(128); - } + User::After(K1mSec); //-- User::After() granularity can be much coarser than 1ms //------------------------------------------- mediaPos += bytesToRead;