author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 16 Apr 2010 16:24:37 +0300 | |
changeset 90 | 947f0dc9f7a8 |
parent 36 | 538db54a451d |
child 102 | ef2a444a7410 |
child 149 | d9f1e5bfe28c |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// f32\sfat32\sl_scan32.cpp |
|
15 |
// ScanDrive code, specific for EFAT32.FSY |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
/** |
|
20 |
@file |
|
21 |
@internalTechnology |
|
22 |
*/ |
|
23 |
||
24 |
#include "sl_std.h" |
|
25 |
#include "sl_scandrv.h" |
|
26 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
27 |
const TInt KMaxScanDepth = 20; ///< Maximum scan depth of to avoid stack over flow |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
28 |
const TInt KClusterListGranularity = 8; ///< Granularity of cluster list used for storage of clusters when KMaxScanDepth is reached |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
29 |
|
0 | 30 |
|
31 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
32 |
/** |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
33 |
CScanDrive factory method |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
34 |
@param aMount the owning mount |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
35 |
*/ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
36 |
CScanDrive* CScanDrive::NewL(CFatMountCB* aMount) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
37 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
38 |
if(!aMount) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
39 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
40 |
ASSERT(0); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
41 |
User::Leave(KErrArgument); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
42 |
} |
0 | 43 |
|
44 |
CScanDrive* self=new (ELeave) CScanDrive(); |
|
45 |
CleanupStack::PushL(self); |
|
46 |
self->ConstructL(aMount); |
|
47 |
CleanupStack::Pop(); |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
48 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
49 |
return self; |
0 | 50 |
} |
51 |
||
52 |
||
53 |
CScanDrive::~CScanDrive() |
|
54 |
{ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
55 |
for(TUint i=0; i<KMaxArrayDepth && iClusterListArray[i]!=NULL; ++i) |
0 | 56 |
{ |
57 |
iClusterListArray[i]->Close(); |
|
58 |
delete iClusterListArray[i]; |
|
59 |
} |
|
60 |
||
61 |
iMediaFatBits.Close(); |
|
62 |
iScanFatBits.Close(); |
|
63 |
||
64 |
} |
|
65 |
||
66 |
/** |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
67 |
Creates the structure of this class. |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
68 |
@param aMount The owning mount |
0 | 69 |
*/ |
70 |
void CScanDrive::ConstructL(CFatMountCB* aMount) |
|
71 |
{ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
72 |
ASSERT(aMount); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
73 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
74 |
//--- setting up |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
75 |
iMount=aMount; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
76 |
iGenericError = ENoErrors; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
77 |
iDirError = ENoDirError; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
78 |
iMaxClusters = iMount->UsableClusters()+KFatFirstSearchCluster; //-- UsableClusters() doesn't count first 2 unused clusers |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
79 |
//------------------------------ |
0 | 80 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
81 |
//-- create bit vectors that will represent FAT on media and reconstructed by ScanDrive. Each bit in the vector represents 1 FAT cluster. |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
82 |
const TUint32 KClustersNum = MaxClusters(); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
83 |
|
0 | 84 |
CleanupClosePushL(iMediaFatBits); |
85 |
CleanupClosePushL(iScanFatBits); |
|
86 |
||
87 |
iMediaFatBits.CreateL(KClustersNum); |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
88 |
iScanFatBits.CreateL(KClustersNum); |
0 | 89 |
|
90 |
CleanupStack::Pop(&iScanFatBits); |
|
91 |
CleanupStack::Pop(&iMediaFatBits); |
|
92 |
} |
|
93 |
||
94 |
//---------------------------------------------------------------------------------------------------- |
|
95 |
/** |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
96 |
FAT type-agnostic parser. Reads whole FAT and sets up a bit vector. |
0 | 97 |
for FAT12/16 it's OK, because the FAT12/16 is fully cached. |
98 |
*/ |
|
99 |
void CScanDrive::DoParseFatL() |
|
100 |
{ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
101 |
const TInt KMaxClusters = MaxClusters(); |
0 | 102 |
|
103 |
iMediaFatBits.Fill(0); |
|
104 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
105 |
__PRINT1(_L("CScanDrive::DoParseFatL(), clusters:%d"), KMaxClusters); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
106 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
107 |
for(TInt i=KFatFirstSearchCluster; i<KMaxClusters; ++i) |
0 | 108 |
{ |
109 |
const TUint32 nFatEntry = ReadFatL(i); |
|
110 |
||
111 |
//-- each '1' bit represents a used cluster |
|
112 |
if(nFatEntry != KSpareCluster) |
|
113 |
iMediaFatBits.SetBit(i); |
|
114 |
} |
|
115 |
} |
|
116 |
||
117 |
//---------------------------------------------------------------------------------------------------- |
|
118 |
/** |
|
119 |
Parse FAT32 buffer. |
|
120 |
@param aBuf buffer, containing FAT32 entries (current portion of FAT) |
|
121 |
@param aCurrFatEntry current FAT entry processed |
|
122 |
*/ |
|
123 |
void CScanDrive::DoParseFat32Buf(const TPtrC8& aBuf, TUint32& aCurrFatEntry) |
|
124 |
{ |
|
125 |
ASSERT((aBuf.Size() & (sizeof(TFat32Entry)-1)) == 0); |
|
126 |
||
127 |
const TInt KNumEntries = aBuf.Size() >> KFat32EntrySzLog2; |
|
128 |
const TFat32Entry* const pFatEntry = (const TFat32Entry*)(aBuf.Ptr()); |
|
129 |
||
130 |
for(TInt i=0; i<KNumEntries; ++i) |
|
131 |
{ |
|
132 |
if(aCurrFatEntry >= KFatFirstSearchCluster) |
|
133 |
{ |
|
134 |
if((pFatEntry[i] & KFat32EntryMask) != KSpareCluster) |
|
135 |
{//-- found a non-free FAT32 entry |
|
136 |
iMediaFatBits.SetBit(aCurrFatEntry); |
|
137 |
} |
|
138 |
} |
|
139 |
++aCurrFatEntry; |
|
140 |
} |
|
141 |
} |
|
142 |
||
143 |
//---------------------------------------------------------------------------------------------------- |
|
144 |
/** |
|
145 |
A specialised method to read and parse FAT32 using a larger buffer. |
|
146 |
1. Larger buffer gives better read performance |
|
147 |
2. using dedicated buffer doesn't trash FAT32 LRU cache. |
|
148 |
*/ |
|
149 |
void CScanDrive::DoParseFat32L() |
|
150 |
{ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
151 |
const TInt KNumClusters = MaxClusters(); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
152 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
153 |
__PRINT1(_L("CScanDrive::DoParseFat32L(), clusters:%d"), KNumClusters); |
0 | 154 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
155 |
ASSERT(iMount->FatType() == EFat32); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
156 |
|
0 | 157 |
const TUint32 KFat1StartPos = iMount->StartOfFatInBytes(); |
158 |
const TUint32 KFatSize = KNumClusters * sizeof(TFat32Entry); //-- usable size of one FAT. |
|
159 |
||
160 |
const TUint32 KFatBufSz = 32*K1KiloByte; //-- buffer size for FAT reading. 32K seems to be optimal size |
|
161 |
||
162 |
iMediaFatBits.Fill(0); |
|
163 |
||
164 |
RBuf8 buf; |
|
165 |
CleanupClosePushL(buf); |
|
166 |
||
167 |
//-- allocate memory for FAT parse buffer |
|
168 |
buf.CreateMaxL(KFatBufSz); |
|
169 |
||
170 |
//-- read FAT directly from the media into the large buffer and parse it |
|
171 |
TUint32 rem = KFatSize; |
|
172 |
TUint32 mediaPos = KFat1StartPos; |
|
173 |
TUint32 currFatEntry = 0; |
|
174 |
||
175 |
while(rem) |
|
176 |
{ |
|
177 |
const TUint32 bytesToRead=Min(rem, KFatBufSz); |
|
178 |
TPtrC8 ptrData(buf.Ptr(), bytesToRead); |
|
179 |
||
180 |
//-- read portion of the FAT into buffer |
|
181 |
User::LeaveIfError(iMount->LocalDrive()->Read(mediaPos, bytesToRead, buf)); |
|
182 |
||
183 |
//-- parse the buffer and populate bit vector |
|
184 |
DoParseFat32Buf(ptrData, currFatEntry); |
|
185 |
||
186 |
mediaPos += bytesToRead; |
|
187 |
rem -= bytesToRead; |
|
188 |
} |
|
189 |
||
190 |
buf.Close(); |
|
191 |
CleanupStack::PopAndDestroy(&buf); |
|
192 |
} |
|
193 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
194 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
195 |
|
0 | 196 |
//---------------------------------------------------------------------------------------------------- |
197 |
/** |
|
198 |
Sets up a bit list representation of the media fat |
|
199 |
Reads whole FAT and sets '1' bits in the bit vector corresponding to the occupied clusters. |
|
200 |
*/ |
|
201 |
void CScanDrive::ReadMediaFatL() |
|
202 |
{ |
|
203 |
ASSERT(iMount->ConsistentState()); |
|
204 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
205 |
TInt nRes; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
206 |
|
0 | 207 |
if(iMount->FatType() == EFat32) |
208 |
{//-- for FAT32 try to use specialised method of parsing |
|
209 |
TRAP(nRes, DoParseFat32L()) |
|
210 |
if(nRes == KErrNone) |
|
211 |
return; |
|
212 |
} |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
213 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
214 |
|
0 | 215 |
//-- use old FAT-agnostic parsing |
216 |
DoParseFatL(); |
|
217 |
} |
|
218 |
||
219 |
||
220 |
/** |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
221 |
@return True if a directory error has been found |
0 | 222 |
*/ |
223 |
TBool CScanDrive::IsDirError() const |
|
224 |
{ |
|
225 |
return(iDirError!=0); |
|
226 |
} |
|
227 |
||
228 |
/** |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
229 |
After StartL() and finishing allows us to know if there were any problems discovered at all. |
0 | 230 |
The client may wish to remount the filesystem if there were errors. |
231 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
232 |
@return The code describing the problem. |
0 | 233 |
*/ |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
234 |
CScanDrive::TGenericError CScanDrive::ProblemsDiscovered() const |
0 | 235 |
{ |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
236 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
237 |
if(IsDirError()) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
238 |
return EScanDriveDirError; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
239 |
else |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
240 |
return iGenericError; |
0 | 241 |
} |
242 |
||
243 |
/** |
|
244 |
Sets the flag indicating than there are errors in filesystem structure |
|
245 |
See ProblemsDiscovered() |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
246 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
247 |
@param aError a code describing the error |
0 | 248 |
*/ |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
249 |
void CScanDrive::IndicateErrorsFound(TGenericError aError) |
0 | 250 |
{ |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
251 |
ASSERT(aError != ENoErrors); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
252 |
iGenericError = aError; |
0 | 253 |
} |
254 |
||
255 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
256 |
//---------------------------------------------------------------------------------------------------- |
0 | 257 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
258 |
Start the scanner. The this calss description about what it actually does. |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
259 |
@param aMode specifies the operational mode. |
0 | 260 |
*/ |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
261 |
void CScanDrive::StartL(TScanDriveMode aMode) |
0 | 262 |
{ |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
263 |
__PRINT2(_L("CScanDrive::StartL(%d), drive:%d"), aMode, iMount->DriveNumber()); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
264 |
iScanDriveMode = aMode; |
0 | 265 |
|
266 |
//-- used for measuring time |
|
267 |
TTime timeStart; |
|
268 |
TTime timeEnd; |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
269 |
|
0 | 270 |
timeStart.UniversalTime(); //-- take start time |
271 |
||
272 |
ReadMediaFatL(); |
|
273 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
274 |
//timeEnd.UniversalTime(); //-- take end time |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
275 |
//elapsedTime = (TInt)( (timeEnd.MicroSecondsFrom(timeStart)).Int64() / K1mSec); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
276 |
//__PRINT1(_L("#@@@ CScanDrive #1:%d ms "), elapsedTime); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
277 |
|
0 | 278 |
CheckDirStructureL(); |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
279 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
280 |
//-- uncomment a line below if you need to compare real and restored FAT tables and print out all differences |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
281 |
//CompareFatsL(EFalse); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
282 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
283 |
//timeEnd.UniversalTime(); //-- take end time |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
284 |
//elapsedTime = (TInt)( (timeEnd.MicroSecondsFrom(timeStart)).Int64() / K1mSec); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
285 |
//__PRINT1(_L("#@@@ CScanDrive #2:%d ms "), elapsedTime); |
0 | 286 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
287 |
if(CheckDiskMode()) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
288 |
{//-- in check disk mode it is nesessarily just to detech FS errors |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
289 |
CompareFatsL(ETrue); //-- will stop on the first error found |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
290 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
291 |
else |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
292 |
{//-- In ScanDrive mode we need to find and fix Rugged FAT artefacts. |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
293 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
294 |
if(IsDirError()) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
295 |
FixupDirErrorL(); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
296 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
297 |
CompareAndFixFatsL(); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
298 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
299 |
|
0 | 300 |
PrintErrors(); |
301 |
||
302 |
||
303 |
timeEnd.UniversalTime(); //-- take end time |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
304 |
const TInt elapsedTime = (TInt)( (timeEnd.MicroSecondsFrom(timeStart)).Int64() / K1mSec); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
305 |
(void)elapsedTime; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
306 |
|
0 | 307 |
__PRINT1(_L("CScanDrive: Directories visisted = %d\n"),iDirsChecked); |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
308 |
__PRINT1(_L("#@@@ CScanDrive time taken:%d ms "), elapsedTime); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
309 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
310 |
|
0 | 311 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
312 |
return; |
0 | 313 |
} |
314 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
315 |
//---------------------------------------------------------------------------------------------------- |
0 | 316 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
317 |
Fix errors detected by the drive scan |
0 | 318 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
319 |
@leave System wide error code |
0 | 320 |
*/ |
321 |
void CScanDrive::FixupDirErrorL() |
|
322 |
{ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
323 |
ASSERT(!CheckDiskMode()); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
324 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
325 |
if(!IsDirError()) |
0 | 326 |
return; |
327 |
||
328 |
if(iDirError==EScanMatchingEntry) |
|
329 |
{ |
|
330 |
FindSameStartClusterL(); |
|
331 |
FixMatchingEntryL(); |
|
332 |
} |
|
333 |
else |
|
334 |
{ |
|
335 |
FixPartEntryL(); |
|
336 |
} |
|
337 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
338 |
IndicateErrorsFound(EScanDriveDirError); //-- indicate that we have found errors |
0 | 339 |
} |
340 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
341 |
//---------------------------------------------------------------------------------------------------- |
0 | 342 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
343 |
Find positions of entries with same start cluster for error correction, searches |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
344 |
the whole volume. Starts at the root directory. |
0 | 345 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
346 |
@leave System wide error code |
0 | 347 |
*/ |
348 |
void CScanDrive::FindSameStartClusterL() |
|
349 |
{ |
|
350 |
TInt err=FindStartClusterL(iMount->RootIndicator()); |
|
351 |
if(err==KErrNone) |
|
352 |
return; |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
353 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
354 |
for(TUint i=0;i<KMaxArrayDepth && iClusterListArray[i]!=NULL;++i) |
0 | 355 |
{ |
356 |
RArray<TInt>* clusterList=iClusterListArray[i]; |
|
357 |
for(TInt j=0;j<clusterList->Count();++j) |
|
358 |
{ |
|
359 |
iRecursiveDepth=0; |
|
360 |
err=FindStartClusterL((*clusterList)[j]); |
|
361 |
if(err==KErrNone) |
|
362 |
return; |
|
363 |
} |
|
364 |
} |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
365 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
366 |
if(err != KErrNone) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
367 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
368 |
__PRINT1(_L("CScanDrive::FindSameStartClusterL() #1 %d"), err); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
369 |
User::Leave(KErrNotFound); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
370 |
} |
0 | 371 |
} |
372 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
373 |
//---------------------------------------------------------------------------------------------------- |
0 | 374 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
375 |
Scan through directory structure looking for start cluster found in iMatching |
0 | 376 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
377 |
@param aDirCluster Start cluster for scan to start |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
378 |
@return System wide error value |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
379 |
@leave |
0 | 380 |
*/ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
381 |
TInt CScanDrive::FindStartClusterL(TUint32 aDirCluster) |
0 | 382 |
{ |
383 |
__PRINT1(_L("CScanDrive::FindStartCluster dirCluster=%d"),aDirCluster); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
384 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
385 |
if(aDirCluster < (TUint)iMount->RootIndicator() || aDirCluster >= MaxClusters()) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
386 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
387 |
__PRINT(_L("CScanDrive::FindStartCluster() #!\n")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
388 |
IndicateErrorsFound(EBadClusterNumber); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
389 |
User::Leave(KErrCorrupt); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
390 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
391 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
392 |
|
0 | 393 |
if(++iRecursiveDepth==KMaxScanDepth) |
394 |
{ |
|
395 |
--iRecursiveDepth; |
|
396 |
return(KErrNotFound); |
|
397 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
398 |
|
0 | 399 |
TEntryPos entryPos(aDirCluster,0); |
400 |
TInt dirEntries=0; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
401 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
402 |
for(;;) |
0 | 403 |
{ |
404 |
TFatDirEntry entry; |
|
405 |
ReadDirEntryL(entryPos,entry); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
406 |
|
0 | 407 |
if(entry.IsParentDirectory()||entry.IsCurrentDirectory()||entry.IsErased()) |
408 |
{ |
|
409 |
if(IsEndOfRootDir(entryPos)) |
|
410 |
break; |
|
411 |
MoveToNextEntryL(entryPos); |
|
412 |
continue; |
|
413 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
414 |
|
0 | 415 |
if(entry.IsEndOfDirectory()) |
416 |
break; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
417 |
|
0 | 418 |
TEntryPos vfatPos=entryPos; |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
419 |
const TBool isComplete = MoveToVFatEndL(entryPos,entry,dirEntries); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
420 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
421 |
if(!isComplete) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
422 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
423 |
__PRINT(_L("CScanDrive::FindStartCluster() #2\n")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
424 |
IndicateErrorsFound(EEntrySetIncomplete); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
425 |
User::Leave(KErrBadName); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
426 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
427 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
428 |
|
0 | 429 |
TInt err=CheckEntryClusterL(entry,vfatPos); |
430 |
if(err==KErrNone) |
|
431 |
{ |
|
432 |
--iRecursiveDepth; |
|
433 |
return(err); |
|
434 |
} |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
435 |
|
0 | 436 |
if(IsEndOfRootDir(entryPos)) |
437 |
break; |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
438 |
|
0 | 439 |
MoveToNextEntryL(entryPos); |
440 |
} |
|
441 |
--iRecursiveDepth; |
|
442 |
return(KErrNotFound); |
|
443 |
} |
|
444 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
445 |
//---------------------------------------------------------------------------------------------------- |
0 | 446 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
447 |
Procces aEntry to find matching start cluster |
0 | 448 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
449 |
@param aEntry Directory entry to check |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
450 |
@param aEntryPos Position of directory to check |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
451 |
@return System wide error value |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
452 |
@leave |
0 | 453 |
*/ |
454 |
TInt CScanDrive::CheckEntryClusterL(const TFatDirEntry& aEntry, const TEntryPos& aEntryPos) |
|
455 |
{ |
|
456 |
__PRINT(_L("CScanDrive::CheckEntryClusterL")); |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
457 |
if((TUint)iMount->StartCluster(aEntry)==iMatching.iStartCluster) |
0 | 458 |
{ |
459 |
TBool complete=AddMatchingEntryL(aEntryPos); |
|
460 |
if(complete) |
|
461 |
return(KErrNone); |
|
462 |
} |
|
463 |
else if(aEntry.Attributes()&KEntryAttDir) |
|
464 |
return(FindStartClusterL(iMount->StartCluster(aEntry))); |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
465 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
466 |
return KErrNotFound; |
0 | 467 |
} |
468 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
469 |
//---------------------------------------------------------------------------------------------------- |
0 | 470 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
471 |
Checks directory structure for errors, can be considered the start point of the scan. |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
472 |
Handles recursion depth to avoid stack overflow. |
0 | 473 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
474 |
@leave System wide error code |
0 | 475 |
*/ |
476 |
void CScanDrive::CheckDirStructureL() |
|
477 |
{ |
|
478 |
CheckDirL(iMount->RootIndicator()); |
|
479 |
// Due to recursive nature of CheckDirL when a depth of |
|
480 |
// KMaxScanDepth is reached clusters are stored in a list |
|
481 |
// and passed into CheckDirL afresh |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
482 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
483 |
for(TUint i=0;i<KMaxArrayDepth && iClusterListArray[i]!=NULL;++i) |
0 | 484 |
{ |
485 |
RArray<TInt>* clusterList=iClusterListArray[i]; |
|
486 |
++iListArrayIndex; |
|
487 |
for(TInt j=0;j<clusterList->Count();++j) |
|
488 |
{ |
|
489 |
iRecursiveDepth=0; |
|
490 |
CheckDirL((*clusterList)[j]); |
|
491 |
} |
|
492 |
} |
|
493 |
} |
|
494 |
||
495 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
496 |
//---------------------------------------------------------------------------------------------------- |
0 | 497 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
498 |
This function is called recursively with Process entry untill the whole volume has been scanned. |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
499 |
Each directory entry is scanned for errors, these are recorded for later fixing. |
0 | 500 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
501 |
@param aCluster Directory cluster to start checking |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
502 |
@leave System wide error codes |
0 | 503 |
*/ |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
504 |
void CScanDrive::CheckDirL(TUint32 aCluster) |
0 | 505 |
{ |
506 |
__PRINT1(_L("CScanDrive::CheckDirL aCluster=%d"),aCluster); |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
507 |
|
0 | 508 |
// check depth of recursion |
509 |
if(++iRecursiveDepth==KMaxScanDepth) |
|
510 |
{ |
|
511 |
AddToClusterListL(aCluster); |
|
512 |
--iRecursiveDepth; |
|
513 |
return; |
|
514 |
} |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
515 |
|
0 | 516 |
++iDirsChecked; |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
517 |
|
0 | 518 |
TEntryPos entryPos(aCluster,0); |
519 |
TInt dirEntries=0; |
|
520 |
FOREVER |
|
521 |
{ |
|
522 |
TFatDirEntry entry; |
|
523 |
ReadDirEntryL(entryPos,entry); |
|
524 |
if(!iMount->IsEndOfClusterCh(entryPos.iCluster)) |
|
525 |
++dirEntries; |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
526 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
527 |
if(entry.IsParentDirectory() || entry.IsCurrentDirectory() || entry.IsErased()) |
0 | 528 |
{ |
529 |
if(IsEndOfRootDir(entryPos)) |
|
530 |
break; |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
531 |
|
0 | 532 |
MoveToNextEntryL(entryPos); |
533 |
continue; |
|
534 |
} |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
535 |
|
0 | 536 |
if(entry.IsEndOfDirectory()) |
537 |
{ |
|
538 |
if(aCluster) |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
539 |
RecordClusterChainL(aCluster,dirEntries<<KSizeOfFatDirEntryLog2); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
540 |
|
0 | 541 |
break; |
542 |
} |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
543 |
|
0 | 544 |
TEntryPos origPos=entryPos; |
545 |
TFatDirEntry origEntry=entry; |
|
546 |
TInt origDirEntries=dirEntries; |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
547 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
548 |
const TBool isComplete = MoveToVFatEndL(entryPos,entry,dirEntries); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
549 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
550 |
if(!isComplete && CheckDiskMode()) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
551 |
{//-- broken VFAT entryset; in CheckDisk mode this is the FS error, abort further activity |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
552 |
__PRINT(_L("CScanDrive::CheckDirL() #1")); |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
553 |
IndicateErrorsFound(EInvalidEntrySize); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
554 |
User::Leave(KErrCorrupt); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
555 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
556 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
557 |
// Only assume that this is a corrupted VFAT entry if the VFAT attributes are set; |
0 | 558 |
// assuming a non-VFAT corrupted entry is a VFAT entry is dangerous as we then assume that the |
559 |
// first byte is a count of entries to skip, thus completely invalidating the next <n> directories. |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
560 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
561 |
//-- this code seems to deal with one of the Rugged FAT artefacts: partially deleted VFAT entryset, when DOS entry is deleted first |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
562 |
//-- and delettion of VFAT ones had failed |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
563 |
if(!isComplete && origEntry.IsVFatEntry()) |
0 | 564 |
{ |
565 |
AddPartialVFatL(origPos,origEntry); |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
566 |
if(!IsEofF(entryPos.iCluster)) |
0 | 567 |
{ |
568 |
TInt toMove=origEntry.NumFollowing()-(dirEntries-origDirEntries); |
|
569 |
if(toMove) |
|
570 |
MovePastEntriesL(entryPos,entry,toMove,dirEntries); |
|
571 |
} |
|
572 |
else |
|
573 |
{ |
|
574 |
// we fell off the end of the directory file, so just strip this |
|
575 |
// incomplete long file name entry |
|
576 |
dirEntries = origDirEntries; |
|
577 |
} |
|
578 |
} |
|
579 |
else |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
580 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
581 |
ProcessEntryL(entry); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
582 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
583 |
|
0 | 584 |
if(IsEndOfRootDir(entryPos)) |
585 |
break; |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
586 |
|
0 | 587 |
MoveToNextEntryL(entryPos); |
588 |
} |
|
589 |
--iRecursiveDepth; |
|
590 |
} |
|
591 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
592 |
//---------------------------------------------------------------------------------------------------- |
0 | 593 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
594 |
Process non trivial entries, such as files, if they are correct by filling out their |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
595 |
cluster allocation in the bit packed Fat table. If it comes accross a directory |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
596 |
CheckDirL will be called. |
0 | 597 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
598 |
@param aEntry Directory entry to check |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
599 |
@leave System wide error code |
0 | 600 |
*/ |
601 |
void CScanDrive::ProcessEntryL(const TFatDirEntry& aEntry) |
|
602 |
{ |
|
603 |
__PRINT(_L("CScanDrive::ProcessEntryL")); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
604 |
const TUint entryAtt=aEntry.Attributes(); |
0 | 605 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
606 |
if((entryAtt & ~KEntryAttMaskSupported) || aEntry.IsErased()) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
607 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
608 |
__PRINT1(_L("CScanDrive::ProcessEntryL() wrong entry att: 0x%x"), entryAtt); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
609 |
IndicateErrorsFound(EEntryBadAtt); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
610 |
User::Leave(KErrCorrupt); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
611 |
} |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
612 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
613 |
if(!(entryAtt&(KEntryAttDir|KEntryAttVolume)) && iMount->StartCluster(aEntry)>0) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
614 |
{//-- this is a file with length >0. Check that its cluster chain corresponds to its size |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
615 |
RecordClusterChainL(iMount->StartCluster(aEntry), aEntry.Size()); |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
616 |
} |
0 | 617 |
else if(entryAtt&KEntryAttDir) |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
618 |
{//-- this is the directory, walk into it |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
619 |
CheckDirL(iMount->StartCluster(aEntry)); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
620 |
} |
0 | 621 |
} |
622 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
623 |
//---------------------------------------------------------------------------------------------------- |
0 | 624 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
625 |
Walks the cluster chain for a correct file or directory, checks that the cluster |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
626 |
has not already been used and that the correct number of clusters are allocated for the |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
627 |
size of file. Registers cluster as used, if correct. |
0 | 628 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
629 |
@param aCluster Cluster chain start point |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
630 |
@param aSizeInBytes Size of the file or directory in bytes |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
631 |
@leave System wide error values |
0 | 632 |
*/ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
633 |
void CScanDrive::RecordClusterChainL(TUint32 aCluster, TUint aSizeInBytes) |
0 | 634 |
{ |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
635 |
__PRINT2(_L("CScanDrive::RecordClusterChainL() cl:%d, sz:%d") ,aCluster, aSizeInBytes); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
636 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
637 |
if(aCluster < KFatFirstSearchCluster || aCluster >= MaxClusters()) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
638 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
639 |
__PRINT(_L("CScanDrive::RecordClusterChainL() #0")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
640 |
IndicateErrorsFound(EBadClusterNumber); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
641 |
User::Leave(KErrCorrupt); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
642 |
} |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
643 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
644 |
TUint clusterCount; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
645 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
646 |
if(aSizeInBytes==0) |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
647 |
{ |
0 | 648 |
clusterCount=1; |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
649 |
} |
0 | 650 |
else |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
651 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
652 |
const TUint64 tmp = aSizeInBytes + Pow2_64(iMount->ClusterSizeLog2()) - 1; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
653 |
clusterCount = (TUint) (tmp >> iMount->ClusterSizeLog2()); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
654 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
655 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
656 |
TUint startCluster=aCluster; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
657 |
|
0 | 658 |
while(clusterCount) |
659 |
{ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
660 |
if(IsClusterUsedL(aCluster)) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
661 |
{//-- this cluster already seems to belong to some other object; crosslinked cluster chain. Can't fix it. |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
662 |
__PRINT1(_L("CScanDrive::RecordClusterChainL #1 %d"),aCluster); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
663 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
664 |
if(CheckDiskMode()) |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
665 |
{//-- in check disk mode this is a FS error; Indicate error and abort furter scanning |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
666 |
__PRINT(_L("CScanDrive::RecordClusterChainL #1.1")); |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
667 |
IndicateErrorsFound(EClusterAlreadyInUse); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
668 |
User::Leave(KErrCorrupt); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
669 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
670 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
671 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
672 |
if(IsDirError() || iMatching.iStartCluster > 0 || aCluster != startCluster) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
673 |
{//-- secondary entry into this state |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
674 |
__PRINT(_L("CScanDrive::RecordClusterChainL #1.2")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
675 |
IndicateErrorsFound(EClusterAlreadyInUse); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
676 |
User::Leave(KErrCorrupt); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
677 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
678 |
|
0 | 679 |
iMatching.iStartCluster=aCluster; |
680 |
iDirError=EScanMatchingEntry; //ERROR POINT |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
681 |
IndicateErrorsFound(EScanDriveDirError); //-- indicate that we have found errors |
0 | 682 |
return; |
683 |
} |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
684 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
685 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
686 |
if(clusterCount==1) |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
687 |
{//-- we have reached the end of the cluster chain |
0 | 688 |
if(!iMount->IsEndOfClusterCh(ReadFatL(aCluster))) |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
689 |
{//-- seems to be a rugged FAT artefact; File truncation/extension had failed before and now file length is less than |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
690 |
//-- the corresponding cluster chain shall be. It will be truncated to the size recorded in file DOS entry. |
0 | 691 |
iTruncationCluster = aCluster; |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
692 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
693 |
if(CheckDiskMode()) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
694 |
{//-- in check disk mode this is a FS error; Indicate error and abort furter scanning |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
695 |
__PRINT1(_L("CScanDrive::RecordClusterChainL #2 %d"),aCluster); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
696 |
IndicateErrorsFound(EInvalidEntrySize); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
697 |
User::Leave(KErrCorrupt); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
698 |
} |
0 | 699 |
} |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
700 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
701 |
//__PRINT1(_L("#--: %d -> EOC"), aCluster); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
702 |
MarkClusterUsedL(aCluster); |
0 | 703 |
return; |
704 |
} |
|
705 |
else |
|
706 |
{ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
707 |
const TUint clusterVal=ReadFatL(aCluster); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
708 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
709 |
//__PRINT2(_L("#--: %d -> %d"), aCluster, clusterVal); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
710 |
if(IsEofF(clusterVal) || clusterVal == KSpareCluster ) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
711 |
{//-- unexpected end of the cluster chain (it is shorter than recorded in file dir. entry) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
712 |
__PRINT1(_L("CScanDrive::RecordClusterChainL #3 %d"),clusterVal); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
713 |
IndicateErrorsFound(EBadClusterValue); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
714 |
User::Leave(KErrCorrupt); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
715 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
716 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
717 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
718 |
MarkClusterUsedL(aCluster); |
0 | 719 |
aCluster=clusterVal; |
720 |
--clusterCount; |
|
721 |
} |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
722 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
723 |
}//while(clusterCount) |
0 | 724 |
} |
725 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
726 |
//---------------------------------------------------------------------------------------------------- |
0 | 727 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
728 |
Move to dos entry, checking all vfat entry ID numbers are in sequence. |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
729 |
Assumes aEntry is not erased |
0 | 730 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
731 |
@param aPos Position of the entry to move from, returns with new position |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
732 |
@param aEntry The Dos entry after the Vfat entries on return |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
733 |
@param aDirLength Running total of the length of the directory in entries |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
734 |
@leave System wide error codes |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
735 |
@return EFalse if not valid vfat entries or dos entry, else returns ETrue |
0 | 736 |
*/ |
737 |
TBool CScanDrive::MoveToVFatEndL(TEntryPos& aPos,TFatDirEntry& aEntry,TInt& aDirLength) |
|
738 |
{ |
|
739 |
__PRINT2(_L("CScanDrive::MoveToVFatEndL cluster=%d,pos=%d"),aPos.iCluster,aPos.iPos); |
|
740 |
if(!aEntry.IsVFatEntry()) |
|
741 |
return IsDosEntry(aEntry); |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
742 |
|
0 | 743 |
TInt toFollow=aEntry.NumFollowing(); |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
744 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
745 |
if(toFollow <=0 || aEntry.IsErased()) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
746 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
747 |
__PRINT1(_L("CScanDrive::MoveToVFatEndL #1 %d"),toFollow); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
748 |
IndicateErrorsFound(EEntrySetIncomplete); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
749 |
User::Leave(KErrCorrupt); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
750 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
751 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
752 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
753 |
for(;;) |
0 | 754 |
{ |
755 |
MoveToNextEntryL(aPos); |
|
756 |
ReadDirEntryL(aPos,aEntry); |
|
757 |
++aDirLength; |
|
758 |
--toFollow; |
|
759 |
if(!toFollow) |
|
760 |
break; |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
761 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
762 |
if(!IsValidVFatEntry(aEntry,toFollow)) |
0 | 763 |
return(EFalse); |
764 |
} |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
765 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
766 |
return(IsDosEntry(aEntry)); |
0 | 767 |
} |
768 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
769 |
//---------------------------------------------------------------------------------------------------- |
0 | 770 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
771 |
Check if an entry is valid VFat |
0 | 772 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
773 |
@param aEntry Entry to check |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
774 |
@param aPrevNum Number into VFat entries for a dos entry to ensure in correct position |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
775 |
@return ETrue if aEntry is a valid vfat entry |
0 | 776 |
*/ |
777 |
TBool CScanDrive::IsValidVFatEntry(const TFatDirEntry& aEntry,TInt aPrevNum)const |
|
778 |
{ |
|
779 |
if(aEntry.IsErased()||!aEntry.IsVFatEntry()) |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
780 |
return EFalse; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
781 |
|
0 | 782 |
return(aEntry.NumFollowing()==aPrevNum); |
783 |
} |
|
784 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
785 |
//---------------------------------------------------------------------------------------------------- |
0 | 786 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
787 |
Check if an entry is a Dos entry |
0 | 788 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
789 |
@param aEntry Entry to check |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
790 |
@return ETrue if aEntry is a dos entry |
0 | 791 |
*/ |
792 |
TBool CScanDrive::IsDosEntry(const TFatDirEntry& aEntry)const |
|
793 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
794 |
const TBool res = !(aEntry.Attributes()&~KEntryAttMaskSupported) && !aEntry.IsErased() && !aEntry.IsVFatEntry() && !aEntry.IsEndOfDirectory(); |
0 | 795 |
return res; |
796 |
} |
|
797 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
798 |
//---------------------------------------------------------------------------------------------------- |
0 | 799 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
800 |
Add partial entry to iPartEntry under the error condition of not all Vfat entries being present |
0 | 801 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
802 |
@param aStartPos Position of the Dos entry associated with the VFat entries |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
803 |
@param aEntry Directory Entry of the Dos entry associated with the VFat entries |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
804 |
@leave KErrCorrupt Occurs if the entry is not valid |
0 | 805 |
*/ |
806 |
void CScanDrive::AddPartialVFatL(const TEntryPos& aStartPos, const TFatDirEntry& aEntry) |
|
807 |
{ |
|
808 |
__PRINT2(_L("CScanDrive::AddPartialVFatL cluster=%d pos=%d"),aStartPos.iCluster,aStartPos.iPos); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
809 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
810 |
if(IsDirError()) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
811 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
812 |
__PRINT(_L("CScanDrive::AddPartialVFatL #1")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
813 |
User::Leave(KErrCorrupt); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
814 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
815 |
|
0 | 816 |
iPartEntry.iEntryPos=aStartPos; |
817 |
iPartEntry.iEntry=aEntry; |
|
818 |
iDirError=EScanPartEntry; |
|
819 |
} |
|
820 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
821 |
//---------------------------------------------------------------------------------------------------- |
0 | 822 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
823 |
Add entry position to iMatching |
0 | 824 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
825 |
@param aEntryPos Position of the entry with the matching entry |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
826 |
@leave KErrCorrupt if the start cluster is 0 or more that two matching entries occurs |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
827 |
@return |
0 | 828 |
*/ |
829 |
TBool CScanDrive::AddMatchingEntryL(const TEntryPos& aEntryPos) |
|
830 |
{ |
|
831 |
__PRINT2(_L("CScanDrive::AddMatchingEntryL cluster=%d pos=%d"),aEntryPos.iCluster,aEntryPos.iPos); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
832 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
833 |
if(iMatching.iStartCluster <= 0 || iMatching.iCount >= KMaxMatchingEntries) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
834 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
835 |
__PRINT(_L("CScanDrive::AddMatchingEntryL #1")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
836 |
User::Leave(KErrCorrupt); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
837 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
838 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
839 |
|
0 | 840 |
iMatching.iEntries[iMatching.iCount++]=aEntryPos; |
841 |
return iMatching.iCount==KMaxMatchingEntries; |
|
842 |
} |
|
843 |
||
844 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
845 |
//---------------------------------------------------------------------------------------------------- |
0 | 846 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
847 |
Scan for differnces in the new and old FAT table writing them to media if discovered |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
848 |
It is supposed to be called in 'ScanDrive' mode only |
0 | 849 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
850 |
@leave System wide error codes |
0 | 851 |
*/ |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
852 |
void CScanDrive::CompareAndFixFatsL() |
0 | 853 |
{ |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
854 |
__PRINT1(_L("CScanDrive::CompareAndFixFatsL() drv:%d"),iMount->DriveNumber()); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
855 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
856 |
ASSERT(!CheckDiskMode()); |
0 | 857 |
|
858 |
TUint32 nClustersFixed = 0; //-- fixed clusters count |
|
859 |
TUint32 nBadClusters = 0; //-- bad cluster count |
|
860 |
TUint32 dirtyFatSector = 0; //-- FAT table media sector with not-flushed data |
|
861 |
||
862 |
const TUint32 KSectorSzLog2 = iMount->SectorSizeLog2(); //-- Log2(media Sector Size) |
|
863 |
||
864 |
TUint32 diffPos; |
|
865 |
if(iMediaFatBits.Diff(iScanFatBits, diffPos)) |
|
866 |
{//-- there is a difference between FATs' bit representation |
|
867 |
||
868 |
ASSERT(diffPos >= KFatFirstSearchCluster); |
|
869 |
||
870 |
const TUint32 maxClusters = iScanFatBits.Size(); |
|
871 |
||
872 |
for(TUint32 i=diffPos; i<maxClusters; ++i) |
|
873 |
{ |
|
874 |
if(BoolXOR(iMediaFatBits[i], iScanFatBits[i])) |
|
875 |
{//-- difference in the cluster "i" between a real FAT and what ScanDrive restored. |
|
876 |
||
877 |
//-- indicate that there are some problems in FAT. and we probably wrote something there. |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
878 |
IndicateErrorsFound(EScanDriveDirError); |
0 | 879 |
|
880 |
//-- skip BAD cluster, can't mark it as unused. |
|
881 |
if(iMount->IsBadCluster(ReadFatL(i))) |
|
882 |
{ |
|
883 |
++nBadClusters; |
|
884 |
continue; |
|
885 |
} |
|
886 |
||
887 |
//-- here we found a lost cluster. Its FAT entry will be replaced with KSpareCluster. In the case of multiple lost clusters FAT table will |
|
888 |
//-- be flushed on media sector basis. It is much faster than flushing FAT after every write and will |
|
889 |
//-- guarantee that FAT won't be corrupted if the media driver provides atomic sector write. |
|
890 |
if(nClustersFixed == 0) |
|
891 |
{//-- this is the first lost cluster entry we found |
|
892 |
||
893 |
//-- relative FAT media sector for the 'i' entry. The real value doesn't matter, |
|
894 |
//-- we will just be flushing FAT before writing to the different FAT media sector. |
|
895 |
dirtyFatSector = iMount->FAT().PosInBytes(i) >> KSectorSzLog2; |
|
896 |
||
897 |
iMount->FAT().WriteL(i, KSpareCluster); //-- fix lost cluster |
|
898 |
} |
|
899 |
else |
|
900 |
{ |
|
901 |
const TUint32 fatSec = iMount->FAT().PosInBytes(i) >> KSectorSzLog2; |
|
902 |
||
903 |
if(fatSec != dirtyFatSector) |
|
904 |
{//-- we are going to write to a differrent media sector |
|
905 |
iMount->FAT().FlushL(); |
|
906 |
iMount->FAT().WriteL(i, KSpareCluster); //-- fix lost cluster |
|
907 |
dirtyFatSector = fatSec; |
|
908 |
} |
|
909 |
else |
|
910 |
{//-- write to the same FAT media sector without flushing |
|
911 |
iMount->FAT().WriteL(i, KSpareCluster); //-- fix lost cluster |
|
912 |
} |
|
913 |
||
914 |
} |
|
915 |
||
916 |
++nClustersFixed; |
|
917 |
||
918 |
}//if(BoolXOR(iMediaFatBits[i], iScanFatBits[i]) |
|
919 |
||
920 |
}//for(TInt i=KFatFirstSearchCluster; i<maxClusters; ++i) |
|
921 |
||
922 |
}//if(iMediaFatBits.Diff(iScanFatBits, diffPos)) |
|
923 |
||
924 |
||
925 |
if(nClustersFixed) |
|
926 |
iMount->FAT().FlushL(); |
|
927 |
||
928 |
//------ |
|
929 |
||
930 |
if(iTruncationCluster != 0) |
|
931 |
{ |
|
932 |
iMount->FAT().WriteFatEntryEofL(iTruncationCluster); |
|
933 |
iMount->FAT().FlushL(); |
|
934 |
||
935 |
//-- indicate that there are some problems in FAT. and we probably wrote something there. |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
936 |
IndicateErrorsFound(EScanDriveDirError); //-- indicate that we have found errors |
0 | 937 |
|
938 |
++nClustersFixed; |
|
939 |
} |
|
940 |
||
941 |
__PRINT2(_L("CScanDrive::WriteNewFatsL() fixed:%d, bad:%d"), nClustersFixed, nBadClusters); |
|
942 |
} |
|
943 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
944 |
//---------------------------------------------------------------------------------------------------- |
0 | 945 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
946 |
Read the "Rugged FAT" ID, stored in reserved2 in the Dos entry or associated with the Dos entry of the |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
947 |
Entry at the position passed in. This is used to find which version of two matching entries should be kept. |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
948 |
|
0 | 949 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
950 |
@param aVFatPos Position of an entry to read ID from |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
951 |
@leave System wide error codes |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
952 |
@return The ID found in reserved2 field of dos entry |
0 | 953 |
*/ |
954 |
TInt CScanDrive::GetReservedidL(TEntryPos aVFatPos) |
|
955 |
{ |
|
956 |
__PRINT(_L("CScanDrive::GetReservedidL")); |
|
957 |
TFatDirEntry entry; |
|
958 |
ReadDirEntryL(aVFatPos,entry); |
|
959 |
if(!IsDosEntry(entry)) |
|
960 |
{ |
|
961 |
TInt toMove=entry.NumFollowing(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
962 |
|
0 | 963 |
while(toMove--) |
964 |
MoveToNextEntryL(aVFatPos); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
965 |
|
0 | 966 |
ReadDirEntryL(aVFatPos,entry); |
967 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
968 |
|
0 | 969 |
return(entry.RuggedFatEntryId()); |
970 |
} |
|
971 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
972 |
//---------------------------------------------------------------------------------------------------- |
0 | 973 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
974 |
Erase part entry found in iPartEntry |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
975 |
@leave System wide error code |
0 | 976 |
*/ |
977 |
void CScanDrive::FixPartEntryL() |
|
978 |
{ |
|
979 |
__PRINT2(_L("CScanDrive::FixPartEntryL cluster=%d,pos=%d"),iPartEntry.iEntryPos.iCluster,iPartEntry.iEntryPos.iPos); |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
980 |
ASSERT(!CheckDiskMode()); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
981 |
iMount->EraseDirEntryL(iPartEntry.iEntryPos,iPartEntry.iEntry); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
982 |
IndicateErrorsFound(EScanDriveDirError); //-- indicate that we have found errors |
0 | 983 |
} |
984 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
985 |
//---------------------------------------------------------------------------------------------------- |
0 | 986 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
987 |
Delete entry with largest value in the reserved2 section(bytes 20 and 21) of dos entry |
0 | 988 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
989 |
@leave System wide error code |
0 | 990 |
*/ |
991 |
void CScanDrive::FixMatchingEntryL() |
|
992 |
{ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
993 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
994 |
__PRINT1(_L("CScanDrive::FixMatchingEntryL() start cluster=%d"),iMatching.iStartCluster); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
995 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
996 |
if(iMatching.iCount != KMaxMatchingEntries) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
997 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
998 |
__PRINT1(_L("CScanDrive::FixMatchingEntryL() #1 %d"), iMatching.iCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
999 |
User::Leave(KErrCorrupt); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1000 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1001 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1002 |
ASSERT(!CheckDiskMode()); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1003 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1004 |
const TInt idOne=GetReservedidL(iMatching.iEntries[0]); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1005 |
const TInt idTwo=GetReservedidL(iMatching.iEntries[1]); |
0 | 1006 |
TFatDirEntry entry; |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1007 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1008 |
const TInt num = idOne>idTwo ? 0:1; |
0 | 1009 |
ReadDirEntryL(iMatching.iEntries[num],entry); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1010 |
|
0 | 1011 |
iMount->EraseDirEntryL(iMatching.iEntries[num],entry); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1012 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1013 |
IndicateErrorsFound(EScanDriveDirError); //-- indicate that we have found errors |
0 | 1014 |
} |
1015 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1016 |
//---------------------------------------------------------------------------------------------------- |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1017 |
/** |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1018 |
Move past specified number of entries |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1019 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1020 |
@param aEntryPos Start position to move from, updated as move takes place |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1021 |
@param aEntry Directory entry moved to |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1022 |
@param aToMove Number of entries to move through |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1023 |
@param aDirEntries Number of entries moved, updated as move takes place |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1024 |
@leave System wide error code |
0 | 1025 |
*/ |
1026 |
void CScanDrive::MovePastEntriesL(TEntryPos& aEntryPos,TFatDirEntry& aEntry,TInt aToMove,TInt& aDirEntries) |
|
1027 |
{ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1028 |
while(aToMove-- && !IsEofF(aEntryPos.iCluster)) |
0 | 1029 |
{ |
1030 |
MoveToNextEntryL(aEntryPos); |
|
1031 |
++aDirEntries; |
|
1032 |
} |
|
1033 |
ReadDirEntryL(aEntryPos,aEntry); |
|
1034 |
} |
|
1035 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1036 |
//---------------------------------------------------------------------------------------------------- |
0 | 1037 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1038 |
Adds aCluster to cluster list array so that it may be revisited later, avoids stack |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1039 |
over flow |
0 | 1040 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1041 |
@param aCluster Directory cluster number to add to the list |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1042 |
@leave KErrNoMemory If allocation fails |
0 | 1043 |
*/ |
1044 |
void CScanDrive::AddToClusterListL(TInt aCluster) |
|
1045 |
{ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1046 |
|
0 | 1047 |
if(iListArrayIndex>=KMaxArrayDepth) |
1048 |
return; |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1049 |
|
0 | 1050 |
if(iClusterListArray[iListArrayIndex]==NULL) |
1051 |
iClusterListArray[iListArrayIndex]=new(ELeave) RArray<TInt>(KClusterListGranularity); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1052 |
|
0 | 1053 |
iClusterListArray[iListArrayIndex]->Append(aCluster); |
1054 |
} |
|
1055 |
||
1056 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1057 |
//---------------------------------------------------------------------------------------------------- |
0 | 1058 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1059 |
Used in "CheckDisk" mode mostly. Compares first FAT table on the media with the FAT bitmap restored by walking the directory structure. |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1060 |
Displays any differences and records an error if found. |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1061 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1062 |
@param aStopOnFirstErrorFound if ETrue will stop after discovering first error (FATs discrepancy) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1063 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1064 |
@leave System wide error codes |
0 | 1065 |
*/ |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1066 |
void CScanDrive::CompareFatsL(TBool aStopOnFirstErrorFound) |
0 | 1067 |
{ |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1068 |
__PRINT1(_L("CScanDrive::CompareFatsL(%d)"), aStopOnFirstErrorFound); |
0 | 1069 |
|
1070 |
||
1071 |
TUint32 diffPos; |
|
1072 |
if(!iMediaFatBits.Diff(iScanFatBits, diffPos)) |
|
1073 |
return; //-- FATs are identical |
|
1074 |
||
1075 |
//-- there is a difference between the real FAT and reconstructed one. Find the mismaching bit and fix FAT. |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1076 |
const TUint clusters = iMount->UsableClusters(); |
0 | 1077 |
ASSERT(diffPos < (TUint32)clusters); |
1078 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1079 |
TUint scanusedcnt=0; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1080 |
TUint mediausedcnt=0; |
0 | 1081 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1082 |
for(TUint i=diffPos; i<clusters; ++i) |
0 | 1083 |
{ |
1084 |
const TBool bRealFatEntry = iMediaFatBits[i]; |
|
1085 |
const TBool bNewFatEntry = iScanFatBits[i]; |
|
1086 |
||
1087 |
if(BoolXOR(bRealFatEntry, bNewFatEntry)) |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1088 |
{//-- mismatch between FAT on the media and the FAT bitmap restored by walking directory structure |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1089 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1090 |
if(bRealFatEntry) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1091 |
{//-- FAT[i] on the media is marked as occupied, but retored FAT bitmap shows that it is free |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1092 |
if(iMount->IsBadCluster(ReadFatL(i))) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1093 |
continue; //-- this is a BAD cluster it can't be occupied by the FS object, OK. |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1094 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1095 |
__PRINT2(_L("FAT[%d] = %d\n"), i, ReadFatL(i)); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1096 |
__PRINT1(_L("iTruncationCluster = %d\n"), iTruncationCluster); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1097 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1098 |
//-- this is a lost cluster |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1099 |
if(!IsEofF(ReadFatL(i)) && (i==iTruncationCluster)) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1100 |
{//-- seems to be a Rugged FAT ertefact |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1101 |
__PRINT1(_L("Hanging cluster = %d\n"),i); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1102 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1103 |
else |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1104 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1105 |
__PRINT1(_L("Lost cluster=%d\n"),i); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1106 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1107 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1108 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1109 |
IndicateErrorsFound(EBadClusterValue); |
0 | 1110 |
} |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1111 |
else |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1112 |
{//-- FAT[i] on the media is marked as free, but retored FAT bitmap shows that it is occupied by some object |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1113 |
IndicateErrorsFound(EClusterAlreadyInUse); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1114 |
__PRINT1(_L("Unflushed cluster = %d\n"),i); |
0 | 1115 |
} |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1116 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1117 |
if(aStopOnFirstErrorFound) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1118 |
break; //-- not asked to check for errors further |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1119 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1120 |
} |
0 | 1121 |
|
1122 |
if(bRealFatEntry) |
|
1123 |
mediausedcnt++; |
|
1124 |
||
1125 |
if(bNewFatEntry) |
|
1126 |
scanusedcnt++; |
|
1127 |
} |
|
1128 |
||
1129 |
__PRINT2(_L("Scan Fat Used=%d, Media Fat Used=%d \n"),scanusedcnt,mediausedcnt); |
|
1130 |
} |
|
1131 |
||
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1132 |
//---------------------------------------------------------------------------------------------------- |
0 | 1133 |
/** |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1134 |
For debug purposes, print errors found as debug output |
0 | 1135 |
*/ |
1136 |
void CScanDrive::PrintErrors() |
|
1137 |
{ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1138 |
#if defined(_DEBUG) |
0 | 1139 |
__PRINT1(_L("Directories visisted = %d\n"),iDirsChecked); |
1140 |
||
1141 |
if(iDirError==EScanPartEntry) |
|
1142 |
{ |
|
1143 |
__PRINT2(_L("Part entry-dir cluster=%d,dir pos=%d,\n"),iPartEntry.iEntryPos.iCluster,iPartEntry.iEntryPos.iPos); |
|
1144 |
} |
|
1145 |
else if(iDirError==EScanMatchingEntry) |
|
1146 |
{ |
|
1147 |
__PRINT1(_L("Matching cluster - cluster no=%d\n"),iMatching.iStartCluster); |
|
1148 |
__PRINT2(_L("\tcluster 1 - dir cluster=%d,dir pos=%d\n"),iMatching.iEntries[0].iCluster,iMatching.iEntries[0].iPos); |
|
1149 |
__PRINT2(_L("\tcluster 2 - dir cluster=%d,dir pos=%d\n"),iMatching.iEntries[1].iCluster,iMatching.iEntries[1].iPos); |
|
1150 |
} |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1151 |
#endif |
0 | 1152 |
} |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1153 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1154 |
|
0 | 1155 |
|
1156 |
/** |
|
1157 |
Read a FAT directory entry from disk, either reads directly from the main cache or |
|
1158 |
from the cluster buffer if scan drive is running in a seperate thread. |
|
1159 |
||
1160 |
@param aPos Media position of entry to read |
|
1161 |
@param aDirEntry Contents of directory entry read |
|
1162 |
@leave System wide error code |
|
1163 |
*/ |
|
1164 |
void CScanDrive::ReadDirEntryL(const TEntryPos& aPos,TFatDirEntry& aDirEntry) |
|
1165 |
{ |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1166 |
//__PRINT(_L("CScanDrive::ReadDirEntryL")); |
0 | 1167 |
if (iMount->IsEndOfClusterCh(aPos.iCluster)) |
1168 |
{ |
|
1169 |
Mem::FillZ(&aDirEntry,sizeof(TFatDirEntry)); |
|
1170 |
return; |
|
1171 |
} |
|
1172 |
||
1173 |
iMount->ReadDirEntryL(aPos, aDirEntry); |
|
1174 |
} |
|
1175 |
||
1176 |
||
1177 |
/** |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1178 |
Move to next directory entry, if anEntry is at the end of the cluster, and we are not |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1179 |
the root dir, move it to the next cluster in the chain. |
0 | 1180 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1181 |
@param aPos Current directory position up dated to position of next entry. |
0 | 1182 |
*/ |
1183 |
void CScanDrive::MoveToNextEntryL(TEntryPos& aPos) |
|
1184 |
{ |
|
1185 |
//__PRINT(_L("CScanDrive::MoveToNextEntryL")); |
|
1186 |
iMount->MoveToNextEntryL(aPos); |
|
1187 |
} |
|
1188 |
||
1189 |
/** |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1190 |
Read a cluster from the Media Fat if scan run in a seperate thread read from scan fat table |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1191 |
otherwise read from mount owned Fat table |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1192 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1193 |
@param aClusterNum Cluster to read |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1194 |
@return Value of cluster read from Fat |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1195 |
*/ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1196 |
TUint32 CScanDrive::ReadFatL(TUint aClusterNum) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1197 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1198 |
if(aClusterNum < KFatFirstSearchCluster || aClusterNum >= MaxClusters()) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1199 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1200 |
__PRINT1(_L("CScanDrive::ReadFatL() bad cluster:%d\n"),aClusterNum); |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1201 |
IndicateErrorsFound(EBadClusterNumber); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1202 |
User::Leave(KErrCorrupt); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1203 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1204 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1205 |
//-- actually, ReadL() can leave with some error code, that won't be reflected in IndicateErrorsFound(). |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1206 |
//-- it's possible to improve but is it worth it? |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1207 |
return iMount->FAT().ReadL(aClusterNum); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1208 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1209 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1210 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1211 |
/** |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1212 |
Set a cluster as visited in the bit packed scan Fat |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1213 |
@param aCluster Cluster number |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1214 |
*/ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1215 |
void CScanDrive::MarkClusterUsedL(TUint aClusterNum) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1216 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1217 |
if(aClusterNum < KFatFirstSearchCluster || aClusterNum >= MaxClusters()) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1218 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1219 |
__PRINT1(_L("CScanDrive::MarkClusterUsedL() bad cluster:%d\n"),aClusterNum); |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1220 |
IndicateErrorsFound(EBadClusterNumber); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1221 |
User::Leave(KErrCorrupt); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1222 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1223 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1224 |
iScanFatBits.SetBit(aClusterNum); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1225 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1226 |
|
0 | 1227 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1228 |
/** |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1229 |
Query whether a cluster is already set as used |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1230 |
@param aCluster Cluster to query |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1231 |
*/ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1232 |
TBool CScanDrive::IsClusterUsedL(TUint aClusterNum) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1233 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1234 |
if(aClusterNum < KFatFirstSearchCluster || aClusterNum >= MaxClusters()) |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1235 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1236 |
__PRINT1(_L("CScanDrive::IsClusterUsedL() bad cluster:%d\n"),aClusterNum); |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1237 |
IndicateErrorsFound(EBadClusterNumber); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1238 |
User::Leave(KErrCorrupt); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1239 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1240 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1241 |
return iScanFatBits[aClusterNum]; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1242 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1243 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1244 |
/** |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1245 |
@param aPos Position in a directory cluster |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1246 |
@return ETrue if aPos is the last entry in the root directory |
0 | 1247 |
*/ |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1248 |
TBool CScanDrive::IsEndOfRootDir(const TEntryPos& aPos)const |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1249 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1250 |
return(iMount->IsRootDir(aPos)&&(iMount->StartOfRootDirInBytes()+aPos.iPos==(iMount->RootDirEnd()-KSizeOfFatDirEntry))); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1251 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1252 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1253 |
/** |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1254 |
@param aVal Value of the cluster to be tested |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1255 |
@return ETrue if aVal is the end of cluster marker |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1256 |
*/ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1257 |
TBool CScanDrive::IsEofF(TInt aVal) const |
0 | 1258 |
{ |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1259 |
return iMount->IsEndOfClusterCh(aVal); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1260 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1261 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1262 |
/** @return max. number of clusters on the volume being scanned */ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1263 |
TUint32 CScanDrive::MaxClusters() const |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1264 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1265 |
ASSERT(iMaxClusters); |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1266 |
return iMaxClusters; |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1267 |
} |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1268 |
|
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1269 |
/** @return ETrue in we are operating in "CheckDisk" mode*/ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1270 |
TBool CScanDrive::CheckDiskMode() const |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1271 |
{ |
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
1272 |
return iScanDriveMode == ECheckDisk; |
0 | 1273 |
} |
1274 |
||
1275 |
||
1276 |
||
1277 |
||
1278 |
||
1279 |
||
1280 |
||
1281 |
||
1282 |