sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32\sfat\inc\sl_scandrv.h sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: //!! sl@0: //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it sl@0: //!! sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: sl@0: sl@0: #ifndef SL_SCANDRV_H sl@0: #define SL_SCANDRV_H sl@0: sl@0: //--------------------------------------------------------------------------------------------------------------------------------- sl@0: sl@0: const TInt KMaxMatchingEntries = 2; ///< Maximum number of matching directory entries scan drive can fix. Any more indicates a fault in the file system sl@0: const TInt KMaxArrayDepth = 6; ///< Maximum array depth for cluster storage when KMaxScanDepth is reached sl@0: sl@0: //--------------------------------------------------------------------------------------------------------------------------------- sl@0: sl@0: /** sl@0: Data structure used to store the location of a partial VFat entry sl@0: */ sl@0: struct TPartVFatEntry sl@0: { sl@0: TEntryPos iEntryPos; ///< The position of the partial VFat entry sl@0: TFatDirEntry iEntry; ///< The Dos entry The VFat entries belong with sl@0: }; sl@0: sl@0: //--------------------------------------------------------------------------------------------------------------------------------- sl@0: sl@0: /** sl@0: Data structure used to store the locations of entries with matching sl@0: start cluster numbers. sl@0: */ sl@0: struct TMatchingStartCluster sl@0: { sl@0: TEntryPos iEntries[KMaxMatchingEntries]; ///< The positions of the matching entries sl@0: TInt iCount; ///< Count of matching entries sl@0: TInt iStartCluster; ///< The matching cluster number found in more than one entry sl@0: }; sl@0: sl@0: sl@0: //--------------------------------------------------------------------------------------------------------------------------------- sl@0: sl@0: class CCheckFatTable : public CBase sl@0: { sl@0: public: sl@0: static CCheckFatTable* NewL(CFatMountCB* aOwner); sl@0: CCheckFatTable(CFatMountCB* aOwner); sl@0: ~CCheckFatTable(); sl@0: void InitializeL(); sl@0: TBool FlushL(); sl@0: TBool GetNextClusterL(TInt& aCluster) const; sl@0: void WriteFatEntryEofFL(TInt aCluster); sl@0: TInt ReadL(TInt aFatIndex) const; sl@0: void WriteL(TInt aFatIndex,TInt aValue); sl@0: private: sl@0: void WriteMediaDescriptor(); sl@0: TInt PosInBytes(TInt aFatIndex) const; sl@0: TInt PosInIndex(TInt aBytePos) const; sl@0: inline TBool IsEof16Bit(TInt aCluster) const; sl@0: inline TBool IsEof12Bit(TInt aCluster) const; sl@0: inline TInt MaxFatIndex() const; sl@0: protected: sl@0: TInt iMaxFatIndex; sl@0: TUint8* iCheckFat; sl@0: CFatMountCB* iOwner; sl@0: }; sl@0: sl@0: sl@0: //--------------------------------------------------------------------------------------------------------------------------------- sl@0: sl@0: /** sl@0: Scan drive class performs scan drive functionality on all types sl@0: of fat volume. sl@0: */ sl@0: class CScanDrive : public CBase sl@0: { sl@0: public: sl@0: enum TDirError{EScanMatchingEntry=1,EScanPartEntry}; sl@0: public: sl@0: CScanDrive(); sl@0: ~CScanDrive(); sl@0: static CScanDrive* NewL(CFatMountCB* aMount); sl@0: void ConstructL(CFatMountCB* aMount); sl@0: TInt StartL(); sl@0: TBool ProblemsDiscovered() const; sl@0: sl@0: sl@0: private: sl@0: sl@0: #if defined(DEBUG_SCANDRIVE) sl@0: void PrintErrors(); sl@0: void CompareFatsL() const; sl@0: #endif sl@0: sl@0: void FixupDirErrorL(); sl@0: void FindSameStartClusterL(); sl@0: TInt FindStartClusterL(TInt aDirCluster); sl@0: void CheckDirStructureL(); sl@0: void CheckDirL(TInt aCluster); sl@0: void ProcessEntryL(const TFatDirEntry& aEntry); sl@0: TInt CheckEntryClusterL(const TFatDirEntry& aEntry, const TEntryPos& aEntryPos); sl@0: void WriteClusterChainL(TInt aCluster,TInt aSizeInBytes); sl@0: TBool MoveToVFatEndL(TEntryPos& aPos,TFatDirEntry& aEntry,TInt& aDirLength); sl@0: TBool IsValidVFatEntry(const TFatDirEntry& aEntry,TInt prevNum)const; sl@0: TBool IsDosEntry(const TFatDirEntry& aEntry)const; sl@0: void AddPartialVFatL(const TEntryPos& aStartPos, const TFatDirEntry& aEntry); sl@0: TBool AddMatchingEntryL(const TEntryPos& aEntryPos); sl@0: TInt GetReservedidL(const TEntryPos aVFatPos); sl@0: void WriteNewFatsL(); sl@0: void FixPartEntryL(); sl@0: void FixMatchingEntryL(); sl@0: void MovePastEntriesL(TEntryPos& aEntryPos,TFatDirEntry& aEntry,TInt aToMove,TInt& aDirEntries); sl@0: void AddToClusterListL(TInt aCluster); sl@0: inline TBool AlreadyExistsL(TInt aCluster)const; sl@0: inline TBool IsEndOfRootDir(const TEntryPos& aPos)const; sl@0: inline TBool IsEofF(TInt aVal)const; sl@0: inline TBool IsDirError()const; sl@0: void IndicateErrorsFound(); sl@0: sl@0: private: sl@0: CFatMountCB* iMount; sl@0: CCheckFatTable* iNewFat; sl@0: TPartVFatEntry iPartEntry; sl@0: TMatchingStartCluster iMatching; sl@0: TDirError iDirError; sl@0: TInt iDirsChecked; sl@0: TInt iRecursiveDepth; sl@0: RArray* iClusterListArray[KMaxArrayDepth]; sl@0: TInt iListArrayIndex; sl@0: TBool iFoundProblems; ///< if ETrue after finish, it means that there where some problems FS structure and they were probably fixed; sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: #endif //SL_SCANDRV_H sl@0: sl@0: