os/kernelhwsrv/userlibandfileserver/fileserver/sfat/inc/sl_scandrv.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfat/inc/sl_scandrv.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,163 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// f32\sfat\inc\sl_scandrv.h
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @internalTechnology
    1.24 +*/
    1.25 +
    1.26 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.27 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.28 +//!!
    1.29 +//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
    1.30 +//!!
    1.31 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.32 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.33 +
    1.34 +
    1.35 +#ifndef SL_SCANDRV_H
    1.36 +#define SL_SCANDRV_H
    1.37 +
    1.38 +//---------------------------------------------------------------------------------------------------------------------------------
    1.39 +
    1.40 +const TInt KMaxMatchingEntries      = 2;        ///< Maximum number of matching directory entries scan drive can fix. Any more indicates a fault in the file system
    1.41 +const TInt KMaxArrayDepth           = 6;        ///< Maximum array depth for cluster storage when KMaxScanDepth is reached
    1.42 +
    1.43 +//---------------------------------------------------------------------------------------------------------------------------------
    1.44 +
    1.45 +/**
    1.46 +Data structure used to store the location of a partial VFat entry
    1.47 +*/
    1.48 +struct TPartVFatEntry
    1.49 +    {
    1.50 +    TEntryPos    iEntryPos; ///< The position of the partial VFat entry
    1.51 +    TFatDirEntry iEntry;    ///< The Dos entry The VFat entries belong with
    1.52 +    };
    1.53 +
    1.54 +//---------------------------------------------------------------------------------------------------------------------------------
    1.55 +
    1.56 +/**
    1.57 +Data structure used to store the locations of entries with matching
    1.58 +start cluster numbers. 
    1.59 +*/
    1.60 +struct TMatchingStartCluster
    1.61 +    {
    1.62 +    TEntryPos   iEntries[KMaxMatchingEntries]; ///< The positions of the matching entries
    1.63 +    TInt        iCount;         ///< Count of matching entries
    1.64 +    TInt        iStartCluster;  ///< The matching cluster number found in more than one entry
    1.65 +    };
    1.66 +
    1.67 +
    1.68 +//---------------------------------------------------------------------------------------------------------------------------------
    1.69 +
    1.70 +class CCheckFatTable : public CBase
    1.71 +    {
    1.72 +public:
    1.73 +    static CCheckFatTable* NewL(CFatMountCB* aOwner);
    1.74 +    CCheckFatTable(CFatMountCB* aOwner);
    1.75 +    ~CCheckFatTable();
    1.76 +    void InitializeL();
    1.77 +    TBool FlushL();
    1.78 +    TBool GetNextClusterL(TInt& aCluster) const;
    1.79 +    void WriteFatEntryEofFL(TInt aCluster);
    1.80 +    TInt ReadL(TInt aFatIndex) const;
    1.81 +    void WriteL(TInt aFatIndex,TInt aValue);
    1.82 +private:
    1.83 +    void WriteMediaDescriptor();
    1.84 +    TInt PosInBytes(TInt aFatIndex) const;
    1.85 +    TInt PosInIndex(TInt aBytePos) const;
    1.86 +    inline TBool IsEof16Bit(TInt aCluster) const;
    1.87 +    inline TBool IsEof12Bit(TInt aCluster) const;
    1.88 +    inline TInt MaxFatIndex() const;
    1.89 +protected:
    1.90 +    TInt iMaxFatIndex;
    1.91 +    TUint8* iCheckFat;
    1.92 +    CFatMountCB* iOwner;
    1.93 +    };
    1.94 +
    1.95 +
    1.96 +//---------------------------------------------------------------------------------------------------------------------------------
    1.97 +
    1.98 +/**
    1.99 +Scan drive class performs scan drive functionality on all types
   1.100 +of fat volume.
   1.101 +*/
   1.102 +class CScanDrive : public CBase
   1.103 +    {
   1.104 +public:
   1.105 +    enum TDirError{EScanMatchingEntry=1,EScanPartEntry};
   1.106 +public:
   1.107 +    CScanDrive();
   1.108 +    ~CScanDrive();
   1.109 +    static CScanDrive* NewL(CFatMountCB* aMount);
   1.110 +    void ConstructL(CFatMountCB* aMount);
   1.111 +    TInt StartL();
   1.112 +    TBool ProblemsDiscovered() const;  
   1.113 +
   1.114 +
   1.115 +private:
   1.116 +
   1.117 +#if defined(DEBUG_SCANDRIVE)
   1.118 +    void PrintErrors();
   1.119 +    void CompareFatsL() const;
   1.120 +#endif
   1.121 +
   1.122 +    void FixupDirErrorL();
   1.123 +    void FindSameStartClusterL();
   1.124 +    TInt FindStartClusterL(TInt aDirCluster);
   1.125 +    void CheckDirStructureL();
   1.126 +    void CheckDirL(TInt aCluster);
   1.127 +    void ProcessEntryL(const TFatDirEntry& aEntry);
   1.128 +    TInt CheckEntryClusterL(const TFatDirEntry& aEntry, const TEntryPos& aEntryPos);
   1.129 +    void WriteClusterChainL(TInt aCluster,TInt aSizeInBytes);
   1.130 +    TBool MoveToVFatEndL(TEntryPos& aPos,TFatDirEntry& aEntry,TInt& aDirLength);
   1.131 +    TBool IsValidVFatEntry(const TFatDirEntry& aEntry,TInt prevNum)const;
   1.132 +    TBool IsDosEntry(const TFatDirEntry& aEntry)const;
   1.133 +    void AddPartialVFatL(const TEntryPos& aStartPos, const TFatDirEntry& aEntry);
   1.134 +    TBool AddMatchingEntryL(const TEntryPos& aEntryPos);
   1.135 +    TInt GetReservedidL(const TEntryPos aVFatPos);
   1.136 +    void WriteNewFatsL();
   1.137 +    void FixPartEntryL();
   1.138 +    void FixMatchingEntryL();
   1.139 +    void MovePastEntriesL(TEntryPos& aEntryPos,TFatDirEntry& aEntry,TInt aToMove,TInt& aDirEntries);
   1.140 +    void AddToClusterListL(TInt aCluster);
   1.141 +    inline TBool AlreadyExistsL(TInt aCluster)const;
   1.142 +    inline TBool IsEndOfRootDir(const TEntryPos& aPos)const;
   1.143 +    inline TBool IsEofF(TInt aVal)const;
   1.144 +    inline TBool IsDirError()const;
   1.145 +    void IndicateErrorsFound();
   1.146 +
   1.147 +private:
   1.148 +    CFatMountCB*        iMount;
   1.149 +    CCheckFatTable*     iNewFat;
   1.150 +    TPartVFatEntry      iPartEntry;
   1.151 +    TMatchingStartCluster iMatching;
   1.152 +    TDirError           iDirError;
   1.153 +    TInt                iDirsChecked;
   1.154 +    TInt                iRecursiveDepth;
   1.155 +    RArray<TInt>*       iClusterListArray[KMaxArrayDepth];
   1.156 +    TInt                iListArrayIndex;
   1.157 +    TBool               iFoundProblems; ///< if ETrue after finish, it means that there where some problems FS structure and they were probably fixed;
   1.158 +    };
   1.159 +
   1.160 +
   1.161 +
   1.162 +
   1.163 +
   1.164 +#endif //SL_SCANDRV_H
   1.165 +
   1.166 +