Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
24 EXPORT_C CMountCB::CMountCB()
25 :iMountQ(_FOFF(CFileCB,iMountLink))
27 __PRINT1(_L("CMountCB::CMountCB()[0x%x]"),this);
33 EXPORT_C CMountCB::~CMountCB()
35 __PRINT1(_L("CMountCB::~CMountCB()[0x%x]"),this);
41 //-----------------------------------------------------------------------------
44 Compares the specified mount control block with this one for inequality.
46 Two mount control blocks are different if either the addresses of
47 the mount control blocks ar different, or their iMountNumber values
50 @param aMount The mount control block to be compared.
52 @return True, if the mount control blocks are different, false otherwise.
54 EXPORT_C TBool CMountCB::operator!=(const CMountCB& aMount) const
57 if (this==(&aMount) && MountNumber()==aMount.MountNumber())
63 //-----------------------------------------------------------------------------
66 Tests whether the given attribute mask matches given criteria (specified
69 This function is used when filtering entries. aMatt specifies the criteria
70 to be matched by anAtt.
72 Volumes are ignored, so if anAtt has the volume attribute set then
73 the function returns false.
75 If aMatt does not have a hidden (KEntryAttHidden), system (KEntryAttSystem),
76 or directory (KEntryAttDir) attribute set and anAtt does have
77 the corresponding attribute set, then the function returns false.
78 Alternatively, if aMatt has KEntryAttMustBeFile set and anAtt has
79 the directory attribute set, then the function also returns EFalse.
81 Further matching behaviour can be implemented using
82 KEntryAttMatchExclusive and KEntryAttMatchExclude.
84 @param anAtt Attribute mask to be tested.
85 @param aMatt The attribute match mask.
87 @return True, if the anAtt entry attributes match, false otherwise.
92 @see KEntryAttMustBeFile
93 @see KEntryAttMatchExclusive
94 @see KEntryAttMatchExclude
96 EXPORT_C TBool CMountCB::MatchEntryAtt(TUint anAtt,TUint aMatt) const
98 if (aMatt&KEntryAttMatchExclude)
99 { // Include any except
100 if ((anAtt&aMatt)==0)
105 anAtt&=KEntryAttMaskSupported;
106 if ((aMatt&KEntryAttMustBeFile) && (anAtt&KEntryAttIllegal))
107 return(EFalse); // Not a file
109 if ((aMatt&KEntryAttHidden)==0 && (anAtt&KEntryAttHidden))
110 return(EFalse); // Ignore hidden unless requested
111 if ((aMatt&KEntryAttSystem)==0 && (anAtt&KEntryAttSystem))
112 return(EFalse); // Ignore system unless requested
113 if ((aMatt&KEntryAttDir)==0 && (anAtt&KEntryAttDir))
114 return(EFalse); // Ignore directory unless requested
115 if (anAtt&KEntryAttVolume)
116 return(EFalse); // Ignore volumes
118 anAtt&=(~(KEntryAttHidden|KEntryAttSystem)); // remove hidden and system
120 if (aMatt&KEntryAttMatchExclusive)
121 { // Exclude all except
122 if ((anAtt&aMatt)!=0)
131 //-----------------------------------------------------------------------------
133 Gets the address of the specified file if it is found in ROM.
135 The default implementation sets aFileStart to NULL, and this should only
136 be overridden by ROM file systems.
138 @param aFileName A reference to a descriptor containing the full file name.
139 @param aFileStart On return, the address of the file, aFileName.
140 The default implementation returns NULL.
142 EXPORT_C void CMountCB::IsFileInRom(const TDesC& /*aFileName*/,TUint8*& aFileStart)
149 //-----------------------------------------------------------------------------
152 Notifies the file server that the free disk space of the mounted volume
153 has changed outside of the standard file system operations.
155 For example, the background thread of the log flash file system will call
156 this function after a background roll-forward.
158 @param aFreeSpace New free disk space value.
160 EXPORT_C void CMountCB::SetDiskSpaceChange(TInt64 aFreeSpace)
162 const TInt drv=Drive().DriveNumber();
163 __ASSERT_ALWAYS(aFreeSpace>=0,Fault(ESvrFreeDiskSpace));
164 __PRINT3(_L("CMountCB::SetDiskSpaceChange(%LU) drv:%d, %dKB"), aFreeSpace, drv, (TUint32)(aFreeSpace>>10));
166 // Notifying involves memory de-allocation on the file server's heap -
167 // check if we need to switch heaps.
168 RAllocator* current_alloc = &User::Heap();
169 RAllocator* svr_alloc = ServerThreadAllocator;
170 if (current_alloc != svr_alloc)
171 User::SwitchHeap(svr_alloc);
173 FsNotify::HandleDiskSpace(drv, aFreeSpace);
175 if (current_alloc != svr_alloc)
176 User::SwitchHeap(current_alloc);
179 //-----------------------------------------------------------------------------
181 Initialize the MountCB object.
183 @param aDrive TDrive object that will be used by the mount for drive access
184 @param apFileSystem pointer to the File System object that has produced this CMountCB
186 EXPORT_C void CMountCB::InitL(TDrive& aDrive, CFileSystem* apFileSystem)
188 __PRINT3(_L("CMountCB::InitL()[0x%x] drv:%d, FS:0x%x"), this, aDrive.DriveNumber(), apFileSystem);
189 ASSERT(apFileSystem);
193 DoInitL(aDrive.DriveNumber());
195 // see whether the file system supports the CFileCB extended API
196 MFileAccessor* fileAccessor = NULL;
198 GetInterfaceTraced(CMountCB::EFileAccessor, (void*&) fileAccessor, NULL);
200 MFileExtendedInterface* fileExtInterface = NULL;
201 GetInterface(CMountCB::EFileExtendedInterface, (void*&) fileExtInterface, NULL);
205 iBody = new(ELeave)CMountBody(this, fileAccessor, fileExtInterface);
209 //-- some file systems can call this method several times for the same mount.
210 //-- composite FS, for example.
211 __PRINT1(_L("CMountCB::InitL !!re-initialisation!! iBody:0x%x"), iBody);
214 SetFileSystem(apFileSystem); //-- associate MountCB object with the file system it belongs to; this relies on iBody
218 Reports whether the specified interface is supported - if it is,
219 the a supplied interface object is modified to it
221 @param aInterfaceId The interface of interest
222 @param aInterface The interface object
223 @return KErrNone if the interface is supported, otherwise KErrNotFound
225 EXPORT_C TInt CMountCB::GetInterface(TInt /*aInterfaceId*/,TAny*& /*aInterface*/,TAny* /*aInput*/)
227 return(KErrNotSupported);
231 Creates a clamp for the named file, and provides clamp handle data to the caller.
233 @param aDriveNo The number of the drive on which the file can be found
234 @param aName Name of the file to clamp
235 @param aHandle Pointer to the clamp handle data
236 @return KErrNone if successful, otherwise one of the systme-wide eror codes.
238 TInt CMountCB::ClampFile(const TInt aDriveNo, const TDesC& aName, TAny* aHandle)
240 return(iBody?iBody->ClampFile(aDriveNo,aName,aHandle):KErrNotSupported);
244 Reports whether the named file is clamped.
246 @param aName Name of the file to clamp
247 @return 0 if the file is not clamped, 1 if it is, or a system-wide error code.
249 EXPORT_C TInt CMountCB::IsFileClamped(/*const TDesC& aName,*/ const TInt64 aUniqueId)
251 return(iBody?iBody->IsFileClamped(aUniqueId):KErrNotSupported);
255 Removes the clamp indicated by the specified handle.
256 If this was the last clamp for the drive, any pending dismount is performed.
258 @param aHandle Pointer to the clamp handle data
259 @return KErrNone if successful, a system-wide error code otherwise
261 TInt CMountCB::UnclampFile(RFileClamp* aHandle)
263 return(iBody?iBody->UnclampFile(aHandle):KErrNotSupported);
267 Returns the current number of clamps
269 @return the number of clamps
271 TInt CMountCB::NoOfClamps()
273 return(iBody?iBody->NoOfClamps():KErrNotSupported);
280 Gets the sub type name of mounted file system (e.g. FAT12, FAT16 or FAT32 of Fat file system).
281 Uses GetInterface() API to avoid binary compatibility break while providing polymorphism.
282 The real implementations is done by classes multiple inherited from both CMountCB and
283 MFileSystemSubType that have implemented MFileSystemSubType::SubType() virtual function.
284 File system that do not support sub types will have KErrNotSupported returned.
286 @param aSubTypeName A descriptor contains return of the sub type name.
287 @return KErrNone if successful; otherwise another of the system wide error codes;
288 KErrNotSupported if sub type is not supported by mounted file system;
290 @see MFileSystemSubType::SubType()
292 TInt CMountCB::FileSystemSubType(TDes& aName)
294 MFileSystemSubType* interface = NULL;
296 TInt rel = GetInterfaceTraced(EGetFileSystemSubType, (TAny*&)(interface), dummy);
297 if((interface != NULL) && (rel == KErrNone))
299 rel = interface->SubType(aName);
306 Gets the cluster size of mounted file system.
307 Uses GetInterface() API to avoid binary compatibility break while providing polymorphism.
308 The real implementation is done by classes multiple inherited from both CMountCB and
309 MFileSystemClusterSize that have implemented MFileSystemClusterSize::ClusterSize() function.
310 File system that do not support concept of 'clusters' will have the default KErrNotSupported returned.
312 @return Cluster size value if successful; otherwise another of the system wide error codes;
313 KErrNotSupported if cluster is not supported by mounted file system;
315 @see MFileSystemClusterSize::ClusterSize()
317 TInt CMountCB::FileSystemClusterSize()
319 MFileSystemClusterSize* interface = NULL;
321 TInt rel = GetInterfaceTraced(EGetClusterSize, (TAny*&)(interface), dummy);
322 if((interface != NULL) && (rel == KErrNone))
324 rel = interface->ClusterSize();
334 Reads a specified section of the file, regardless of the file's lock state.
336 Uses GetInterface() API to avoid binary compatibility break while providing polymorphism.
337 The real implementation is done by classes multiple inherited from both CMountCB and
338 MFileSystemExtendedInterface that have implemented MFileSystemExtendedInterface::ExtendedReadSectionL() function.
339 File system that do not support large file will implement the default CMountCB::ReadSectionL() function.
341 @see CMountCB::ReadSectionL()
343 @see MFileSystemExtendedInterface::ExtendedReadSectionL()
345 void CMountCB::ReadSection64L(const TDesC& aName,TInt64 aPos,TAny* aTrg,TInt aLength,const RMessagePtr2& aMessage)
347 iBody->iFileExtendedInterface->ReadSection64L(aName, aPos, aTrg, aLength, aMessage);
350 TInt CMountCB::GetFileUniqueId(const TDesC& aName, TInt64& aUniqueId)
352 return (iBody->iFileAccessor->GetFileUniqueId(aName, aUniqueId));
355 TInt CMountCB::Spare3(TInt aVal, TAny* aPtr1, TAny* aPtr2)
357 return (iBody->iFileAccessor->Spare3(aVal, aPtr1, aPtr2));
360 TInt CMountCB::Spare2(TInt aVal, TAny* aPtr1, TAny* aPtr2)
362 return (iBody->iFileAccessor->Spare2(aVal, aPtr1, aPtr2));
365 TInt CMountCB::Spare1(TInt aVal, TAny* aPtr1, TAny* aPtr2)
367 return (iBody->iFileAccessor->Spare1(aVal, aPtr1, aPtr2));
370 TInt CMountCB::GetInterfaceTraced(TInt aInterfaceId, TAny*& aInterface, TAny* aInput)
372 TRACE3(UTF::EBorder, UTraceModuleFileSys::ECMountCBGetInterface, EF32TraceUidFileSys,
373 DriveNumber(), aInterfaceId, aInput);
375 TInt r = GetInterface(aInterfaceId, aInterface, aInput);
377 TRACERET2(UTF::EBorder, UTraceModuleFileSys::ECMountCBGetInterfaceRet, EF32TraceUidFileSys, r, aInterface);
382 //-----------------------------------------------------------------------------
384 Get the file system name. I.e. The name of the file system that produced this object of CMountCB
385 @param aName buffer for the name
387 void CMountCB::FileSystemName(TDes& aName)
389 aName = FileSystem()->Name();
394 //-----------------------------------------------------------------------------
396 Associate CFileSystem object (the factory) and the produced CMountCB object.
397 @param aFS pointer to the file system that produced this mount.
399 void CMountCB::SetFileSystem(CFileSystem* aFS)
402 iBody->SetFileSystem(aFS);
406 Get reference to the filesystem, associated with this mount.
408 EXPORT_C CFileSystem* CMountCB::FileSystem() const
411 CFileSystem* pFSys = iBody->GetFileSystem();
416 void CMountCB::SetProxyDriveDismounted()
418 iBody->SetProxyDriveDismounted();
421 TBool CMountCB::ProxyDriveDismounted()
423 return iBody->ProxyDriveDismounted();
428 Factory method. Produces CFileCB object.
430 CFileCB* CMountCB::NewFileL() const
432 return FileSystem()->NewFileL();
436 Factory method. Produces CDirCB object.
438 CDirCB* CMountCB::NewDirL() const
440 return FileSystem()->NewDirL();
445 Factory method. Produces CFormatCB object.
447 CFormatCB* CMountCB::NewFormatL() const
449 return FileSystem()->NewFormatL();