diff -r e7d2d738d3c2 -r 2f92ad2dc5db userlibandfileserver/fileserver/sfat32/sl_mnt.cpp --- a/userlibandfileserver/fileserver/sfat32/sl_mnt.cpp Mon Mar 15 12:45:50 2010 +0200 +++ b/userlibandfileserver/fileserver/sfat32/sl_mnt.cpp Wed Mar 31 23:38:45 2010 +0300 @@ -304,11 +304,6 @@ { iLeafDirCache->Reset(); } - else - { - User::Free(iLastLeafDir); - iLastLeafDir=NULL; - } } //------------------------------------------------------------------------------------------------------------------- @@ -843,7 +838,7 @@ @param aStartCluster this entry start cluster number @param aParentCluster parent entry start cluster number */ -void CFatMountCB::InitializeFirstDirClusterL(TInt aStartCluster,TInt aParentCluster) +void CFatMountCB::InitializeFirstDirClusterL(TUint32 aStartCluster, TUint32 aParentCluster) { const TUint32 KClusterSz= 1<=KFatFirstSearchCluster,User::Leave(KErrCorrupt)); - TInt endCluster=0; + TUint32 endCluster=0; const TInt clusterRelativePos=ClusterRelativePos(aPos.iPos); const TInt maxClusters=((aLength+clusterRelativePos-1)>>ClusterSizeLog2())+1; @@ -1645,11 +1639,11 @@ if(r == KErrNone && errinf().iReasonCode == TErrorInfo::EBadSector) // GetLastErrorInfo succeded and Last Error was caused by bad sector { - const TInt badcluster = (TInt)(((dataStart + errinf().iErrorPos) - ClusterBasePosition())>>ClusterSizeLog2())+KFatFirstSearchCluster; - TInt goodcluster = FAT().AllocateSingleClusterL(badcluster); + const TUint32 badcluster = (TInt)(((dataStart + errinf().iErrorPos) - ClusterBasePosition())>>ClusterSizeLog2())+KFatFirstSearchCluster; + TUint32 goodcluster = FAT().AllocateSingleClusterL(badcluster); //Calculate cluster number to check whether this write started at the beginning of new cluster or middle of previous cluster. - TInt cluster = aPos.iCluster; + TUint32 cluster = aPos.iCluster; if ( (aPos.iPos) && ((aPos.iPos)==((aPos.iPos >> ClusterSizeLog2())<>ClusterSizeLog2())+1; @@ -1860,33 +1854,20 @@ // { - __PRINT(_L("CFatMountCB::FindLeafDirL")); + __PRINT2(_L("CFatMountCB::FindLeafDirL drv:%d, dir:%S"),DriveNumber() ,&aLeafDir); TLex lex(aName); TInt r; TEntryPos entryPos(RootIndicator(),0); - if (iLeafDirCache == NULL) - { - TInt leaflen=(iLastLeafDir) ? iLastLeafDir->Length() : 0; - TInt namelen=aName.Length(); - if (leaflen>1 && namelen>=leaflen && *iLastLeafDir==aName.Left(leaflen)) - { - if (leaflen==namelen) - return(iLastLeafDirCluster); - lex.Inc(leaflen-1); - entryPos.iCluster=iLastLeafDirCluster; - } - } - else - { - // Skip root directory + ASSERT(iLeafDirCache); + if (iLeafDirCache->CacheCount() > 0 && aName.Length() > 1) { - TInt err = iLeafDirCache->FindInCache(aName, aLeafDir); + const TInt err = iLeafDirCache->FindInCache(aName, aLeafDir); if (err == KErrNone) { - ASSERT(aLeafDir.iClusterNum > 0); + ASSERT(ClusterNumberValid(aLeafDir.iClusterNum)); return aLeafDir.iClusterNum; } else if (err != KErrNotFound) @@ -1894,23 +1875,27 @@ User::LeaveIfError(err); } } - } - - FOREVER + + TFatDirEntry entry; + TFileName fileName; + TEntryPos startPos; + TFatDirEntry startEntry; + + for(;;) { lex.Inc(); // Skip path delimiter lex.Mark(); r=lex.Remainder().Locate(KPathDelimiter); + if (r==KErrNotFound) r=lex.Remainder().Length(); + if (r==0) // End of the path break; + lex.Inc(r); // Set the token length - TFatDirEntry entry; - - TFileName fileName; - TEntryPos startPos; - TFatDirEntry startEntry; + + DoFindL(lex.MarkedToken(), KEntryAttMatchMask|KEntryAttMatchExclusive, startPos, startEntry, entryPos, entry, @@ -1921,21 +1906,13 @@ entryPos.iCluster=StartCluster(entry); entryPos.iPos=0; - } - - if (iLeafDirCache == NULL) - { - AllocBufferL(((CFatMountCB*)this)->iLastLeafDir,aName); - ((CFatMountCB*)this)->iLastLeafDirCluster=entryPos.iCluster; - } - else - { + }// for(;;) + if (aName.Length() > 1) { aLeafDir = TLeafDirData(entryPos.iCluster); iLeafDirCache->AddToCacheL(aName, aLeafDir); } - } return entryPos.iCluster; } @@ -1995,7 +1972,7 @@ TInt numFound = 0; TEntryPos startPos = DosEntryPos1; - TInt clusterNum = DosEntryPos1.iCluster; + TUint32 clusterNum = DosEntryPos1.iCluster; for(TUint32 entryCnt=0; entryCnt < maxDirEntries; ++entryCnt) {//-- walk through directory cluster list. The loop is limited by maximal number of dir entries @@ -2041,7 +2018,7 @@ for(;;) { StartEntryPos1 = DosEntryPos1; - TInt clSave = DosEntryPos1.iCluster; //-- need to save current cluster number because GetDirEntry() & MoveToNextEntryL() can change it + TUint32 clSave = DosEntryPos1.iCluster; //-- need to save current cluster number because GetDirEntry() & MoveToNextEntryL() can change it //-- get directory entry from the cache. We know that the DosEntryPos1 is cached. nErr = GetDirEntry(DosEntryPos1, DosEntry1, StartEntry1, aFileName); @@ -2460,10 +2437,10 @@ __PRINT2(_L("CFatMountCB::DoFindL() drv:%d, %S"),Drive().DriveNumber(),&aTrgtName); - TInt previousCluster=aDosEntryPos.iCluster; + TUint32 previousCluster=aDosEntryPos.iCluster; TUint previousPosition=aDosEntryPos.iPos; - TInt changePreviousCluster=1; - TInt count=0; + TUint32 changePreviousCluster=1; + TUint32 count=0; TBool trgNameIsWildCard = EFalse; //-- ETrue if the name we are looking for is a wildcard TBool trgNameFullySpecified = ETrue; //-- ETrue if the name we are looking for doesn't contain wildcards @@ -2948,7 +2925,7 @@ Zero fill a cluster @param aCluster cluster number to zero-fill */ -void CFatMountCB::ZeroDirClusterL(TInt aCluster) +void CFatMountCB::ZeroDirClusterL(TUint32 aCluster) { __PRINT1(_L("CFatMountCB::ZeroDirClusterL %d"),aCluster); @@ -3165,12 +3142,12 @@ //----------------------------------------------------------------------------------------- /** Read the Uid of the entry starting at aCluster */ -void CFatMountCB::ReadUidL(TInt aCluster,TEntry& anEntry) const +void CFatMountCB::ReadUidL(TUint32 aCluster,TEntry& anEntry) const { __PRINT1(_L("CFatMountCB::ReadUidL(%d)"), aCluster); - if((TUint)aCluster < KFatFirstSearchCluster || (TUint)aCluster >= UsableClusters()+KFatFirstSearchCluster) + if(aCluster < KFatFirstSearchCluster || aCluster >= UsableClusters()+KFatFirstSearchCluster) User::Leave(KErrCorrupt); TBuf8 uidBuf; @@ -3227,10 +3204,10 @@ if ((TUint)(aPos+aLength)>fileSize) aLength=fileSize-aPos; - TInt cluster=StartCluster(dosEntry); + TUint32 cluster=StartCluster(dosEntry); TInt pos = aPos; - TInt endCluster; + TUint32 endCluster; TInt clusterSize=1<Des().SetLength(0); + __PRINT2(_L("CFatMountCB::EraseDirEntryL cl:%d, pos:%d"), aPos.Cluster(), aPos.Pos()); //-- use special interface to access FAT directory file DirWriteL(aPos,TPtrC8((TUint8*)&KEntryErasedMarker,sizeof(TUint8))); @@ -3377,10 +3354,12 @@ //----------------------------------------------------------------------------------------- +/** + Read a FAT directory entry + @param aPos dir. entry position + @param aDirEntry entry data +*/ void CFatMountCB::ReadDirEntryL(const TEntryPos& aPos,TFatDirEntry& aDirEntry) const -// -// Read a FAT directory entry to disk -// { // __PRINT(_L("CFatMountCB::ReadDirEntryL")); @@ -3525,7 +3504,7 @@ This method is called for rugged FAT only. for parameters see CFatTable::ExtendClusterListL */ -void CFatMountCB::ExtendClusterListZeroedL(TInt aNumber,TInt& aCluster) +void CFatMountCB::ExtendClusterListZeroedL(TUint32 aNumber, TUint32& aCluster) { __PRINT(_L("CFatMountCB::ExtendClusterListZeroedL")); __ASSERT_DEBUG(aNumber>0,Fault(EFatBadParameter)); @@ -3961,10 +3940,10 @@ User::Leave(KErrNotFound); // Allows maximum number of entries in root directory } - TInt previousCluster= aDosEntryPos.iCluster; + TUint32 previousCluster= aDosEntryPos.iCluster; TUint previousPosition= aDosEntryPos.iPos; - TInt changePreviousCluster=1; - TInt count=0; + TUint32 changePreviousCluster=1; + TUint32 count=0; TFatDirEntry startEntry; TFileName dummyLongName; @@ -4054,7 +4033,7 @@ TUint i = 0; TInt clusterRelativePos; TInt maxClusters; - TInt endCluster; + TUint32 endCluster; TInt clusterListLen; TInt readLength; TInt temp; @@ -4205,6 +4184,7 @@ } delete pScnDrv; + pScnDrv = NULL; if(chkDskRes != KErrNone) { @@ -4234,7 +4214,7 @@ const TBool bNeedFatRemount = (nScnDrvRes!=KErrNone) || pScnDrv->ProblemsDiscovered(); delete pScnDrv; - + pScnDrv = NULL; if(bNeedFatRemount) {//-- ScanDrive found and probably fixed some errors.