author | William Roberts <williamr@symbian.org> |
Mon, 19 Jul 2010 15:53:40 +0100 | |
changeset 213 | cd1a471fd308 |
parent 152 | 657f875b013e |
child 257 | 3e88ff8f41d5 |
child 299 | b5a01337d018 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1995-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 |
// |
|
15 |
||
16 |
#include "sf_std.h" |
|
17 |
||
152
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
18 |
#ifdef OST_TRACE_COMPILER_IN_USE |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
19 |
#include "sf_mntTraces.h" |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
20 |
#endif |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
21 |
|
0 | 22 |
|
23 |
||
24 |
||
25 |
/** |
|
26 |
Default constructor. |
|
27 |
*/ |
|
28 |
EXPORT_C CMountCB::CMountCB() |
|
29 |
:iMountQ(_FOFF(CFileCB,iMountLink)) |
|
30 |
{ |
|
31 |
__PRINT1(_L("CMountCB::CMountCB()[0x%x]"),this); |
|
32 |
} |
|
33 |
||
34 |
||
35 |
||
36 |
||
37 |
EXPORT_C CMountCB::~CMountCB() |
|
38 |
{ |
|
39 |
__PRINT1(_L("CMountCB::~CMountCB()[0x%x]"),this); |
|
40 |
delete iBody; |
|
41 |
delete iVolumeName; |
|
42 |
} |
|
43 |
||
44 |
||
45 |
//----------------------------------------------------------------------------- |
|
46 |
||
47 |
/** |
|
48 |
Compares the specified mount control block with this one for inequality. |
|
49 |
||
50 |
Two mount control blocks are different if either the addresses of |
|
51 |
the mount control blocks ar different, or their iMountNumber values |
|
52 |
are different. |
|
53 |
||
54 |
@param aMount The mount control block to be compared. |
|
55 |
||
56 |
@return True, if the mount control blocks are different, false otherwise. |
|
57 |
*/ |
|
58 |
EXPORT_C TBool CMountCB::operator!=(const CMountCB& aMount) const |
|
59 |
{ |
|
60 |
||
61 |
if (this==(&aMount) && MountNumber()==aMount.MountNumber()) |
|
62 |
return(FALSE); |
|
63 |
return(TRUE); |
|
64 |
} |
|
65 |
||
66 |
||
67 |
//----------------------------------------------------------------------------- |
|
68 |
||
69 |
/** |
|
70 |
Tests whether the given attribute mask matches given criteria (specified |
|
71 |
in another mask). |
|
72 |
||
73 |
This function is used when filtering entries. aMatt specifies the criteria |
|
74 |
to be matched by anAtt. |
|
75 |
||
76 |
Volumes are ignored, so if anAtt has the volume attribute set then |
|
77 |
the function returns false. |
|
78 |
||
79 |
If aMatt does not have a hidden (KEntryAttHidden), system (KEntryAttSystem), |
|
80 |
or directory (KEntryAttDir) attribute set and anAtt does have |
|
81 |
the corresponding attribute set, then the function returns false. |
|
82 |
Alternatively, if aMatt has KEntryAttMustBeFile set and anAtt has |
|
83 |
the directory attribute set, then the function also returns EFalse. |
|
84 |
||
85 |
Further matching behaviour can be implemented using |
|
86 |
KEntryAttMatchExclusive and KEntryAttMatchExclude. |
|
87 |
||
88 |
@param anAtt Attribute mask to be tested. |
|
89 |
@param aMatt The attribute match mask. |
|
90 |
||
91 |
@return True, if the anAtt entry attributes match, false otherwise. |
|
92 |
||
93 |
@see KEntryAttHidden |
|
94 |
@see KEntryAttSystem |
|
95 |
@see KEntryAttDir |
|
96 |
@see KEntryAttMustBeFile |
|
97 |
@see KEntryAttMatchExclusive |
|
98 |
@see KEntryAttMatchExclude |
|
99 |
*/ |
|
100 |
EXPORT_C TBool CMountCB::MatchEntryAtt(TUint anAtt,TUint aMatt) const |
|
101 |
{ |
|
102 |
if (aMatt&KEntryAttMatchExclude) |
|
103 |
{ // Include any except |
|
104 |
if ((anAtt&aMatt)==0) |
|
105 |
return(ETrue); |
|
106 |
return(EFalse); |
|
107 |
} |
|
108 |
||
109 |
anAtt&=KEntryAttMaskSupported; |
|
110 |
if ((aMatt&KEntryAttMustBeFile) && (anAtt&KEntryAttIllegal)) |
|
111 |
return(EFalse); // Not a file |
|
112 |
||
113 |
if ((aMatt&KEntryAttHidden)==0 && (anAtt&KEntryAttHidden)) |
|
114 |
return(EFalse); // Ignore hidden unless requested |
|
115 |
if ((aMatt&KEntryAttSystem)==0 && (anAtt&KEntryAttSystem)) |
|
116 |
return(EFalse); // Ignore system unless requested |
|
117 |
if ((aMatt&KEntryAttDir)==0 && (anAtt&KEntryAttDir)) |
|
118 |
return(EFalse); // Ignore directory unless requested |
|
119 |
if (anAtt&KEntryAttVolume) |
|
120 |
return(EFalse); // Ignore volumes |
|
121 |
||
122 |
anAtt&=(~(KEntryAttHidden|KEntryAttSystem)); // remove hidden and system |
|
123 |
||
124 |
if (aMatt&KEntryAttMatchExclusive) |
|
125 |
{ // Exclude all except |
|
126 |
if ((anAtt&aMatt)!=0) |
|
127 |
return(ETrue); |
|
128 |
return(EFalse); |
|
129 |
} |
|
130 |
return(ETrue); |
|
131 |
} |
|
132 |
||
133 |
||
134 |
||
135 |
//----------------------------------------------------------------------------- |
|
136 |
/** |
|
137 |
Gets the address of the specified file if it is found in ROM. |
|
138 |
||
139 |
The default implementation sets aFileStart to NULL, and this should only |
|
140 |
be overridden by ROM file systems. |
|
141 |
||
142 |
@param aFileName A reference to a descriptor containing the full file name. |
|
143 |
@param aFileStart On return, the address of the file, aFileName. |
|
144 |
The default implementation returns NULL. |
|
145 |
*/ |
|
146 |
EXPORT_C void CMountCB::IsFileInRom(const TDesC& /*aFileName*/,TUint8*& aFileStart) |
|
147 |
{ |
|
148 |
||
149 |
aFileStart=NULL; |
|
150 |
} |
|
151 |
||
152 |
||
153 |
//----------------------------------------------------------------------------- |
|
154 |
||
155 |
/** |
|
156 |
Notifies the file server that the free disk space of the mounted volume |
|
157 |
has changed outside of the standard file system operations. |
|
158 |
||
159 |
For example, the background thread of the log flash file system will call |
|
160 |
this function after a background roll-forward. |
|
161 |
||
162 |
@param aFreeSpace New free disk space value. |
|
163 |
*/ |
|
164 |
EXPORT_C void CMountCB::SetDiskSpaceChange(TInt64 aFreeSpace) |
|
165 |
{ |
|
166 |
const TInt drv=Drive().DriveNumber(); |
|
167 |
__ASSERT_ALWAYS(aFreeSpace>=0,Fault(ESvrFreeDiskSpace)); |
|
168 |
__PRINT3(_L("CMountCB::SetDiskSpaceChange(%LU) drv:%d, %dKB"), aFreeSpace, drv, (TUint32)(aFreeSpace>>10)); |
|
169 |
||
170 |
// Notifying involves memory de-allocation on the file server's heap - |
|
171 |
// check if we need to switch heaps. |
|
172 |
RAllocator* current_alloc = &User::Heap(); |
|
173 |
RAllocator* svr_alloc = ServerThreadAllocator; |
|
174 |
if (current_alloc != svr_alloc) |
|
175 |
User::SwitchHeap(svr_alloc); |
|
176 |
||
177 |
FsNotify::HandleDiskSpace(drv, aFreeSpace); |
|
178 |
||
179 |
if (current_alloc != svr_alloc) |
|
180 |
User::SwitchHeap(current_alloc); |
|
181 |
} |
|
182 |
||
183 |
//----------------------------------------------------------------------------- |
|
184 |
/** |
|
185 |
Initialize the MountCB object. |
|
186 |
||
187 |
@param aDrive TDrive object that will be used by the mount for drive access |
|
188 |
@param apFileSystem pointer to the File System object that has produced this CMountCB |
|
189 |
*/ |
|
190 |
EXPORT_C void CMountCB::InitL(TDrive& aDrive, CFileSystem* apFileSystem) |
|
191 |
{ |
|
192 |
__PRINT3(_L("CMountCB::InitL()[0x%x] drv:%d, FS:0x%x"), this, aDrive.DriveNumber(), apFileSystem); |
|
193 |
ASSERT(apFileSystem); |
|
194 |
||
195 |
||
196 |
SetDrive(&aDrive); |
|
197 |
DoInitL(aDrive.DriveNumber()); |
|
198 |
||
199 |
// see whether the file system supports the CFileCB extended API |
|
200 |
MFileAccessor* fileAccessor = NULL; |
|
201 |
||
202 |
GetInterfaceTraced(CMountCB::EFileAccessor, (void*&) fileAccessor, NULL); |
|
203 |
||
204 |
MFileExtendedInterface* fileExtInterface = NULL; |
|
205 |
GetInterface(CMountCB::EFileExtendedInterface, (void*&) fileExtInterface, NULL); |
|
206 |
||
207 |
if(!iBody) |
|
208 |
{ |
|
209 |
iBody = new(ELeave)CMountBody(this, fileAccessor, fileExtInterface); |
|
210 |
} |
|
211 |
else |
|
212 |
{ |
|
213 |
//-- some file systems can call this method several times for the same mount. |
|
214 |
//-- composite FS, for example. |
|
215 |
__PRINT1(_L("CMountCB::InitL !!re-initialisation!! iBody:0x%x"), iBody); |
|
216 |
} |
|
217 |
||
218 |
SetFileSystem(apFileSystem); //-- associate MountCB object with the file system it belongs to; this relies on iBody |
|
219 |
} |
|
220 |
||
221 |
/** |
|
222 |
Reports whether the specified interface is supported - if it is, |
|
223 |
the a supplied interface object is modified to it |
|
224 |
||
225 |
@param aInterfaceId The interface of interest |
|
226 |
@param aInterface The interface object |
|
227 |
@return KErrNone if the interface is supported, otherwise KErrNotFound |
|
228 |
*/ |
|
229 |
EXPORT_C TInt CMountCB::GetInterface(TInt /*aInterfaceId*/,TAny*& /*aInterface*/,TAny* /*aInput*/) |
|
230 |
{ |
|
231 |
return(KErrNotSupported); |
|
232 |
} |
|
233 |
||
234 |
/** |
|
235 |
Creates a clamp for the named file, and provides clamp handle data to the caller. |
|
236 |
||
237 |
@param aDriveNo The number of the drive on which the file can be found |
|
238 |
@param aName Name of the file to clamp |
|
239 |
@param aHandle Pointer to the clamp handle data |
|
240 |
@return KErrNone if successful, otherwise one of the systme-wide eror codes. |
|
241 |
*/ |
|
242 |
TInt CMountCB::ClampFile(const TInt aDriveNo, const TDesC& aName, TAny* aHandle) |
|
243 |
{ |
|
244 |
return(iBody?iBody->ClampFile(aDriveNo,aName,aHandle):KErrNotSupported); |
|
245 |
}; |
|
246 |
||
247 |
/** |
|
248 |
Reports whether the named file is clamped. |
|
249 |
||
250 |
@param aName Name of the file to clamp |
|
251 |
@return 0 if the file is not clamped, 1 if it is, or a system-wide error code. |
|
252 |
*/ |
|
253 |
EXPORT_C TInt CMountCB::IsFileClamped(/*const TDesC& aName,*/ const TInt64 aUniqueId) |
|
254 |
{ |
|
255 |
return(iBody?iBody->IsFileClamped(aUniqueId):KErrNotSupported); |
|
256 |
}; |
|
257 |
||
258 |
/** |
|
259 |
Removes the clamp indicated by the specified handle. |
|
260 |
If this was the last clamp for the drive, any pending dismount is performed. |
|
261 |
||
262 |
@param aHandle Pointer to the clamp handle data |
|
263 |
@return KErrNone if successful, a system-wide error code otherwise |
|
264 |
*/ |
|
265 |
TInt CMountCB::UnclampFile(RFileClamp* aHandle) |
|
266 |
{ |
|
267 |
return(iBody?iBody->UnclampFile(aHandle):KErrNotSupported); |
|
268 |
}; |
|
269 |
||
270 |
/** |
|
271 |
Returns the current number of clamps |
|
272 |
||
273 |
@return the number of clamps |
|
274 |
*/ |
|
275 |
TInt CMountCB::NoOfClamps() |
|
276 |
{ |
|
277 |
return(iBody?iBody->NoOfClamps():KErrNotSupported); |
|
278 |
} |
|
279 |
||
280 |
||
281 |
||
282 |
||
283 |
/** |
|
284 |
Gets the sub type name of mounted file system (e.g. FAT12, FAT16 or FAT32 of Fat file system). |
|
285 |
Uses GetInterface() API to avoid binary compatibility break while providing polymorphism. |
|
286 |
The real implementations is done by classes multiple inherited from both CMountCB and |
|
287 |
MFileSystemSubType that have implemented MFileSystemSubType::SubType() virtual function. |
|
288 |
File system that do not support sub types will have KErrNotSupported returned. |
|
289 |
||
290 |
@param aSubTypeName A descriptor contains return of the sub type name. |
|
291 |
@return KErrNone if successful; otherwise another of the system wide error codes; |
|
292 |
KErrNotSupported if sub type is not supported by mounted file system; |
|
293 |
||
294 |
@see MFileSystemSubType::SubType() |
|
295 |
*/ |
|
296 |
TInt CMountCB::FileSystemSubType(TDes& aName) |
|
297 |
{ |
|
298 |
MFileSystemSubType* interface = NULL; |
|
299 |
TAny* dummy = NULL; |
|
300 |
TInt rel = GetInterfaceTraced(EGetFileSystemSubType, (TAny*&)(interface), dummy); |
|
301 |
if((interface != NULL) && (rel == KErrNone)) |
|
302 |
{ |
|
303 |
rel = interface->SubType(aName); |
|
304 |
} |
|
305 |
||
306 |
return rel; |
|
307 |
} |
|
308 |
||
309 |
/** |
|
310 |
Gets the cluster size of mounted file system. |
|
311 |
Uses GetInterface() API to avoid binary compatibility break while providing polymorphism. |
|
312 |
The real implementation is done by classes multiple inherited from both CMountCB and |
|
313 |
MFileSystemClusterSize that have implemented MFileSystemClusterSize::ClusterSize() function. |
|
314 |
File system that do not support concept of 'clusters' will have the default KErrNotSupported returned. |
|
315 |
||
316 |
@return Cluster size value if successful; otherwise another of the system wide error codes; |
|
317 |
KErrNotSupported if cluster is not supported by mounted file system; |
|
318 |
||
319 |
@see MFileSystemClusterSize::ClusterSize() |
|
320 |
*/ |
|
321 |
TInt CMountCB::FileSystemClusterSize() |
|
322 |
{ |
|
323 |
MFileSystemClusterSize* interface = NULL; |
|
324 |
TAny* dummy = NULL; |
|
325 |
TInt rel = GetInterfaceTraced(EGetClusterSize, (TAny*&)(interface), dummy); |
|
326 |
if((interface != NULL) && (rel == KErrNone)) |
|
327 |
{ |
|
328 |
rel = interface->ClusterSize(); |
|
329 |
} |
|
330 |
||
331 |
return rel; |
|
332 |
} |
|
333 |
||
334 |
||
335 |
/** |
|
336 |
@prototype |
|
337 |
||
338 |
Reads a specified section of the file, regardless of the file's lock state. |
|
339 |
||
340 |
Uses GetInterface() API to avoid binary compatibility break while providing polymorphism. |
|
341 |
The real implementation is done by classes multiple inherited from both CMountCB and |
|
342 |
MFileSystemExtendedInterface that have implemented MFileSystemExtendedInterface::ExtendedReadSectionL() function. |
|
343 |
File system that do not support large file will implement the default CMountCB::ReadSectionL() function. |
|
344 |
||
345 |
@see CMountCB::ReadSectionL() |
|
346 |
||
347 |
@see MFileSystemExtendedInterface::ExtendedReadSectionL() |
|
348 |
*/ |
|
349 |
void CMountCB::ReadSection64L(const TDesC& aName,TInt64 aPos,TAny* aTrg,TInt aLength,const RMessagePtr2& aMessage) |
|
350 |
{ |
|
351 |
iBody->iFileExtendedInterface->ReadSection64L(aName, aPos, aTrg, aLength, aMessage); |
|
352 |
} |
|
353 |
||
354 |
TInt CMountCB::GetFileUniqueId(const TDesC& aName, TInt64& aUniqueId) |
|
355 |
{ |
|
356 |
return (iBody->iFileAccessor->GetFileUniqueId(aName, aUniqueId)); |
|
357 |
} |
|
358 |
||
359 |
TInt CMountCB::Spare3(TInt aVal, TAny* aPtr1, TAny* aPtr2) |
|
360 |
{ |
|
361 |
return (iBody->iFileAccessor->Spare3(aVal, aPtr1, aPtr2)); |
|
362 |
} |
|
363 |
||
364 |
TInt CMountCB::Spare2(TInt aVal, TAny* aPtr1, TAny* aPtr2) |
|
365 |
{ |
|
366 |
return (iBody->iFileAccessor->Spare2(aVal, aPtr1, aPtr2)); |
|
367 |
} |
|
368 |
||
369 |
TInt CMountCB::Spare1(TInt aVal, TAny* aPtr1, TAny* aPtr2) |
|
370 |
{ |
|
371 |
return (iBody->iFileAccessor->Spare1(aVal, aPtr1, aPtr2)); |
|
372 |
} |
|
373 |
||
374 |
TInt CMountCB::GetInterfaceTraced(TInt aInterfaceId, TAny*& aInterface, TAny* aInput) |
|
375 |
{ |
|
152
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
376 |
OstTraceExt3(TRACE_FILESYSTEM, FSYS_ECMOUNTCBGETINTERFACE, "drive %d aInterfaceId %d aInput %x", (TUint) DriveNumber(), (TUint) aInterfaceId, (TUint) aInput); |
0 | 377 |
|
378 |
TInt r = GetInterface(aInterfaceId, aInterface, aInput); |
|
379 |
||
152
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
380 |
OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECMOUNTCBGETINTERFACERET, "r %d aInterface %x", (TUint) r, (TUint) aInterface); |
0 | 381 |
|
382 |
return r; |
|
383 |
} |
|
384 |
||
385 |
//----------------------------------------------------------------------------- |
|
386 |
/** |
|
387 |
Get the file system name. I.e. The name of the file system that produced this object of CMountCB |
|
388 |
@param aName buffer for the name |
|
389 |
*/ |
|
390 |
void CMountCB::FileSystemName(TDes& aName) |
|
391 |
{ |
|
392 |
aName = FileSystem()->Name(); |
|
393 |
} |
|
394 |
||
395 |
||
396 |
||
397 |
//----------------------------------------------------------------------------- |
|
398 |
/** |
|
399 |
Associate CFileSystem object (the factory) and the produced CMountCB object. |
|
400 |
@param aFS pointer to the file system that produced this mount. |
|
401 |
*/ |
|
402 |
void CMountCB::SetFileSystem(CFileSystem* aFS) |
|
403 |
{ |
|
404 |
ASSERT(iBody); |
|
405 |
iBody->SetFileSystem(aFS); |
|
406 |
} |
|
407 |
||
408 |
/** |
|
409 |
Get reference to the filesystem, associated with this mount. |
|
410 |
*/ |
|
411 |
EXPORT_C CFileSystem* CMountCB::FileSystem() const |
|
412 |
{ |
|
413 |
ASSERT(iBody); |
|
414 |
CFileSystem* pFSys = iBody->GetFileSystem(); |
|
415 |
ASSERT(pFSys); |
|
416 |
return pFSys; |
|
417 |
} |
|
418 |
||
419 |
void CMountCB::SetProxyDriveDismounted() |
|
420 |
{ |
|
421 |
iBody->SetProxyDriveDismounted(); |
|
422 |
} |
|
423 |
||
424 |
TBool CMountCB::ProxyDriveDismounted() |
|
425 |
{ |
|
426 |
return iBody->ProxyDriveDismounted(); |
|
427 |
} |
|
428 |
||
429 |
||
430 |
/** |
|
431 |
Factory method. Produces CFileCB object. |
|
432 |
*/ |
|
433 |
CFileCB* CMountCB::NewFileL() const |
|
434 |
{ |
|
435 |
return FileSystem()->NewFileL(); |
|
436 |
} |
|
437 |
||
438 |
/** |
|
439 |
Factory method. Produces CDirCB object. |
|
440 |
*/ |
|
441 |
CDirCB* CMountCB::NewDirL() const |
|
442 |
{ |
|
443 |
return FileSystem()->NewDirL(); |
|
444 |
} |
|
445 |
||
446 |
||
447 |
/** |
|
448 |
Factory method. Produces CFormatCB object. |
|
449 |
*/ |
|
450 |
CFormatCB* CMountCB::NewFormatL() const |
|
451 |
{ |
|
452 |
return FileSystem()->NewFormatL(); |
|
453 |
} |
|
454 |
||
455 |
||
456 |
||
457 |
||
458 |
||
459 |
||
460 |
||
461 |
||
462 |
||
463 |
||
464 |
||
465 |
||
466 |
||
467 |
||
468 |
||
469 |