diff -r a179b74831c9 -r c1f20ce4abcf userlibandfileserver/fileserver/sfat32/fat_table32.cpp --- a/userlibandfileserver/fileserver/sfat32/fat_table32.cpp Thu Aug 19 11:14:22 2010 +0300 +++ b/userlibandfileserver/fileserver/sfat32/fat_table32.cpp Tue Aug 31 16:34:26 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); + } @@ -684,7 +692,7 @@ CAtaFatTable::CAtaFatTable(CFatMountCB& aOwner) :CFatTable(aOwner), iDriveInteface(aOwner.DriveInterface()) { - iState = ENotInitialised; + iState = ENotInitialised; } @@ -1036,10 +1044,16 @@ //-- create helper thread object and start the thread ipHelperThread = CFat32BitCachePopulator::NewL(*this); - 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. + if(ipHelperThread->Launch() != KErrNone) + {//-- failed for some reason + DestroyHelperThread(); + } + else + { + //-- 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. @@ -1472,7 +1486,7 @@ {//-- test property for this drive is defined if(nMntDebugFlags & KMntDisable_FatBkGndScan) { - __PRINT(_L("#- FAT32 BkGnd scan is disabled is disabled by debug interface.")); + __PRINT(_L("#- FAT32 BkGnd scan is disabled by debug interface.")); bFat32BkGndScan = EFalse; } @@ -1536,7 +1550,8 @@ SetState(EFreeClustersScan); - ipHelperThread->Launch(); + User::LeaveIfError(ipHelperThread->Launch()); + //-- background FAT scanning thread is running now } @@ -1781,20 +1796,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); } @@ -1959,8 +1971,8 @@ return nRes; } - //-- Helper FAT thread is running now - return KErrNone; + //-- Helper FAT thread is running now + return KErrNone; } @@ -1978,7 +1990,8 @@ /** Launches the FAT32_ScanThread scaner thread. - @return standard error code + @return KErrNone if the thread launched OK + standard error code otherwise */ TInt CFat32ScanThread::Launch() {