userlibandfileserver/fileserver/sfile/sf_drv.cpp
branchGCC_SURGE
changeset 221 39b39e1a406e
parent 201 43365a9b78a3
child 199 189ece41fa29
equal deleted inserted replaced
219:0ff03867bdb6 221:39b39e1a406e
    15 // 
    15 // 
    16 //
    16 //
    17 
    17 
    18 #include "sf_std.h"
    18 #include "sf_std.h"
    19 #include "sf_file_cache.h"
    19 #include "sf_file_cache.h"
    20 
    20 #ifdef OST_TRACE_COMPILER_IN_USE
    21 
    21 #include "sf_drvTraces.h"
       
    22 #endif
    22 //const TInt KMaxNotifierAttempts=4; // not used anywhere
    23 //const TInt KMaxNotifierAttempts=4; // not used anywhere
    23 
    24 
    24 static TPtrC StripBackSlash(const TDesC& aName)
    25 static TPtrC StripBackSlash(const TDesC& aName)
    25 //
    26 //
    26 // If aName ends in a backslash, strip it.
    27 // If aName ends in a backslash, strip it.
    82 		aRequest->SetDrive(&aRequest->Drive()->SubstedDrive());
    83 		aRequest->SetDrive(&aRequest->Drive()->SubstedDrive());
    83 		}
    84 		}
    84 	return(KErrNone);
    85 	return(KErrNone);
    85 	}
    86 	}
    86 
    87 
    87 void ValidateAtts(TUint /*anEntryAtts*/,TUint& aSetAttMask,TUint& aClearAttMask)
    88 void ValidateAtts(TUint& aSetAttMask,TUint& aClearAttMask)
    88 //
    89 //
    89 // Do not allow the entry type to be changed
    90 // Do not allow the entry type to be changed
    90 //
    91 //
    91 	{
    92 	{
    92 	const TUint KReadOnlySetAtts = KEntryAttVolume | 
    93 	const TUint KReadOnlySetAtts = KEntryAttVolume | 
   284 	iReason=KErrNone;
   285 	iReason=KErrNone;
   285 
   286 
   286 	if (!aMount.IsDismounted() && !aMount.ProxyDriveDismounted())
   287 	if (!aMount.IsDismounted() && !aMount.ProxyDriveDismounted())
   287 		{
   288 		{
   288 		aMount.SetDrive(this);
   289 		aMount.SetDrive(this);
   289 		TRACE1(UTF::EBorder, UTraceModuleFileSys::ECMountCBReMount, EF32TraceUidFileSys, DriveNumber());
   290 		OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBREMOUNT1, "drive %d", DriveNumber());
   290 		
   291 		
   291         //-- actually, this is asking CMountCB to see if it belongs to the current media. 
   292         //-- actually, this is asking CMountCB to see if it belongs to the current media. 
   292         iReason = aMount.ReMount();
   293         iReason = aMount.ReMount();
   293 
   294 
   294 		TRACE1(UTF::EBorder, UTraceModuleFileSys::ECMountCBReMountRet, EF32TraceUidFileSys, iReason);
   295 		OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBREMOUNT1RET, "success %d", iReason);
   295 		
   296 		
   296         if (iReason == KErrNone)	//	ReMount succeeded
   297         if (iReason == KErrNone)	//	ReMount succeeded
   297 			{
   298 			{
   298 			aMount.Open();
   299 			aMount.Open();
   299 			iCurrentMount = &aMount;
   300 			iCurrentMount = &aMount;
   325 	{
   326 	{
   326 	CFileSystem* pMountsFs = NULL; //-- reference to the filesystem that will be producing CMountCB
   327 	CFileSystem* pMountsFs = NULL; //-- reference to the filesystem that will be producing CMountCB
   327     
   328     
   328     apMount = NULL;
   329     apMount = NULL;
   329 
   330 
   330     TRACE2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewMountL, EF32TraceUidFileSys, &FSys(), DriveNumber());
   331     OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWMOUNTL, "this %x drive %d", (TUint) &FSys(), (TUint) DriveNumber());
   331    
   332    
   332     //-- construct a new CmountCB object.
   333     //-- construct a new CmountCB object.
   333     //-- on return pMountsFs will be the pointer to the factory object of CFileSystem that produced this mount
   334     //-- on return pMountsFs will be the pointer to the factory object of CFileSystem that produced this mount
   334     apMount = FSys().NewMountExL(this, &pMountsFs, aForceMount, aFsNameHash);
   335     apMount = FSys().NewMountExL(this, &pMountsFs, aForceMount, aFsNameHash);
   335 
   336 
   336 	TRACE2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewMountLRet, EF32TraceUidFileSys, KErrNone, apMount);
   337 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWMOUNTLRET, "r %d CMountCB %x", (TUint) KErrNone, (TUint) apMount);
   337 	__PRINT2(_L("TDrive::MountMediaL created mount:0x%x FileSys:0x%x"), apMount, pMountsFs);
   338 	__PRINT2(_L("TDrive::MountMediaL created mount:0x%x FileSys:0x%x"), apMount, pMountsFs);
   338 
   339 
   339     ASSERT(pMountsFs && apMount);
   340     ASSERT(pMountsFs && apMount);
   340 
   341 
   341 	apMount->SetMountNumber(iMountNumber++);
   342 	apMount->SetMountNumber(iMountNumber++);
   400 
   401 
   401     @return standard error code.
   402     @return standard error code.
   402 */
   403 */
   403 TInt TDrive::MountControl(TInt aLevel, TInt aOption, TAny* aParam)
   404 TInt TDrive::MountControl(TInt aLevel, TInt aOption, TAny* aParam)
   404     {
   405     {
   405 	TRACE4(UTF::EBorder, UTraceModuleFileSys::ECMountCBMountControl, EF32TraceUidFileSys, DriveNumber(), aLevel, aOption, aParam);
   406 	OstTraceExt4(TRACE_FILESYSTEM, FSYS_ECMOUNTCBMOUNTCONTROL, "drive %d aLevel %d aOption %x aParam %x", (TUint) DriveNumber(), (TUint) aLevel, (TUint) aOption, (TUint) aParam);
   406     TInt r = CurrentMount().MountControl(aLevel, aOption, aParam);
   407     TInt r = CurrentMount().MountControl(aLevel, aOption, aParam);
   407 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBMountControlRet, EF32TraceUidFileSys, r);
   408 	
   408 
   409 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBMOUNTCONTROLRET, "r %d", r);
   409 	return r;
   410 	return r;
   410     }
   411     }
   411 
   412 
   412 //----------------------------------------------------------------------------
   413 //----------------------------------------------------------------------------
   413 /**
   414 /**
   432 
   433 
   433     //-- 1. Try mount-specific request first. If the mount is still performing free space calculations,
   434     //-- 1. Try mount-specific request first. If the mount is still performing free space calculations,
   434     //-- the caller will be suspended until aFreeSpaceRequired bytes is available or scanning process finishes
   435     //-- the caller will be suspended until aFreeSpaceRequired bytes is available or scanning process finishes
   435     {
   436     {
   436         TUint64 freeSpaceReq = aFreeSpaceRequired;
   437         TUint64 freeSpaceReq = aFreeSpaceRequired;
   437 		TRACE1(UTF::EBorder, UTraceModuleFileSys::ECMountCBFreeSpace, EF32TraceUidFileSys, DriveNumber());
   438 		OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBFREESPACE, "drive %d", DriveNumber());
   438         nRes = CurrentMount().RequestFreeSpace(freeSpaceReq);
   439         nRes = CurrentMount().RequestFreeSpace(freeSpaceReq);
   439 		TRACERET3(UTF::EBorder, UTraceModuleFileSys::ECMountCBFreeSpaceRet, EF32TraceUidFileSys, nRes, I64LOW(freeSpaceReq), I64HIGH(freeSpaceReq));
   440 		OstTraceExt3(TRACE_FILESYSTEM, FSYS_ECMOUNTCBFREESPACERET, "r %d FreeSpace %x:%x", (TUint) nRes, (TUint) I64HIGH(freeSpaceReq), (TUint) I64LOW(freeSpaceReq));
   440         if(nRes == KErrNone)
   441         if(nRes == KErrNone)
   441             {
   442             {
   442             return (freeSpaceReq >= aFreeSpaceRequired) ? KErrNone : KErrDiskFull;
   443             return (freeSpaceReq >= aFreeSpaceRequired) ? KErrNone : KErrDiskFull;
   443             }
   444             }
   444     }
   445     }
   464     TInt nRes;
   465     TInt nRes;
   465 
   466 
   466     nRes = CheckMount();
   467     nRes = CheckMount();
   467     if(nRes != KErrNone)
   468     if(nRes != KErrNone)
   468         return nRes;
   469         return nRes;
   469 
       
   470     //-- 1. Try mount-specific request first. It won't block this call as CMountCB::VolumeL() can do if some background activity is going on the mount
   470     //-- 1. Try mount-specific request first. It won't block this call as CMountCB::VolumeL() can do if some background activity is going on the mount
   471 	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECMountCBVolumeSize, EF32TraceUidFileSys, DriveNumber());
   471 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBVOLUMESIZE, "drive %d", DriveNumber());
   472     nRes = CurrentMount().MountedVolumeSize(aSize);
   472     nRes = CurrentMount().MountedVolumeSize(aSize);
   473 	TRACERET3(UTF::EBorder, UTraceModuleFileSys::ECMountCBVolumeSize, EF32TraceUidFileSys, nRes, I64LOW(aSize), I64HIGH(aSize));
   473 	OstTraceExt3(TRACE_FILESYSTEM, FSYS_ECMOUNTCBVOLUMESIZERET, "r %d aSize %x:%x", (TUint) nRes, (TUint) I64HIGH(aSize), (TUint) I64LOW(aSize));
   474     if(nRes == KErrNone)
   474     if(nRes == KErrNone)
   475         return nRes;
   475         return nRes;
   476 
   476 
   477     //-- given Mount doesn't support this functionality, use legacy method
   477     //-- given Mount doesn't support this functionality, use legacy method
   478     TVolumeInfo volInfo;
   478     TVolumeInfo volInfo;
   501     nRes = CheckMount();
   501     nRes = CheckMount();
   502     if(nRes != KErrNone)
   502     if(nRes != KErrNone)
   503         return nRes;
   503         return nRes;
   504 
   504 
   505     //-- 1. Try mount-specific request first. It won't block this call as CMountCB::VolumeL() can do 
   505     //-- 1. Try mount-specific request first. It won't block this call as CMountCB::VolumeL() can do 
   506 	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECMountCBCurrentFreeSpace, EF32TraceUidFileSys, DriveNumber());
   506 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBCURRENTFREESPACE, "drive %d", DriveNumber());
   507     nRes = CurrentMount().GetCurrentFreeSpaceAvailable(aFreeDiskSpace);
   507     nRes = CurrentMount().GetCurrentFreeSpaceAvailable(aFreeDiskSpace);
   508 	TRACERET3(UTF::EBorder, UTraceModuleFileSys::ECMountCBCurrentFreeSpaceRet, EF32TraceUidFileSys, nRes, I64LOW(aFreeDiskSpace), I64HIGH(aFreeDiskSpace));
   508 	OstTraceExt3(TRACE_FILESYSTEM, FSYS_ECMOUNTCBCURRENTFREESPACERET, "r %d FreeSpace %x:%x", (TUint) nRes, (TUint) I64HIGH(aFreeDiskSpace), (TUint) I64LOW(aFreeDiskSpace));
   509     if(nRes == KErrNone)
   509     if(nRes == KErrNone)
   510         return nRes;
   510         return nRes;
   511 
   511 
   512     //-- given Mount doesn't support this functionality, use legacy method
   512     //-- given Mount doesn't support this functionality, use legacy method
   513     TVolumeInfo volInfo;
   513     TVolumeInfo volInfo;
   541 		return(r);
   541 		return(r);
   542 
   542 
   543 	if(IsWriteProtected())
   543 	if(IsWriteProtected())
   544 		return(KErrAccessDenied);
   544 		return(KErrAccessDenied);
   545 
   545 
   546 	TRACE4(UTF::EBorder, UTraceModuleFileSys::ECMountCBFinaliseMount2, EF32TraceUidFileSys, DriveNumber(), aOperation, aParam1, aParam2);
   546 	OstTraceExt4(TRACE_FILESYSTEM, FSYS_ECMOUNTCBFINALISEMOUNT2, "drive %d aOperation %d aParam1 %x aParam2 %x", (TUint) DriveNumber(), (TUint) aOperation, (TUint) aParam1, (TUint) aParam2);
   547 	TRAP(r,CurrentMount().FinaliseMountL(aOperation, aParam1, aParam2));
   547 	TRAP(r,CurrentMount().FinaliseMountL(aOperation, aParam1, aParam2));
   548 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBFinaliseMount2Ret, EF32TraceUidFileSys, r);
   548 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBFINALISEMOUNT2RET, "r %d", r);
   549 	
   549 	
   550 	// Pass FinaliseDrive notification down to media driver
   550 	// Pass FinaliseDrive notification down to media driver
   551 	TInt driveNumber = DriveNumber();
   551 	TInt driveNumber = DriveNumber();
   552 	if (LocalDrives::IsValidDriveMapping(driveNumber) && !LocalDrives::IsProxyDrive(driveNumber))
   552 	if (LocalDrives::IsValidDriveMapping(driveNumber) && !LocalDrives::IsProxyDrive(driveNumber))
   553 		{
   553 		{
   576 		return(r);
   576 		return(r);
   577 
   577 
   578 	if(IsWriteProtected())
   578 	if(IsWriteProtected())
   579 		return(KErrAccessDenied);
   579 		return(KErrAccessDenied);
   580 
   580 
   581 	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECMountCBFinaliseMount1, EF32TraceUidFileSys, DriveNumber());
   581 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBFINALISEMOUNT1, "drive %d", DriveNumber());
   582 	TRAP(r,CurrentMount().FinaliseMountL());
   582 	TRAP(r,CurrentMount().FinaliseMountL());
   583 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBFinaliseMount1Ret, EF32TraceUidFileSys, r);
   583 	
       
   584 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBFINALISEMOUNT1RET, "r %d", r);
   584 	
   585 	
   585     return r;
   586     return r;
   586 	}
   587 	}
   587 
   588 
   588 
   589 
   885         break;
   886         break;
   886 		}
   887 		}
   887 
   888 
   888 	return KErrNone;
   889 	return KErrNone;
   889 	}
   890 	}
   890 
       
   891 void TDrive::DriveInfo(TDriveInfo& anInfo)
   891 void TDrive::DriveInfo(TDriveInfo& anInfo)
   892 //
   892 //
   893 // Get the drive info.
   893 // Get the drive info.
   894 //
   894 //
   895 	{
   895 	{
   898 	anInfo.iBattery=EBatNotSupported;
   898 	anInfo.iBattery=EBatNotSupported;
   899     anInfo.iConnectionBusType=EConnectionBusInternal;
   899     anInfo.iConnectionBusType=EConnectionBusInternal;
   900 
   900 
   901 	if(iFSys)
   901 	if(iFSys)
   902 		{
   902 		{
   903 		TRACE2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemDriveInfo, EF32TraceUidFileSys, &FSys(), DriveNumber());
   903 		OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMDRIVEINFO, "this %x aDriveNumber %d", (TUint) &FSys(), (TUint) DriveNumber());
   904 		FSys().DriveInfo(anInfo,DriveNumber());
   904 		FSys().DriveInfo(anInfo,DriveNumber());
   905 		TRACE3(UTF::EBorder, UTraceModuleFileSys::ECFileSystemDriveInfoRet, EF32TraceUidFileSys, 
   905 		OstTraceExt3(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMDRIVEINFORET, "type %d driveAtt %x mediaAtt %x", (TUint) anInfo.iType, (TUint) anInfo.iDriveAtt, (TUint) anInfo.iMediaAtt);
   906 			anInfo.iType, anInfo.iDriveAtt, anInfo.iMediaAtt);
       
   907 		}
   906 		}
   908 
   907 
   909 	anInfo.iDriveAtt=Att();
   908 	anInfo.iDriveAtt=Att();
   910 	}
   909 	}
   911 
   910 
   921 		CMountCB& m=CurrentMount();
   920 		CMountCB& m=CurrentMount();
   922 		aVolume.iName=m.VolumeName();
   921 		aVolume.iName=m.VolumeName();
   923 		aVolume.iUniqueID=m.iUniqueID;
   922 		aVolume.iUniqueID=m.iUniqueID;
   924 		aVolume.iSize=m.iSize;
   923 		aVolume.iSize=m.iSize;
   925 
   924 
   926 		TRACE1(UTF::EBorder, UTraceModuleFileSys::ECMountCBVolumeL, EF32TraceUidFileSys, DriveNumber());
   925 		OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBVOLUMEL, "drive %d", DriveNumber());
   927 		TRAP(r,m.VolumeL(aVolume))
   926 		TRAP(r,m.VolumeL(aVolume))
   928 		TRACE7(UTF::EBorder, UTraceModuleFileSys::ECMountCBVolumeLRet, EF32TraceUidFileSys, 
   927 		OstTraceExt5(TRACE_FILESYSTEM, FSYS_ECMOUNTCBVOLUMELRETA, "r %d iSize %x:%x iFree %x:%x", (TUint) r, (TUint) I64HIGH(aVolume.iSize), (TUint) I64LOW(aVolume.iSize), (TUint) I64HIGH(aVolume.iFree), (TUint) I64LOW(aVolume.iFree));
   929 			r, aVolume.iUniqueID, I64LOW(aVolume.iSize), I64HIGH(aVolume.iSize),
   928 		OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECMOUNTCBVOLUMELRETB, "iUniqueID %x iFileCacheFlags %x", (TUint) aVolume.iUniqueID, (TUint) aVolume.iFileCacheFlags);
   930 			I64LOW(aVolume.iFree), I64HIGH(aVolume.iFree), aVolume.iFileCacheFlags);
       
   931 
       
   932 		}
   929 		}
   933 	return(r);
   930 	return(r);
   934 	}
   931 	}
   935 
   932 
   936 
   933 
   940 //
   937 //
   941 	{
   938 	{
   942 	__CHECK_DRIVETHREAD(iDriveNumber);
   939 	__CHECK_DRIVETHREAD(iDriveNumber);
   943 	aBuf=aName.AllocL();
   940 	aBuf=aName.AllocL();
   944 	TPtr volumeName=aBuf->Des();
   941 	TPtr volumeName=aBuf->Des();
   945 
   942 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBSETVOLUMEL, "drive %d", DriveNumber());
   946 	TRACEMULT2(UTF::EBorder, UTraceModuleFileSys::ECMountCBSetVolumeL, EF32TraceUidFileSys, DriveNumber(), aName);
   943 	OstTraceData(TRACE_FILESYSTEM, FSYS_EVOLUMENAME, "VolumeName %S", aName.Ptr(), aName.Length()<<1);
       
   944 	
   947 	CurrentMount().SetVolumeL(volumeName);
   945 	CurrentMount().SetVolumeL(volumeName);
   948 	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECMountCBSetVolumeLRet, EF32TraceUidFileSys, KErrNone);
   946 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBSETVOLUMELRET, "r %d", KErrNone);
   949 
       
   950 
       
   951 	delete &CurrentMount().VolumeName();
   947 	delete &CurrentMount().VolumeName();
   952 	CurrentMount().SetVolumeName(aBuf);
   948 	CurrentMount().SetVolumeName(aBuf);
   953 	}
   949 	}
   954 
   950 
   955 TInt TDrive::SetVolume(const TDesC& aName)
   951 TInt TDrive::SetVolume(const TDesC& aName)
   980 		return(r);
   976 		return(r);
   981 	if(IsWriteProtected())
   977 	if(IsWriteProtected())
   982 		return(KErrAccessDenied);
   978 		return(KErrAccessDenied);
   983 	TParse newDirName;
   979 	TParse newDirName;
   984 	newDirName.Set(aName,NULL,NULL);
   980 	newDirName.Set(aName,NULL,NULL);
   985 
   981 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBMKDIRL, "drive %d", DriveNumber());
   986 	TRACEMULT2(UTF::EBorder, UTraceModuleFileSys::ECMountCBMkDirL, EF32TraceUidFileSys, DriveNumber(), aName);
   982 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBMKDIRLYS_EDIRNAME, "Dir %S", aName.Ptr(), aName.Length()<<1);
   987 	TRAP(r,CurrentMount().MkDirL(newDirName.FullName()))
   983 	TRAP(r,CurrentMount().MkDirL(newDirName.FullName()))
   988 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBMkDirLRet, EF32TraceUidFileSys, r);
   984 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBMKDIRLRET, "r %d", r);
   989 
       
   990 	return(r);
   985 	return(r);
   991 	}
   986 	}
   992 
       
   993 TInt TDrive::RmDir(const TDesC& aName)
   987 TInt TDrive::RmDir(const TDesC& aName)
   994 //
   988 //
   995 // Remove a directory.
   989 // Remove a directory.
   996 //
   990 //
   997 	{
   991 	{
  1004 		return(r);
   998 		return(r);
  1005 	if (entry.IsDir()==EFalse)
   999 	if (entry.IsDir()==EFalse)
  1006 		return(KErrPathNotFound);
  1000 		return(KErrPathNotFound);
  1007 	if ((entry.iAtt&KEntryAttReadOnly) || IsWriteProtected())
  1001 	if ((entry.iAtt&KEntryAttReadOnly) || IsWriteProtected())
  1008 		return(KErrAccessDenied);
  1002 		return(KErrAccessDenied);
  1009 
  1003 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBRMDIRL, "drive %d", DriveNumber());
  1010 	TRACEMULT2(UTF::EBorder, UTraceModuleFileSys::ECMountCBRmDirL, EF32TraceUidFileSys, DriveNumber(), aName);
  1004 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBRMDIRLYS_EDIRNAME, "Dir %S", aName.Ptr(), aName.Length()<<1);
  1011 	TRAP(r,CurrentMount().RmDirL(aName))
  1005 	TRAP(r,CurrentMount().RmDirL(aName))
  1012 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBRmDirLRet, EF32TraceUidFileSys, r);
  1006 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBRMDIRLRET, "r %d", r);
  1013 
       
  1014 	return(r);
  1007 	return(r);
  1015 	}
  1008 	}
  1016 
  1009 
  1017 /*
  1010 /*
  1018  Delete files allowing wild cards.
  1011  Delete files allowing wild cards.
  1029 	// remove from closed queue - NB this isn't strictly necessary if file is read-only or write-protected...
  1022 	// remove from closed queue - NB this isn't strictly necessary if file is read-only or write-protected...
  1030 	LocateClosedFile(aName, EFalse);
  1023 	LocateClosedFile(aName, EFalse);
  1031 
  1024 
  1032     if (IsWriteProtected())
  1025     if (IsWriteProtected())
  1033 		return(KErrAccessDenied);
  1026 		return(KErrAccessDenied);
  1034 
  1027 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBDELETEL1, "drive %d", DriveNumber());
  1035     //-- filesystems' CMountCB::DeleteL() implementations shall check the entry attributes themeselves. 
  1028 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBDELETEL1_EFILENAME, "FileName %S", aName.Ptr(), aName.Length()<<1);
  1036 	TRACEMULT2(UTF::EBorder, UTraceModuleFileSys::ECMountCBDeleteL, EF32TraceUidFileSys, DriveNumber(), aName);
       
  1037 	TRAP(r,CurrentMount().DeleteL(aName))
  1029 	TRAP(r,CurrentMount().DeleteL(aName))
  1038 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBDeleteLRet, EF32TraceUidFileSys, r);
  1030 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBDELETEL1_RET, "r %d", r);
  1039 
       
  1040 	return r;
  1031 	return r;
  1041 	}
  1032 	}
  1042 
  1033 
  1043 TInt TDrive::CheckMountAndEntryNames(const TDesC& anOldName,const TDesC& aNewName)
  1034 TInt TDrive::CheckMountAndEntryNames(const TDesC& anOldName,const TDesC& aNewName)
  1044 //
  1035 //
  1105 		return(KErrAccessDenied);
  1096 		return(KErrAccessDenied);
  1106 
  1097 
  1107 	// remove from closed queue
  1098 	// remove from closed queue
  1108 	LocateClosedFile(anOldName, EFalse);
  1099 	LocateClosedFile(anOldName, EFalse);
  1109 	LocateClosedFile(aNewName, EFalse);
  1100 	LocateClosedFile(aNewName, EFalse);
  1110 
  1101 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBRENAMEL, "drive %d", DriveNumber());
  1111 	TRACEMULT3(UTF::EBorder, UTraceModuleFileSys::ECMountCBRenameL, EF32TraceUidFileSys, DriveNumber(), oldEntryName,newEntryName);
  1102 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBRENAMELYS_EOLDNAME, "OldName %S", oldEntryName.Ptr(), oldEntryName.Length()<<1);
       
  1103 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBRENAMELYS_ENEWNAME, "NewName %S", newEntryName.Ptr(), newEntryName.Length()<<1);
  1112 	TRAP(r,CurrentMount().RenameL(oldEntryName,newEntryName))
  1104 	TRAP(r,CurrentMount().RenameL(oldEntryName,newEntryName))
  1113 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBRenameLRet, EF32TraceUidFileSys, r);
  1105 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBRENAMELRET, "r %d", r);
  1114 
       
  1115 	return(r);
  1106 	return(r);
  1116 	}
  1107 	}
  1117 
  1108 
  1118 TInt TDrive::Replace(const TDesC& anOldName,const TDesC& aNewName)
  1109 TInt TDrive::Replace(const TDesC& anOldName,const TDesC& aNewName)
  1119 //
  1110 //
  1143 		return(KErrInUse);
  1134 		return(KErrInUse);
  1144 
  1135 
  1145 	// remove from closed queue
  1136 	// remove from closed queue
  1146 	LocateClosedFile(anOldName, EFalse);
  1137 	LocateClosedFile(anOldName, EFalse);
  1147 	LocateClosedFile(aNewName, EFalse);
  1138 	LocateClosedFile(aNewName, EFalse);
  1148 
  1139 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBREPLACEL, "drive %d", DriveNumber());
  1149 	TRACEMULT3(UTF::EBorder, UTraceModuleFileSys::ECMountCBReplaceL, EF32TraceUidFileSys, DriveNumber(), anOldName, aNewName);
  1140 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBREPLACEL_EOLDNAME, "OldName %S", anOldName.Ptr(), anOldName.Length()<<1);
       
  1141 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBREPLACEL_ENEWNAME, "NewName %S", aNewName.Ptr(), aNewName.Length()<<1);
  1150 	TRAP(r,CurrentMount().ReplaceL(anOldName,aNewName))
  1142 	TRAP(r,CurrentMount().ReplaceL(anOldName,aNewName))
  1151 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBReplaceLRet, EF32TraceUidFileSys, r);
  1143 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBREPLACELRET, "r %d", r);
  1152 
       
  1153 	return(r);
  1144 	return(r);
  1154 	}
  1145 	}
  1155 
  1146 
  1156 TInt TDrive::Entry(const TDesC& aName,TEntry& anEntry)
  1147 TInt TDrive::Entry(const TDesC& aName,TEntry& anEntry)
  1157 //
  1148 //
  1176 void TDrive::DoEntryL(const TDesC& aName, TEntry& anEntry)
  1167 void TDrive::DoEntryL(const TDesC& aName, TEntry& anEntry)
  1177 //
  1168 //
  1178 // Get entry details
  1169 // Get entry details
  1179 //
  1170 //
  1180 	{
  1171 	{
  1181 	FlushCachedFileInfoL();
  1172 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBENTRYL, "drive %d", DriveNumber());
  1182 
  1173 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBENTRYL_EFILEPATH, "FilePath %S", aName.Ptr(), aName.Length()<<1);
  1183 	TRACEMULT2(UTF::EBorder, UTraceModuleFileSys::ECMountCBEntryL, EF32TraceUidFileSys, DriveNumber(), aName);
       
  1184 	CurrentMount().EntryL(aName,anEntry);
  1174 	CurrentMount().EntryL(aName,anEntry);
  1185 	TRACE5(UTF::EBorder, UTraceModuleFileSys::ECMountCBEntryLRet, EF32TraceUidFileSys, 
  1175 
  1186 		KErrNone, anEntry.iAtt, 
  1176 	// If the file is already open then read the file attributes directly from the file
  1187 		I64LOW(anEntry.iModified.Int64()), I64HIGH(anEntry.iModified.Int64()), 
  1177 	TFileName foldedName;
  1188 		anEntry.iSize);
  1178 	TUint32 nameHash=0;
  1189 
  1179 	foldedName.CopyF(aName);
  1190 	}
  1180 	nameHash=CalcNameHash(foldedName);
  1191 
  1181 
  1192 TInt TDrive::CheckAttributes(const TDesC& aName,TUint& aSetAttMask,TUint& aClearAttMask)
  1182 	__CHECK_DRIVETHREAD(iDriveNumber);
       
  1183 	TDblQueIter<CFileCB> q(CurrentMount().iMountQ);
       
  1184 	CMountCB* currentMount = &CurrentMount();
       
  1185 	CFileCB* file;
       
  1186 	while ((file=q++)!=NULL)
       
  1187 		{
       
  1188 		if ((&file->Drive()==this) && 
       
  1189 			&file->Mount() == currentMount &&
       
  1190 			nameHash == file->NameHash() && 
       
  1191 			file->FileNameF().Match(foldedName)==KErrNone)
       
  1192 			{
       
  1193 			anEntry.iAtt = file->Att() & ~KEntryAttModified;
       
  1194 			anEntry.SetFileSize(file->CachedSize64());
       
  1195 			anEntry.iModified = file->Modified();
       
  1196 			break;
       
  1197 			}
       
  1198 		}
       
  1199 
       
  1200 
       
  1201 	OstTraceExt5(TRACE_FILESYSTEM, FSYS_ECMOUNTCBENTRYLRET, "att %x modified %x:%x  size %x:%x", (TUint) anEntry.iAtt, (TUint) I64HIGH(anEntry.iModified.Int64()), (TUint) I64LOW(anEntry.iModified.Int64()), (TUint) I64HIGH(anEntry.FileSize()), (TUint) anEntry.FileSize());
       
  1202 	}
       
  1203 
       
  1204 TInt TDrive::CheckAttributes(TUint& aSetAttMask,TUint& aClearAttMask)
  1193 //
  1205 //
  1194 // Validate the changes against the current entry attributes
  1206 // Validate the changes against the current entry attributes
  1195 //
  1207 //
  1196 	{
  1208 	{
  1197 
  1209 	ValidateAtts(aSetAttMask,aClearAttMask);
  1198 	TEntry entry;
       
  1199 	TRAPD(r,DoEntryL(aName,entry));
       
  1200 	if (r!=KErrNone)
       
  1201 		return(r);
       
  1202 	ValidateAtts(entry.iAtt,aSetAttMask,aClearAttMask);
       
  1203 	return(KErrNone);
  1210 	return(KErrNone);
  1204 	}
  1211 	}
  1205 
  1212 
  1206 TInt TDrive::SetEntry(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask)
  1213 TInt TDrive::SetEntry(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask)
  1207 //
  1214 //
  1214 		return(r);
  1221 		return(r);
  1215 	TPtrC entryName(StripBackSlash(aName));
  1222 	TPtrC entryName(StripBackSlash(aName));
  1216 	CFileCB* pF=LocateFile(entryName);
  1223 	CFileCB* pF=LocateFile(entryName);
  1217 	if (pF!=NULL)
  1224 	if (pF!=NULL)
  1218 		return(KErrInUse);
  1225 		return(KErrInUse);
  1219 	r=CheckAttributes(entryName,aSetAttMask,aClearAttMask);
  1226 	r=CheckAttributes(aSetAttMask,aClearAttMask);
  1220 	if (r!=KErrNone)
  1227 	if (r!=KErrNone)
  1221 		return(r);
  1228 		return(r);
  1222 	if (IsWriteProtected())
  1229 	if (IsWriteProtected())
  1223 		return(KErrAccessDenied);
  1230 		return(KErrAccessDenied);
  1224 	TTime nullTime(0);
  1231 	TTime nullTime(0);
  1225 	if (aTime!=nullTime)
  1232 	if (aTime!=nullTime)
  1226 		aSetAttMask|=KEntryAttModified;
  1233 		aSetAttMask|=KEntryAttModified;
  1227 
  1234 	OstTraceExt5(TRACE_FILESYSTEM, FSYS_ECMOUNTCBSETENTRYL, "drive %d aTime %x:%x  aSetAttMask %x aClearAttMask %x", (TUint) DriveNumber(), (TUint) I64HIGH(aTime.Int64()), (TUint) I64LOW(aTime.Int64()), (TUint) aSetAttMask, (TUint) aClearAttMask);
  1228 	TRACEMULT6(UTF::EBorder, UTraceModuleFileSys::ECMountCBSetEntryL, EF32TraceUidFileSys, 
  1235 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBSETENTRYL_EFILEPATH, "FilePath %S", aName.Ptr(), aName.Length()<<1);
  1229 		DriveNumber(), aName, I64LOW(aTime.Int64()), I64HIGH(aTime.Int64()), aSetAttMask, aClearAttMask);
       
  1230 	TRAP(r,CurrentMount().SetEntryL(entryName,aTime,aSetAttMask,aClearAttMask))
  1236 	TRAP(r,CurrentMount().SetEntryL(entryName,aTime,aSetAttMask,aClearAttMask))
  1231 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBSetEntryLRet, EF32TraceUidFileSys, r);
  1237 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBSETENTRYLRET, "r %d", r);
  1232 
       
  1233 	return(r);
  1238 	return(r);
  1234 	}
  1239 	}
  1235 
  1240 
  1236 TInt TDrive::FileTemp(CFsRequest* aRequest,TInt& aHandle,const TDesC& aPath,TDes& aName,TUint aMode)
  1241 TInt TDrive::FileTemp(CFsRequest* aRequest,TInt& aHandle,const TDesC& aPath,TDes& aName,TUint aMode)
  1237 //
  1242 //
  1363 		aFileCB=pFile;
  1368 		aFileCB=pFile;
  1364 		pFileCache = pFile->FileCache();
  1369 		pFileCache = pFile->FileCache();
  1365 		}
  1370 		}
  1366 	else
  1371 	else
  1367 		{
  1372 		{
  1368 		TRACE2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewFileL, EF32TraceUidFileSys, &FSys(), DriveNumber());
  1373 		OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWFILEL, "this %x drive %d", (TUint) &FSys(), (TUint) DriveNumber());
  1369 
       
  1370         //-- construct CFileCB object, belonging to the corresponding mount
  1374         //-- construct CFileCB object, belonging to the corresponding mount
  1371         pFile = aFileCB = CurrentMount().NewFileL();
  1375         pFile = aFileCB = CurrentMount().NewFileL();
  1372 
  1376 
  1373 		TRACERET2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewFileLRet, EF32TraceUidFileSys, r, pFile);
  1377 		OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWFILELRET, "r %d CFileCB %x", (TUint) r, (TUint) pFile);
  1374 		TDrive* createdDrive=!aRequest->SubstedDrive() ? this : aRequest->SubstedDrive();
  1378 		TDrive* createdDrive=!aRequest->SubstedDrive() ? this : aRequest->SubstedDrive();
  1375 
  1379 
  1376     	HBufC* fileName = CreateFileNameL(aName);
  1380     	HBufC* fileName = CreateFileNameL(aName);
  1377 
  1381 
  1378         pFile->InitL(this, createdDrive, fileName);
  1382         pFile->InitL(this, createdDrive, fileName);
  1399 	aHandle=aRequest->Session()->Handles().AddL(pFileShare,ETrue);
  1403 	aHandle=aRequest->Session()->Handles().AddL(pFileShare,ETrue);
  1400 
  1404 
  1401 
  1405 
  1402 	if (openFile)
  1406 	if (openFile)
  1403 		{
  1407 		{
  1404 		TRACEMULT5(UTF::EBorder, UTraceModuleFileSys::ECMountCBFileOpenL, EF32TraceUidFileSys, DriveNumber(), aName, aMode, (TUint) anOpen, (TUint) pFile);
  1408 		OstTraceExt4(TRACE_FILESYSTEM, FSYS_ECMOUNTCBFILEOPENL, "drive %d aMode %x anOpen %d aFile %x", (TUint) DriveNumber(), (TUint) aMode, (TUint) anOpen, (TUint) pFile);
       
  1409 		OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBFILEOPENL_EFILENAME, "FileName %S", aName.Ptr(), aName.Length()<<1);
  1405 		CurrentMount().FileOpenL(aName,aMode,anOpen,pFile);
  1410 		CurrentMount().FileOpenL(aName,aMode,anOpen,pFile);
  1406 		TRACE1(UTF::EBorder, UTraceModuleFileSys::ECMountCBFileOpenLRet, EF32TraceUidFileSys, KErrNone);
  1411 		OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBFILEOPENLRET, "r %d", KErrNone);
  1407 
       
  1408 		// Delete on close may now be safely flagged if required.
  1412 		// Delete on close may now be safely flagged if required.
  1409 		// The file did not exist on the media prior to the
  1413 		// The file did not exist on the media prior to the
  1410 		// CMountCB::FileOpenL() call for the case of a create.
  1414 		// CMountCB::FileOpenL() call for the case of a create.
  1411 		if ((aMode & EDeleteOnClose) && (anOpen==EFileCreate))
  1415 		if ((aMode & EDeleteOnClose) && (anOpen==EFileCreate))
  1412 			pFile->SetDeleteOnClose();
  1416 			pFile->SetDeleteOnClose();
  1473 void TDrive::DirOpenL(CSessionFs* aSession,TInt& aHandle,const TDesC& aName,TUint anAtt,const TUidType& aUidType,CDirCB*& aDir)
  1477 void TDrive::DirOpenL(CSessionFs* aSession,TInt& aHandle,const TDesC& aName,TUint anAtt,const TUidType& aUidType,CDirCB*& aDir)
  1474 //
  1478 //
  1475 // Open a directory listing. Leave on error.
  1479 // Open a directory listing. Leave on error.
  1476 //
  1480 //
  1477 	{
  1481 	{
  1478 	TRACE2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewDirL, EF32TraceUidFileSys, &FSys(), DriveNumber());
  1482 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWDIRL, "this %x drive %d", (TUint) &FSys(), (TUint) DriveNumber());
  1479 
       
  1480     CDirCB* pD = aDir = CurrentMount().NewDirL(); //-- construct CDirCB object, belonging to the corresponding mount
  1483     CDirCB* pD = aDir = CurrentMount().NewDirL(); //-- construct CDirCB object, belonging to the corresponding mount
  1481 
  1484 
  1482 	TRACE2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewDirLRet, EF32TraceUidFileSys, KErrNone, pD);
  1485 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWDIRLRET, "r %d CDirCB %x", (TUint) KErrNone, (TUint) pD);
  1483 	pD->InitL(this);
  1486 	pD->InitL(this);
  1484 	// modify resource counter after initialisation to ensure correct cleanup
  1487 	// modify resource counter after initialisation to ensure correct cleanup
  1485 	AddResource(CurrentMount());
  1488 	AddResource(CurrentMount());
  1486 	pD->iAtt=anAtt;
  1489 	pD->iAtt=anAtt;
  1487 	pD->iUidType=aUidType;
  1490 	pD->iUidType=aUidType;
  1488 	Dirs->AddL(pD,ETrue);
  1491 	Dirs->AddL(pD,ETrue);
  1489 	aHandle=aSession->Handles().AddL(pD,ETrue);
  1492 	aHandle=aSession->Handles().AddL(pD,ETrue);
  1490 
  1493 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECMOUNTCBDIROPENL, "drive %d aDir %x", (TUint) DriveNumber(), (TUint) pD);
  1491 	TRACEMULT3(UTF::EBorder, UTraceModuleFileSys::ECMountCBDirOpenL, EF32TraceUidFileSys, DriveNumber(), aName, (TUint) pD);
  1494 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBDIROPENL_EDIRNAME, "Dir %S", aName.Ptr(), aName.Length()<<1);
  1492 	CurrentMount().DirOpenL(aName,pD);
  1495 	CurrentMount().DirOpenL(aName,pD);
  1493 	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECMountCBDirOpenLRet, EF32TraceUidFileSys, KErrNone);
  1496 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBDIROPENLRET, "r %d", KErrNone);
  1494 	}
  1497 	}
  1495 
  1498 
  1496 TInt TDrive::DirOpen(CSessionFs* aSession,TInt& aHandle,const TDesC& aName,TUint anAtt,const TUidType& aUidType)
  1499 TInt TDrive::DirOpen(CSessionFs* aSession,TInt& aHandle,const TDesC& aName,TUint anAtt,const TUidType& aUidType)
  1497 //
  1500 //
  1498 // Open a directory listing.
  1501 // Open a directory listing.
  1547 	__PRINT(_L("TDrive::ReadSection"));
  1550 	__PRINT(_L("TDrive::ReadSection"));
  1548 	TInt r=CheckMountAndEntryName(aName);
  1551 	TInt r=CheckMountAndEntryName(aName);
  1549 	if (r!=KErrNone)
  1552 	if (r!=KErrNone)
  1550 		return(r);
  1553 		return(r);
  1551 	TPtrC entryName(StripBackSlash(aName));
  1554 	TPtrC entryName(StripBackSlash(aName));
  1552 
       
  1553 	TRACETHREADID(aMessage);
  1555 	TRACETHREADID(aMessage);
  1554 	TRACEMULT7(UTF::EBorder, UTraceModuleFileSys::ECMountCBReadFileSectionL, EF32TraceUidFileSys, 
  1556 	OstTraceExt5(TRACE_FILESYSTEM, FSYS_ECMOUNTCBREADFILESECTIONL, "drive %d clientThreadId %x aPos %x:%x aLength %d", (TUint) DriveNumber(), (TUint) threadId, (TUint) I64HIGH(aPos), (TUint) I64LOW(aPos), (TUint) aLength);
  1555 		DriveNumber(), aName, I64LOW(aPos), I64HIGH(aPos), (TUint) aTrg, aLength, I64LOW(threadId));
  1557 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBREADFILESECTIONL_EFILENAME, "FileName %S", aName.Ptr(), aName.Length()<<1);
  1556 	TRAP(r,ReadSectionL(entryName,aPos,aTrg,aLength,aMessage));
  1558 	TRAP(r,ReadSectionL(entryName,aPos,aTrg,aLength,aMessage));
  1557 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBReadFileSectionLRet, EF32TraceUidFileSys, r);
  1559 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBREADFILESECTIONLRET, "r %d", r);
  1558 
       
  1559 	if (r==KErrHidden)
  1560 	if (r==KErrHidden)
  1560 		r=KErrNotFound;	
  1561 		r=KErrNotFound;	
  1561 	else if (r==KErrPathHidden)
  1562 	else if (r==KErrPathHidden)
  1562 		r=KErrPathNotFound;
  1563 		r=KErrPathNotFound;
  1563 
  1564 
  1585 	TInt r=CheckMount();
  1586 	TInt r=CheckMount();
  1586 	if (r==KErrNone)
  1587 	if (r==KErrNone)
  1587 		TRAP(r,FlushCachedFileInfoL());
  1588 		TRAP(r,FlushCachedFileInfoL());
  1588 	if (r==KErrNone)
  1589 	if (r==KErrNone)
  1589 		{
  1590 		{
  1590 		TRACE1(UTF::EBorder, UTraceModuleFileSys::ECMountCBCheckDisk1, EF32TraceUidFileSys, DriveNumber());
  1591 		OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBCHECKDISK1, "drive %d", DriveNumber());
  1591 		r=CurrentMount().CheckDisk();
  1592 		r=CurrentMount().CheckDisk();
  1592 		TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBCheckDisk1Ret, EF32TraceUidFileSys, r);
  1593 		OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBCHECKDISK1RET, "r %d", r);
  1593 		}
  1594 		}
  1594 	return(r);
  1595 	return(r);
  1595 	}
  1596 	}
  1596 
  1597 
  1597 /**
  1598 /**
  1602 	TInt r=CheckMount();
  1603 	TInt r=CheckMount();
  1603 	if (r==KErrNone)
  1604 	if (r==KErrNone)
  1604 		TRAP(r,FlushCachedFileInfoL());
  1605 		TRAP(r,FlushCachedFileInfoL());
  1605 	if (r==KErrNone)
  1606 	if (r==KErrNone)
  1606 		{
  1607 		{
  1607 		TRACE4(UTF::EBorder, UTraceModuleFileSys::ECMountCBCheckDisk2, EF32TraceUidFileSys, DriveNumber(), aOperation, aParam1, aParam2);
  1608 		OstTraceExt4(TRACE_FILESYSTEM, FSYS_ECMOUNTCBCHECKDISK2, "drive %d aOperation %d aParam1 %x aParam2 %x", (TUint) DriveNumber(), (TUint) aOperation, (TUint) aParam1, (TUint) aParam2);
  1608 		r=CurrentMount().CheckDisk(aOperation, aParam1, aParam2);
  1609 		r=CurrentMount().CheckDisk(aOperation, aParam1, aParam2);
  1609 		TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBCheckDisk2Ret, EF32TraceUidFileSys, r);
  1610 		OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBCHECKDISK2RET, "r %d", r);
  1610 		}
  1611 		}
  1611 
  1612 
  1612 	return(r);
  1613 	return(r);
  1613     }
  1614     }
  1614 
  1615 
  1626 		return r;
  1627 		return r;
  1627 
  1628 
  1628 	// Empty closed file queue
  1629 	// Empty closed file queue
  1629 	TClosedFileUtils::Remove(DriveNumber());
  1630 	TClosedFileUtils::Remove(DriveNumber());
  1630 
  1631 
  1631 	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECMountCBScanDrive1, EF32TraceUidFileSys, DriveNumber());
  1632 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBSCANDRIVE1, "drive %d", DriveNumber());
  1632 	r = CurrentMount().ScanDrive();
  1633 	r = CurrentMount().ScanDrive();
  1633 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBScanDrive1Ret, EF32TraceUidFileSys, r);
  1634 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBSCANDRIVE1RET, "r %d", r);
  1634 
       
  1635 	return r;
  1635 	return r;
  1636 	}
  1636 	}
  1637 
  1637 
  1638 
  1638 
  1639 /**
  1639 /**
  1653 		return r;
  1653 		return r;
  1654 
  1654 
  1655 	// Empty closed file queue
  1655 	// Empty closed file queue
  1656 	TClosedFileUtils::Remove(DriveNumber());
  1656 	TClosedFileUtils::Remove(DriveNumber());
  1657 
  1657 
  1658 	TRACE4(UTF::EBorder, UTraceModuleFileSys::ECMountCBScanDrive2, EF32TraceUidFileSys, DriveNumber(), aOperation, aParam1, aParam2);
  1658 	OstTraceExt4(TRACE_FILESYSTEM, FSYS_ECMOUNTCBSCANDRIVE2, "drive %d aOperation %d aParam1 %x aParam2 %x", (TUint) DriveNumber(), (TUint) aOperation, (TUint) aParam1, (TUint) aParam2);
  1659 	r = CurrentMount().ScanDrive(aOperation, aParam1, aParam2);
  1659 	r = CurrentMount().ScanDrive(aOperation, aParam1, aParam2);
  1660 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBScanDrive2Ret, EF32TraceUidFileSys, r);
  1660 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBSCANDRIVE2RET, "r %d", r);
  1661 
       
  1662 	return r;
  1661 	return r;
  1663 	}
  1662 	}
  1664 
  1663 
  1665 
  1664 
  1666 TInt TDrive::GetShortName(const TDesC& aName,TDes& aShortName)
  1665 TInt TDrive::GetShortName(const TDesC& aName,TDes& aShortName)
  1670 	{
  1669 	{
  1671 	TInt r=CheckMountAndEntryName(aName);
  1670 	TInt r=CheckMountAndEntryName(aName);
  1672 	if (r!=KErrNone)
  1671 	if (r!=KErrNone)
  1673 		return(r);
  1672 		return(r);
  1674 	TPtrC entryName(StripBackSlash(aName));
  1673 	TPtrC entryName(StripBackSlash(aName));
  1675 
  1674 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBGETSHORTNAMEL, "drive %d", DriveNumber());
  1676 	TRACEMULT2(UTF::EBorder, UTraceModuleFileSys::ECMountCBGetShortNameL, EF32TraceUidFileSys, DriveNumber(), entryName);
  1675 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBGETSHORTNAMEL_ELONGNAME, "LongName %S", entryName.Ptr(), entryName.Length()<<1);
  1677 	TRAP(r,CurrentMount().GetShortNameL(entryName,aShortName));
  1676 	TRAP(r,CurrentMount().GetShortNameL(entryName,aShortName));
  1678 	TRACERETMULT2(UTF::EBorder, UTraceModuleFileSys::ECMountCBGetShortNameLRet, EF32TraceUidFileSys, r, aShortName);
  1677 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBGETSHORTNAMEL_ESHORTNAME, "ShortName %S", aShortName.Ptr(), aShortName.Length()<<1);
  1679 
  1678 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBGETSHORTNAMEL_ECMOUNTCBGETSHORTNAMELRET, "r %d", r);
  1680 	return(r);
  1679 	return(r);
  1681 	}
  1680 	}
  1682 
  1681 
  1683 TInt TDrive::GetLongName(const TDesC& aShortName,TDes& aLongName)
  1682 TInt TDrive::GetLongName(const TDesC& aShortName,TDes& aLongName)
  1684 //
  1683 //
  1687 	{
  1686 	{
  1688 	TInt r=CheckMountAndEntryName(aShortName);
  1687 	TInt r=CheckMountAndEntryName(aShortName);
  1689 	if (r!=KErrNone)
  1688 	if (r!=KErrNone)
  1690 		return(r);
  1689 		return(r);
  1691 	TPtrC entryName(StripBackSlash(aShortName));
  1690 	TPtrC entryName(StripBackSlash(aShortName));
  1692 
  1691 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBGETLONGNAMEL, "drive %d", DriveNumber());
  1693 	TRACEMULT2(UTF::EBorder, UTraceModuleFileSys::ECMountCBGetLongNameL, EF32TraceUidFileSys, DriveNumber(), entryName);
  1692 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBGETLONGNAMEL_ESHORTNAME, "ShortName %S", entryName.Ptr(), entryName.Length()<<1);
  1694 	TRAP(r,CurrentMount().GetLongNameL(entryName,aLongName));
  1693 	TRAP(r,CurrentMount().GetLongNameL(entryName,aLongName));
  1695 	TRACERETMULT2(UTF::EBorder, UTraceModuleFileSys::ECMountCBGetLongNameLRet, EF32TraceUidFileSys, r, aLongName);
  1694 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBGETLONGNAMEL_ELONGNAME, "LongName %S", aLongName.Ptr(), aLongName.Length()<<1);
  1696 
  1695 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBGETLONGNAMELRET, "r %d", r);
  1697 	return(r);
  1696 	return(r);
  1698 	}
  1697 	}
  1699 
  1698 
  1700 
  1699 
  1701 /**
  1700 /**
  1855 	__CHECK_DRIVETHREAD(iDriveNumber);
  1854 	__CHECK_DRIVETHREAD(iDriveNumber);
  1856 	if(iFSys==NULL)
  1855 	if(iFSys==NULL)
  1857 		return(KErrNotReady);
  1856 		return(KErrNotReady);
  1858 	TInt r;
  1857 	TInt r;
  1859 	CMountCB* pM=NULL;
  1858 	CMountCB* pM=NULL;
  1860 	TRACE2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewMountL, EF32TraceUidFileSys, &FSys(), DriveNumber());
  1859 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWMOUNTL1, "this %x drive %d", (TUint) &FSys(), (TUint) DriveNumber());
  1861 	TRAP(r,pM=FSys().NewMountL());
  1860 	TRAP(r,pM=FSys().NewMountL());
  1862 	TRACERET2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewMountLRet, EF32TraceUidFileSys, r, pM);
  1861 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWMOUNTL1RET, "r %d CMountCB %x", (TUint) r, (TUint) pM);
  1863 	if(r!=KErrNone)
  1862 	if(r!=KErrNone)
  1864 		return(r);
  1863 		return(r);
  1865 	pM->SetDrive(this);
  1864 	pM->SetDrive(this);
  1866 
  1865 	OstTraceExt4(TRACE_FILESYSTEM, FSYS_ECMOUNTCBFORCEREMOUNTDRIVE, "drive %d aMountInfo %x aMountInfoMessageHandle %x aFlags %x", (TUint) DriveNumber(), (TUint) aMountInfo, (TUint) aMountInfoMessageHandle, (TUint) aFlags);
  1867 	TRACE4(UTF::EBorder, UTraceModuleFileSys::ECMountCBForceRemountDrive, EF32TraceUidFileSys, 
       
  1868 		DriveNumber(), aMountInfo, aMountInfoMessageHandle, aFlags);
       
  1869 	r=pM->ForceRemountDrive(aMountInfo,aMountInfoMessageHandle,aFlags);
  1866 	r=pM->ForceRemountDrive(aMountInfo,aMountInfoMessageHandle,aFlags);
  1870 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBForceRemountDriveRet, EF32TraceUidFileSys, r);
  1867 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBFORCEREMOUNTDRIVERET, "r %d", r);
  1871 
       
  1872 	pM->Close();
  1868 	pM->Close();
  1873 	return(r);
  1869 	return(r);
  1874 	}
  1870 	}
  1875 
       
  1876 TBool TDrive::IsExtensionMounted(CProxyDriveFactory* aFactory)
  1871 TBool TDrive::IsExtensionMounted(CProxyDriveFactory* aFactory)
  1877 //
  1872 //
  1878 // return ETrue if extension mounted on the drive
  1873 // return ETrue if extension mounted on the drive
  1879 //
  1874 //
  1880 	{
  1875 	{
  1883 		if(iExtInfo.iInfo[i].iFactory==aFactory)
  1878 		if(iExtInfo.iInfo[i].iFactory==aFactory)
  1884 			return(ETrue);
  1879 			return(ETrue);
  1885 		}
  1880 		}
  1886 	return(EFalse);
  1881 	return(EFalse);
  1887 	}
  1882 	}
  1888 
       
  1889 TInt TDrive::MountExtension(CProxyDriveFactory* aFactory,TBool aIsPrimary)
  1883 TInt TDrive::MountExtension(CProxyDriveFactory* aFactory,TBool aIsPrimary)
  1890 //
  1884 //
  1891 // Mount an extension
  1885 // Mount an extension
  1892 //
  1886 //
  1893 	{
  1887 	{
  1907 	__CHECK_DRIVETHREAD(iDriveNumber);
  1901 	__CHECK_DRIVETHREAD(iDriveNumber);
  1908 	// must be a secondary extension
  1902 	// must be a secondary extension
  1909 	if(iFSys==NULL)
  1903 	if(iFSys==NULL)
  1910 		return(KErrNotReady);
  1904 		return(KErrNotReady);
  1911 	TBool extSupported = iFSys->IsExtensionSupported();
  1905 	TBool extSupported = iFSys->IsExtensionSupported();
  1912 	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECFileSystemIsExtensionSupported, EF32TraceUidFileSys, extSupported);
  1906 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMISEXTENSIONSUPPORTED1, "%x r %d", (TUint) iFSys, (TUint) extSupported);
  1913 	if(!extSupported)
  1907 	if(!extSupported)
  1914 		return(KErrNotSupported);
  1908 		return(KErrNotSupported);
  1915 	if(IsExtensionMounted(aFactory))
  1909 	if(IsExtensionMounted(aFactory))
  1916 		return(KErrAlreadyExists);
  1910 		return(KErrAlreadyExists);
  1917 	if(iCurrentMount && (CurrentMount().LockStatus()!=0 || Mount().Count()>1))
  1911 	if(iCurrentMount && (CurrentMount().LockStatus()!=0 || Mount().Count()>1))
  1995 	__CHECK_DRIVETHREAD(iDriveNumber);
  1989 	__CHECK_DRIVETHREAD(iDriveNumber);
  1996 	if(iFSys==NULL)
  1990 	if(iFSys==NULL)
  1997 		return(KErrNotReady);
  1991 		return(KErrNotReady);
  1998 	TInt r;
  1992 	TInt r;
  1999 	CMountCB* pM=NULL;
  1993 	CMountCB* pM=NULL;
  2000 	TRACE2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewMountL, EF32TraceUidFileSys, &FSys(), DriveNumber());
  1994 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWMOUNTL2, "this %x drive %d", (TUint) &FSys(), (TUint) DriveNumber());
  2001 	TRAP(r,pM=FSys().NewMountL());
  1995 	TRAP(r,pM=FSys().NewMountL());
  2002 	TRACERET2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewMountLRet, EF32TraceUidFileSys, r, pM);
  1996 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWMOUNTL2RET, "r %d CMountCB %x", (TUint) r, (TUint) pM);
  2003 	if(r!=KErrNone)
  1997 	if(r!=KErrNone)
  2004 		return(r);
  1998 		return(r);
  2005 	pM->SetDrive(this);
  1999 	pM->SetDrive(this);
  2006 
  2000 
  2007 	TRACE2(UTF::EBorder, UTraceModuleFileSys::ECMountCBLock, EF32TraceUidFileSys, DriveNumber(), aStore);
  2001 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECMOUNTCBLOCK, "drive %d aStore %d", (TUint) DriveNumber(), (TUint) aStore);
  2008 	r=pM->Lock(aOld,aNew,aStore);
  2002 	r=pM->Lock(aOld,aNew,aStore);
  2009 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBLockRet, EF32TraceUidFileSys, r);
  2003 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBLOCKRET, "r %d", r);
  2010 
       
  2011 	pM->Close();
  2004 	pM->Close();
  2012 	return(r);
  2005 	return(r);
  2013 	}
  2006 	}
  2014 
  2007 
  2015 TInt TDrive::UnlockDevice(TMediaPassword& aPassword,TBool aStore)
  2008 TInt TDrive::UnlockDevice(TMediaPassword& aPassword,TBool aStore)
  2021 	__CHECK_DRIVETHREAD(iDriveNumber);
  2014 	__CHECK_DRIVETHREAD(iDriveNumber);
  2022 	if(iFSys==NULL)
  2015 	if(iFSys==NULL)
  2023 		return(KErrNotReady);
  2016 		return(KErrNotReady);
  2024 	TInt r;
  2017 	TInt r;
  2025 	CMountCB* pM=NULL;
  2018 	CMountCB* pM=NULL;
  2026 	TRACE2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewMountL, EF32TraceUidFileSys, &FSys(), DriveNumber());
  2019 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWMOUNTL3, "this %x drive %d", (TUint) &FSys(), (TUint) DriveNumber());
  2027 	TRAP(r,pM=FSys().NewMountL());
  2020 	TRAP(r,pM=FSys().NewMountL());
  2028 	TRACERET2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewMountLRet, EF32TraceUidFileSys, r, pM);
  2021 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWMOUNTL3RET, "r %d CMountCB %x", (TUint) r, (TUint) pM);
  2029 	if(r!=KErrNone)
  2022 	if(r!=KErrNone)
  2030 		return(r);
  2023 		return(r);
  2031 
  2024 
  2032 	// reset mount failure count - which is likely to be non-zero if drive is locked
  2025 	// reset mount failure count - which is likely to be non-zero if drive is locked
  2033 	iMountFailures = 0;
  2026 	iMountFailures = 0;
  2034 
  2027 
  2035 	pM->SetDrive(this);
  2028 	pM->SetDrive(this);
  2036 
  2029 
  2037 	TRACE2(UTF::EBorder, UTraceModuleFileSys::ECMountCBUnlock, EF32TraceUidFileSys, DriveNumber(), aStore);
  2030 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECMOUNTCBUNLOCK, "drive %d aStore %d", (TUint) DriveNumber(), (TUint) aStore);
  2038 	r=pM->Unlock(aPassword,aStore);
  2031 	r=pM->Unlock(aPassword,aStore);
  2039 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBUnlockRet, EF32TraceUidFileSys, r);
  2032 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBUNLOCKRET, "r %d", r);
  2040 
       
  2041 	pM->Close();
  2033 	pM->Close();
  2042 	return(r);
  2034 	return(r);
  2043 	}
  2035 	}
  2044 
  2036 
  2045 TInt TDrive::ClearDevicePassword(TMediaPassword& aPassword)
  2037 TInt TDrive::ClearDevicePassword(TMediaPassword& aPassword)
  2051 	__CHECK_DRIVETHREAD(iDriveNumber);
  2043 	__CHECK_DRIVETHREAD(iDriveNumber);
  2052 	if(iFSys==NULL)
  2044 	if(iFSys==NULL)
  2053 		return(KErrNotReady);
  2045 		return(KErrNotReady);
  2054 	TInt r;
  2046 	TInt r;
  2055 	CMountCB* pM=NULL;
  2047 	CMountCB* pM=NULL;
  2056 	TRACE2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewMountL, EF32TraceUidFileSys, &FSys(), DriveNumber());
  2048 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWMOUNTL4, "this %x drive %d", (TUint) &FSys(), (TUint) DriveNumber());
  2057 	TRAP(r,pM=FSys().NewMountL());
  2049 	TRAP(r,pM=FSys().NewMountL());
  2058 	TRACERET2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewMountLRet, EF32TraceUidFileSys, r, pM);
  2050 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWMOUNTL4RET, "r %d CMountCB %x", (TUint) r, (TUint) pM);
  2059 	if(r!=KErrNone)
  2051 	if(r!=KErrNone)
  2060 		return(r);
  2052 		return(r);
  2061 	pM->SetDrive(this);
  2053 	pM->SetDrive(this);
  2062 
  2054 
  2063 	// ClearPassword() will only work if the card is already unlocked. 
  2055 	// ClearPassword() will only work if the card is already unlocked. 
  2067 	TDriveInfo info;
  2059 	TDriveInfo info;
  2068 	DriveInfo(info);
  2060 	DriveInfo(info);
  2069 	if (info.iMediaAtt & KMediaAttLocked)
  2061 	if (info.iMediaAtt & KMediaAttLocked)
  2070 		UnlockDevice(aPassword, EFalse);
  2062 		UnlockDevice(aPassword, EFalse);
  2071 
  2063 
  2072 	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECMountCBClearPassword, EF32TraceUidFileSys, DriveNumber());
  2064 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBCLEARPASSWORD, "drive %d", DriveNumber());
  2073 	r=pM->ClearPassword(aPassword);
  2065 	r=pM->ClearPassword(aPassword);
  2074 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBClearPasswordRet, EF32TraceUidFileSys, r);
  2066 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBCLEARPASSWORDRET, "r %d", r);
  2075 
       
  2076 	pM->Close();
  2067 	pM->Close();
  2077 	return(r);
  2068 	return(r);
  2078 	}
  2069 	}
  2079 
  2070 
  2080 TInt TDrive::EraseDevicePassword()
  2071 TInt TDrive::EraseDevicePassword()
  2086 	__CHECK_DRIVETHREAD(iDriveNumber);
  2077 	__CHECK_DRIVETHREAD(iDriveNumber);
  2087 	if(iFSys==NULL)
  2078 	if(iFSys==NULL)
  2088 		return(KErrNotReady);
  2079 		return(KErrNotReady);
  2089 	TInt r;
  2080 	TInt r;
  2090 	CMountCB* pM=NULL;
  2081 	CMountCB* pM=NULL;
  2091 	TRACE2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewMountL, EF32TraceUidFileSys, &FSys(), DriveNumber());
  2082 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWMOUNTL5, "this %x drive %d", (TUint) &FSys(), (TUint) DriveNumber());
  2092 	TRAP(r,pM=FSys().NewMountL());
  2083 	TRAP(r,pM=FSys().NewMountL());
  2093 	TRACERET2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewMountLRet, EF32TraceUidFileSys, r, pM);
  2084 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWMOUNTL5RET, "r %d CMountCB %x", (TUint) r, (TUint) pM);
  2094 	if(r!=KErrNone)
  2085 	if(r!=KErrNone)
  2095 		return(r);
  2086 		return(r);
  2096 	pM->SetDrive(this);
  2087 	pM->SetDrive(this);
  2097 
  2088 
  2098 	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECMountCBErasePassword, EF32TraceUidFileSys, DriveNumber());
  2089 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBERASEPASSWORD, "drive %d", DriveNumber());
  2099 	r=pM->ErasePassword();
  2090 	r=pM->ErasePassword();
  2100 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBErasePasswordRet, EF32TraceUidFileSys, r);
  2091 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBERASEPASSWORDRET, "r %d", r);
  2101 
       
  2102 	pM->Close();
  2092 	pM->Close();
  2103 	return(r);
  2093 	return(r);
  2104 	}
  2094 	}
  2105 
  2095 
  2106 #else
  2096 #else
  2235     iMountFailures = 0;
  2225     iMountFailures = 0;
  2236 
  2226 
  2237 	if (!iCurrentMount)
  2227 	if (!iCurrentMount)
  2238 		return;
  2228 		return;
  2239 
  2229 
  2240 	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECMountCBDismounted, EF32TraceUidFileSys, DriveNumber());
  2230 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBDISMOUNTED, "drive %d", DriveNumber());
  2241     iCurrentMount->Dismounted();
  2231     iCurrentMount->Dismounted();
  2242 	TRACE0(UTF::EBorder, UTraceModuleFileSys::ECMountCBDismountedRet, EF32TraceUidFileSys);
  2232 	OstTrace0(TRACE_FILESYSTEM, FSYS_ECMOUNTCBDISMOUNTEDRET, "");
  2243 
       
  2244 	iCurrentMount->Close();
  2233 	iCurrentMount->Close();
  2245 	iCurrentMount=NULL;
  2234 	iCurrentMount=NULL;
  2246     }
  2235     }
  2247 
  2236 
  2248 
  2237 
  2335 	else
  2324 	else
  2336 		iDriveFlags &= ~EDismountDeferred;
  2325 		iDriveFlags &= ~EDismountDeferred;
  2337 	}
  2326 	}
  2338 
  2327 
  2339 
  2328 
  2340 
       
  2341 TInt TDrive::ControlIO(const RMessagePtr2& aMessage,TInt aCommand,TAny* aParam1,TAny* aParam2)
  2329 TInt TDrive::ControlIO(const RMessagePtr2& aMessage,TInt aCommand,TAny* aParam1,TAny* aParam2)
  2342 //
  2330 //
  2343 // General purpose test interface - .FSY specific.
  2331 // General purpose test interface - .FSY specific.
  2344 //
  2332 //
  2345 	{
  2333 	{
  2346 	TInt r=CheckMount();
  2334 	TInt r=CheckMount();
  2347 	if(r==KErrNone || (r==KErrInUse && iReason==KErrNone))
  2335 	if(r==KErrNone || (r==KErrInUse && iReason==KErrNone))
  2348 		{
  2336 		{
  2349 		TRACETHREADID(aMessage);
  2337 		TRACETHREADID(aMessage);
  2350 		TRACE5(UTF::EBorder, UTraceModuleFileSys::ECMountCBControlIO, EF32TraceUidFileSys, 
  2338 		OstTraceExt5(TRACE_FILESYSTEM, FSYS_ECMOUNTCBCONTROLIO, "drive %d aCommand %d aParam1 %x aParam2 %x clientThreadId %x", (TUint) DriveNumber(), (TUint) aCommand, (TUint) aParam1, (TUint) aParam2, (TUint) threadId);
  2351 			DriveNumber(), aCommand, aParam1, aParam2, I64LOW(threadId));
       
  2352 		r=CurrentMount().ControlIO(aMessage,aCommand,aParam1,aParam2);
  2339 		r=CurrentMount().ControlIO(aMessage,aCommand,aParam1,aParam2);
  2353 		TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBControlIORet, EF32TraceUidFileSys, r);
  2340 		OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBCONTROLIORET, "r %d", r);
  2354 		}
  2341 		}
  2355 	return(r);
  2342 	return(r);
  2356 	}
  2343 	}
  2357 
  2344 
  2358 
  2345 
  2565 */
  2552 */
  2566 CFormatCB* TDrive::FormatOpenL(CFsRequest* aRequest, TInt& aFmtHandle, TFormatMode aFmtMode, const TLDFormatInfo* apLDFormatInfo, const TVolFormatParam* apVolFormatParam)
  2553 CFormatCB* TDrive::FormatOpenL(CFsRequest* aRequest, TInt& aFmtHandle, TFormatMode aFmtMode, const TLDFormatInfo* apLDFormatInfo, const TVolFormatParam* apVolFormatParam)
  2567     {
  2554     {
  2568     ASSERT(!(apLDFormatInfo && apVolFormatParam));  //-- these parameters are mutually exclusive
  2555     ASSERT(!(apLDFormatInfo && apVolFormatParam));  //-- these parameters are mutually exclusive
  2569     
  2556     
  2570     TRACE2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewFormatL, EF32TraceUidFileSys, &FSys(), DriveNumber()); 
  2557     OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWFORMATL, "this %x drive %d", (TUint) &FSys(), (TUint) DriveNumber()); 
  2571 
       
  2572     CFormatCB* pFormat = CurrentMount().NewFormatL(); 
  2558     CFormatCB* pFormat = CurrentMount().NewFormatL(); 
  2573 
  2559 
  2574 	TRACE2(UTF::EBorder, UTraceModuleFileSys::ECFileSystemNewFormatLRet, EF32TraceUidFileSys, KErrNone, pFormat); 
  2560 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILESYSTEMNEWFORMATLRET, "r %d CFormatCB %x", (TUint) KErrNone, (TUint) pFormat); 
  2575 	
  2561 	
  2576     Formats->AddL(pFormat, ETrue); 
  2562     Formats->AddL(pFormat, ETrue); 
  2577 	pFormat->InitL(this, aFmtMode); 
  2563 	pFormat->InitL(this, aFmtMode); 
  2578 
  2564 
  2579     if(aFmtMode & ESpecialFormat) 
  2565     if(aFmtMode & ESpecialFormat)