diff -r 96e5fb8b040d -r 36bfc973b146 userlibandfileserver/fileserver/sfat32/sl_mnt.cpp --- a/userlibandfileserver/fileserver/sfat32/sl_mnt.cpp Thu Dec 17 09:24:54 2009 +0200 +++ b/userlibandfileserver/fileserver/sfat32/sl_mnt.cpp Thu Jan 07 13:38:45 2010 +0200 @@ -81,8 +81,10 @@ CFatMountCB::CFatMountCB() { __PRINT2(_L("CFatMountCB::CFatMountCB() 0x%x, %S"), this, &KThisFsyName); - iFatType = EInvalid; + + SetFatType(EInvalid); iState = ENotMounted; + DBG_STATEMENT(iCBRecFlag = 0); //-- debug flag only } @@ -232,7 +234,7 @@ /** Try remount this Fat volume. Checks if the volume parameters remained the same as on original MountL() call, and if they are, re-initialises the mount. This includes resetting all caches. - ! Do not call this method from TFatDriveInterface methods, like citical and non-critical notifiers ! This can lead to the + ! Do not call this method from TDriveInterface methods, like citical and non-critical notifiers ! This can lead to the recursive loops and undefined behaviour. @return KErrNone if the remount was OK @@ -437,7 +439,7 @@ /** Open CFatMountCB for write. I.e. perform some actions on the first write attempt. - This is a callback from TFatDriveInterface. + This is a callback from TDriveInterface. @return System wide error code. */ TInt CFatMountCB::OpenMountForWrite() @@ -450,12 +452,12 @@ ASSERT(State() == EInit_R || State() == EFinalised); //-- Check possible recursion. This method must not be called recursively. SetVolumeCleanL() works through direct disc access and - //-- can not call TFatDriveInterface methods that call this method etc. + //-- can not call TDriveInterface methods that call this method etc. ASSERT(iCBRecFlag == 0); DBG_STATEMENT(iCBRecFlag = 1); //-- set recursion check flag //-- do here some "opening" work, like marking volme as dirty - //-- be careful here, as soon as this is a callback from TFatDriveInterface, writing via TFatDriveInterface may cause some unwanted recursion. + //-- be careful here, as soon as this is a callback from TDriveInterface, writing via TDriveInterface may cause some unwanted recursion. //-- mark the volume as dirty TInt nRes=KErrNone; @@ -2251,7 +2253,9 @@ pDirCache->MakePageMRU(mruPos); - // only update the leaf dir cache when the original cache index is provided + //-- if the corresponding leaf directory name is cached, associate the last search positionin this directory. + //-- the next search in this dir. will start from this position (and will wrap around over the dir. beginning). + //-- the "last search position" will is the position of current VFAT entryset start. if (aLeafDir.iClusterNum) { iLeafDirCache->UpdateMRUPos(TLeafDirData(aLeafDir.iClusterNum, aStartEntryPos)); @@ -2277,7 +2281,7 @@ TInt count = 1; iTargetName.Set(aTargetName); - isLegalDosName = IsLegalDosName(aTargetName, ETrue, EFalse, EFalse, ETrue, EFalse); + isLegalDosName = IsLegalDosName(aTargetName, ETrue, EFalse, EFalse, ETrue, EFalse); if(isLegalDosName) {//-- iShortName will contain generated short DOS name by long filename @@ -2501,6 +2505,9 @@ //-- locate the name in the cache first to avoid reading from media //-- if the entry belongs to the root directory (for FAT12,16) skip the lookup, because root directory isn't aligned by cluster size boundary, //-- while directory cache pages are. For FAT32 it doesn't matter, because root dir is a usual file. + + //-- the "rummage dir. cache" can be swithed off. This is not affecting the functionality, only the performance. + #if 1 if(iRawDisk->DirCacheInterface() && trgNameFullySpecified && !IsRootDir(aDosEntryPos) && !aFileCreationHelper) {//-- aName is fully specified, i.e doesn't contain wildcards @@ -2512,6 +2519,8 @@ return(aStartEntry.IsVFatEntry()); } } + #endif + //--------------------------------------------------- // we need to scan ahead from the mru pos then come back to beginning, if startcluster is provided @@ -2655,10 +2664,11 @@ found = ETrue; break; //-- DOS entries match, success. } + } else if (!trgNameFullySpecified) {//-- target name contains wildcards, we need to use MatchF with dos name - TBuf8<0x20> dosName8(DosNameFromStdFormat(aDosEntry.Name())); + TBuf8<0x20> dosName8(DosNameFromStdFormat(aDosEntry.Name())); TBuf<0x20> dosName; LocaleUtils::ConvertToUnicodeL(dosName, dosName8); //-- convert DOS name to unicode (implies locale settings) if (dosName.MatchF(trgtNameNoDot)!=KErrNotFound) @@ -2666,7 +2676,7 @@ found = ETrue; break; } - } + } } @@ -2763,10 +2773,12 @@ TInt64 mruPos = MakeLinAddrL(aDosEntryPos); iRawDisk->DirCacheInterface()->MakePageMRU(mruPos); - // only update the leaf dir cache when the original cache index is provided - if (aLeafDirData.iClusterNum) + //-- if the corresponding leaf directory name is cached, associate the last search positionin this directory. + //-- the next search in this dir. will start from this position (and will wrap around over the dir. beginning). + //-- the "last search position" will is the position of current VFAT entryset start. + if(aLeafDirData.iClusterNum) { - iLeafDirCache->UpdateMRUPos(TLeafDirData(aLeafDirData.iClusterNum, aDosEntryPos)); + iLeafDirCache->UpdateMRUPos(TLeafDirData(aLeafDirData.iClusterNum, aStartEntryPos)); } } @@ -4302,6 +4314,12 @@ if (MaxClusters == 0) return KErrCorrupt; + //-- used for measuring time + TTime timeStart; + TTime timeEnd; + timeStart.UniversalTime(); //-- take start time + + RBitVector bitVec; //-- each bit in this vector represents a FAT cluster TInt nRes = bitVec.Create(MaxClusters); @@ -4321,6 +4339,13 @@ bitVec.Close(); + timeEnd.UniversalTime(); //-- take end time + const TInt msScanTime = (TInt)( (timeEnd.MicroSecondsFrom(timeStart)).Int64() / K1mSec); + (void)msScanTime; + + __PRINT1(_L("#@@@ CheckDisk() time taken:%d ms"), msScanTime); + + switch(r) { @@ -4562,5 +4587,57 @@ return nRes; } - - +//----------------------------------------------------------------------------------------- +/** + Internal helper method. + @param aFatType FAT type + @return End Of Cluster Chain code that depend on FAT type, 0xff8 for FAT12, 0xfff8 for FAT16, and 0xffffff8 for FAT32 +*/ +TUint32 EocCodeByFatType(TFatType aFatType) + { + switch(aFatType) + { + case EFat32: + return EOF_32Bit-7; //-- 0xffffff8 + + case EFat16: + return EOF_16Bit-7; //-- 0xfff8 + + case EFat12: + return EOF_12Bit-7; //-- 0xff8 + + default: + ASSERT(aFatType == EInvalid); + return 0; + } + + } + +//----------------------------------------------------------------------------------------- +/** + Set FAT type that this object of CFatMountCB will be dealing with. +*/ +void CFatMountCB::SetFatType(TFatType aFatType) + { + ASSERT(State() == ENotMounted || State() == EDismounted || State() == EMounting) ; + + iFatType = aFatType; + iFatEocCode = EocCodeByFatType(aFatType); + } + + + + + + + + + + + + + + + + +