userlibandfileserver/fileserver/sfile/sf_file.cpp
branchRCL_3
changeset 43 c1f20ce4abcf
parent 42 a179b74831c9
child 44 3e88ff8f41d5
equal deleted inserted replaced
42:a179b74831c9 43:c1f20ce4abcf
    14 //
    14 //
    15  
    15  
    16 #include "sf_std.h"
    16 #include "sf_std.h"
    17 #include "sf_file_cache.h"
    17 #include "sf_file_cache.h"
    18 #include "cl_std.h"
    18 #include "cl_std.h"
    19 
    19 #ifdef OST_TRACE_COMPILER_IN_USE
       
    20 #include "sf_fileTraces.h"
       
    21 #endif
    20 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
    22 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
    21 
    23 
    22 TInt OutputTraceInfo(CFsRequest* aRequest,TCorruptNameRec* aNameRec)
    24 TInt OutputTraceInfo(CFsRequest* aRequest,TCorruptNameRec* aNameRec)
    23 	{	
    25 	{	
    24 	RThread tT;
    26 	RThread tT;
  1505 	if ((share->iMode&EFileWrite)==0)
  1507 	if ((share->iMode&EFileWrite)==0)
  1506 		return(KErrAccessDenied);
  1508 		return(KErrAccessDenied);
  1507 	r=share->CheckMount();
  1509 	r=share->CheckMount();
  1508 	if (r!=KErrNone)
  1510 	if (r!=KErrNone)
  1509 		return(r);
  1511 		return(r);
  1510 
  1512 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBFLUSHDATAL1, "this %x", &share->File());
  1511 	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECFileCBFlushDataL, EF32TraceUidFileSys, &share->File());
       
  1512 	TRAP(r,share->File().FlushDataL());
  1513 	TRAP(r,share->File().FlushDataL());
  1513 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECFileCBFlushDataLRet, EF32TraceUidFileSys, r);
  1514 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBFLUSHDATAL1RET, "r %d", r);
  1514 
       
  1515 	return(r);
  1515 	return(r);
  1516 	}
  1516 	}
  1517 
  1517 
  1518 TInt TFsFileFlush::Initialise(CFsRequest* aRequest)
  1518 TInt TFsFileFlush::Initialise(CFsRequest* aRequest)
  1519 //
  1519 //
  1677 		return(KErrAccessDenied);
  1677 		return(KErrAccessDenied);
  1678 	
  1678 	
  1679     TUint setAttMask=(TUint)(aRequest->Message().Int0());
  1679     TUint setAttMask=(TUint)(aRequest->Message().Int0());
  1680 	TUint clearAttMask=(TUint)aRequest->Message().Int1();
  1680 	TUint clearAttMask=(TUint)aRequest->Message().Int1();
  1681 	ValidateAtts(setAttMask,clearAttMask);
  1681 	ValidateAtts(setAttMask,clearAttMask);
  1682 
  1682 	OstTraceExt3(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL1, "this %x aSetAttMask %x aClearAttMask %x", (TUint) &share->File(), (TUint) setAttMask, (TUint) clearAttMask);
  1683 	TRACE5(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryL, EF32TraceUidFileSys, &share->File(), 0, 0, setAttMask,clearAttMask);
       
  1684 	TRAP(r,share->File().SetEntryL(share->File().Modified(),setAttMask,clearAttMask))
  1683 	TRAP(r,share->File().SetEntryL(share->File().Modified(),setAttMask,clearAttMask))
  1685 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryLRet, EF32TraceUidFileSys, r);
  1684 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL1RET, "r %d", r);
  1686 
       
  1687 	return(r);
  1685 	return(r);
  1688 	}
  1686 	}
  1689 
  1687 
  1690 
  1688 
  1691 TInt TFsFileSetAtt::Initialise(CFsRequest* aRequest)
  1689 TInt TFsFileSetAtt::Initialise(CFsRequest* aRequest)
  1743 		return(KErrAccessDenied);
  1741 		return(KErrAccessDenied);
  1744 	
  1742 	
  1745 	TTime time;
  1743 	TTime time;
  1746 	TPtr8 t((TUint8*)&time,sizeof(TTime));
  1744 	TPtr8 t((TUint8*)&time,sizeof(TTime));
  1747 	aRequest->ReadL(KMsgPtr0,t);
  1745 	aRequest->ReadL(KMsgPtr0,t);
  1748 
  1746 	OstTraceExt3(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL2, "this %x aSetAttMask %x aClearAttMask %x", (TUint) &share->File(), (TUint) KEntryAttModified, (TUint) 0);
  1749 	TRACE5(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryL, EF32TraceUidFileSys, &share->File(), 0, 0, KEntryAttModified,0);
       
  1750 	TRAP(r,share->File().SetEntryL(time,KEntryAttModified,0))
  1747 	TRAP(r,share->File().SetEntryL(time,KEntryAttModified,0))
  1751 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryLRet, EF32TraceUidFileSys, r);
  1748 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL2RET, "r %d", r);
  1752 
       
  1753 	return(r);
  1749 	return(r);
  1754 	}
  1750 	}
  1755 
  1751 
  1756 
  1752 
  1757 TInt TFsFileSetModified::Initialise(CFsRequest* aRequest)
  1753 TInt TFsFileSetModified::Initialise(CFsRequest* aRequest)
  1792 	aRequest->ReadL(KMsgPtr0,t);
  1788 	aRequest->ReadL(KMsgPtr0,t);
  1793 	TUint setAttMask=(TUint)(aRequest->Message().Int1());
  1789 	TUint setAttMask=(TUint)(aRequest->Message().Int1());
  1794 	TUint clearAttMask=(TUint)aRequest->Message().Int2();
  1790 	TUint clearAttMask=(TUint)aRequest->Message().Int2();
  1795 	ValidateAtts(setAttMask,clearAttMask);//	Validate attributes
  1791 	ValidateAtts(setAttMask,clearAttMask);//	Validate attributes
  1796 
  1792 
  1797 	TRACE5(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryL, EF32TraceUidFileSys, &share->File(), 0, 0, setAttMask,clearAttMask);
  1793 	OstTraceExt3(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL3, "this %x aSetAttMask %x aClearAttMask %x", (TUint) &share->File(), (TUint) setAttMask, (TUint) clearAttMask);
  1798 	TRAP(r,share->File().SetEntryL(time,setAttMask|KEntryAttModified,clearAttMask))
  1794 	TRAP(r,share->File().SetEntryL(time,setAttMask|KEntryAttModified,clearAttMask))
  1799 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryLRet, EF32TraceUidFileSys, r);
  1795 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL3RET, "r %d", r);
  1800 
       
  1801 	return(r);
  1796 	return(r);
  1802 	}
  1797 	}
  1803 
  1798 
  1804 TInt TFsFileSet::Initialise(CFsRequest* aRequest)
  1799 TInt TFsFileSet::Initialise(CFsRequest* aRequest)
  1805 //
  1800 //
  1840 		return KErrAccessDenied;
  1835 		return KErrAccessDenied;
  1841 
  1836 
  1842 		// check if an attempt is made to change the share mode to EFileShareExclusive
  1837 		// check if an attempt is made to change the share mode to EFileShareExclusive
  1843 		// while the file has multiple readers
  1838 		// while the file has multiple readers
  1844 	if (newMode == EFileShareExclusive && (currentMode & KFileShareMask) != EFileShareExclusive)
  1839 	if (newMode == EFileShareExclusive && (currentMode & KFileShareMask) != EFileShareExclusive)
  1845 		{ 
  1840 		{
  1846 		// Check no other CFileCB is reading the file.
  1841 		// Check that this is the file's only fileshare/client
  1847 		FileShares->Lock();
  1842 		TDblQue<CFileShare>& aShareList = (&share->File())->FileShareList();
  1848 		TInt count=FileShares->Count();
  1843 		if (!(aShareList.IsFirst(share) && aShareList.IsLast(share)))
  1849 		TBool found=EFalse;
  1844 			return KErrAccessDenied;
  1850 		while(count--)
  1845 		}
  1851 			{
  1846 	
  1852 			CFileShare* fileShare=(CFileShare*)(*FileShares)[count];
       
  1853 			if (&fileShare->File()==&share->File())
       
  1854 				{
       
  1855 				if (found)
       
  1856 					{
       
  1857 					FileShares->Unlock();
       
  1858 					return(KErrAccessDenied);
       
  1859 					}
       
  1860 				found=ETrue;
       
  1861 				}
       
  1862 			}
       
  1863 		FileShares->Unlock();
       
  1864 		}
       
  1865 	share->iMode&=~KFileShareMask;
  1847 	share->iMode&=~KFileShareMask;
  1866 	share->iMode|=newMode;
  1848 	share->iMode|=newMode;
  1867 	share->File().SetShare(newMode);
  1849 	share->File().SetShare(newMode);
  1868 	return(KErrNone);
  1850 	return(KErrNone);
  1869 	}
  1851 	}
  1910 	if ((share->iMode&EFileWrite)==0)
  1892 	if ((share->iMode&EFileWrite)==0)
  1911 		return(KErrAccessDenied); // File must have write permission
  1893 		return(KErrAccessDenied); // File must have write permission
  1912 
  1894 
  1913 	TPtrC filePath = aRequest->Dest().FullName().Mid(2);
  1895 	TPtrC filePath = aRequest->Dest().FullName().Mid(2);
  1914 	CFileCB& file = share->File();
  1896 	CFileCB& file = share->File();
  1915 
  1897 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBRENAMEL, "this %x", (TUint) &file);
  1916 	TRACEMULT2(UTF::EBorder, UTraceModuleFileSys::ECFileCBRenameL, EF32TraceUidFileSys, 
  1898 	OstTraceData(TRACE_FILESYSTEM, FSYS_ECFILECBRENAMELYS_EFILENAME, "FileName %S", filePath.Ptr(), filePath.Length()<<1);
  1917 		(TUint) &file, filePath);
       
  1918 	TRAP(r,file.RenameL(filePath));
  1899 	TRAP(r,file.RenameL(filePath));
  1919 	TRACERETMULT1(UTF::EBorder, UTraceModuleFileSys::ECFileCBRenameLRet, EF32TraceUidFileSys, r);
  1900 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBRENAMELRET, "r %d", r);
  1920 
       
  1921 	// Re-write the file's folded name & re-calculate the hash
  1901 	// Re-write the file's folded name & re-calculate the hash
  1922 	if (r == KErrNone)
  1902 	if (r == KErrNone)
  1923 		{
  1903 		{
  1924 		TFileName filePathF;
  1904 		TFileName filePathF;
  1925 		filePathF.CopyF(filePath);
  1905 		filePathF.CopyF(filePath);
  2360 	// as CFileCache may steal it (!)
  2340 	// as CFileCache may steal it (!)
  2361 	if (FileCache())
  2341 	if (FileCache())
  2362 		FileCache()->Close();
  2342 		FileCache()->Close();
  2363 	if (iBody && iBody->iDeleteOnClose)
  2343 	if (iBody && iBody->iDeleteOnClose)
  2364 		{
  2344 		{
  2365 		TRACEMULT2(UTF::EBorder, UTraceModuleFileSys::ECMountCBDeleteL, EF32TraceUidFileSys, DriveNumber(), FileName());
  2345 		OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBDELETEL2, "drive %d", DriveNumber());
       
  2346 		OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBDELETEL2_EFILENAME, "FileName %S", FileName().Ptr(), FileName().Length()<<1);
  2366 		TInt r;
  2347 		TInt r;
  2367 		TRAP(r, iMount->DeleteL(FileName()));
  2348 		TRAP(r, iMount->DeleteL(FileName()));
  2368 		TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBDeleteLRet, EF32TraceUidFileSys, r);
  2349 		OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBDELETEL2RET, "r %d", r);
  2369 		}
  2350 		}
  2370 
  2351 
  2371 	if(iMount)
  2352 	if(iMount)
  2372 		iMount->Close();
  2353 		iMount->Close();
  2373 	if (iMountLink.iNext!=NULL)
  2354 	if (iMountLink.iNext!=NULL)
  2461 		}
  2442 		}
  2462 	}
  2443 	}
  2463 
  2444 
  2464 
  2445 
  2465 void CFileCB::PromoteShare(CFileShare* aShare)
  2446 void CFileCB::PromoteShare(CFileShare* aShare)
  2466 //
  2447 /**
  2467 // Manages share promotion after the share has been added to the FilsShares container.
  2448 	Manages share promotion and checks the EFileSequential file mode
  2468 //
  2449 	after the share has been added to the FileShares container.
  2469 //  - Assumes the share has already been validated using ValidateShare()
  2450 	
  2470 //
  2451 	It assumes the share has already been validated using ValidateShare().
  2471 //  - The count of promoted shares (ie - non-EFileShareReadersOrWriters) is incremented
  2452 	
  2472 //	  to allow the share mode to be demoted when the last promoted share is closed.
  2453 	The count of promoted shares (ie - non-EFileShareReadersOrWriters) is incremented
  2473 //
  2454 	to allow the share mode to be demoted when the last promoted share is closed.
       
  2455 	
       
  2456 	Similarly, the count of non-EFileSequential file modes is incremented to allow
       
  2457 	the file mode to be enabled when the last non-EFileSequential share is closed.
       
  2458  */
  2474 	{
  2459 	{
  2475 	TShare reqShare = (TShare)(aShare->iMode & KFileShareMask);
  2460 	TShare reqShare = (TShare)(aShare->iMode & KFileShareMask);
  2476 	if(reqShare != EFileShareReadersOrWriters)
  2461 	if(reqShare != EFileShareReadersOrWriters)
  2477 		{
  2462 		{
  2478 		iBody->iPromotedShares++;
  2463 		iBody->iPromotedShares++;
  2479 		iShare = reqShare;
  2464 		iShare = reqShare;
  2480 		}
  2465 		}
       
  2466 	
       
  2467 	// If the file mode is not EFileSequential, then disable the 'Sequential' flag
       
  2468 	if(!(aShare->iMode & EFileSequential))
       
  2469 		{
       
  2470 		iBody->iNonSequentialFileModes++;
       
  2471 		SetSequentialMode(EFalse);
       
  2472 		__PRINT(_L("CFileCB::PromoteShare - FileSequential mode is off"));
       
  2473 		}
  2481 	}
  2474 	}
  2482 
  2475 
  2483 
  2476 
  2484 void CFileCB::DemoteShare(CFileShare* aShare)
  2477 void CFileCB::DemoteShare(CFileShare* aShare)
  2485 //
  2478 /**
  2486 // Manages share demotion after the share has been removed from the FileShares container.
  2479 	Manages share demotion and checks the EFileSequential file mode
  2487 //
  2480 	after the share has been removed from the FileShares container.
  2488 //  - If the share being removed is not EFileShareReadersOrWriters, then the current
  2481 	
  2489 //	  share mode may require demotion back to EFileShareReadersOrWriters.
  2482 	If the share being removed is not EFileShareReadersOrWriters, then the current
  2490 //
  2483 	share mode may require demotion back to EFileShareReadersOrWriters.
  2491 //	- This is determined by the iPromotedShares count, incremented in PromoteShare()
  2484 	This is determined by the iPromotedShares count, incremented in PromoteShare().
  2492 //
  2485 	
  2493 	{
  2486 	Similarly, if the share being removed is non-EFileSequential,
  2494 	if((aShare->iMode & KFileShareMask) != EFileShareReadersOrWriters)
  2487 	then the EFileSequential flag may need to be enabled,
  2495 		{
  2488 	which is determined by the iNonSequentialFileModes count.
  2496 		if(--iBody->iPromotedShares == 0)
  2489  */
  2497 			{
  2490 	{
  2498 			// Don't worry if the file has never been opened as EFileShareReadersOrWriters
  2491 	if((aShare->iMode & KFileShareMask) != EFileShareReadersOrWriters
  2499 			//  - in this case the CFileCB object is about to be closed anyway.
  2492 		&& --iBody->iPromotedShares == 0)
  2500 			iShare = EFileShareReadersOrWriters;
  2493 		{
  2501 			}
  2494 		// Don't worry if the file has never been opened as EFileShareReadersOrWriters
  2502 		}
  2495 		//  - in this case the CFileCB object is about to be closed anyway.
  2503 	__ASSERT_DEBUG(iBody->iPromotedShares>=0,Fault(EFileShareBadPromoteCount));
  2496 		iShare = EFileShareReadersOrWriters;
       
  2497 		}
       
  2498 	__ASSERT_DEBUG(iBody->iPromotedShares>=0, Fault(EFileShareBadPromoteCount));
       
  2499 	
       
  2500 	if(!(aShare->iMode & EFileSequential) && --iBody->iNonSequentialFileModes == 0)
       
  2501 		{
       
  2502 		// As above, if the file has never been opened as EFileSequential,
       
  2503 		// it implies that the CFileCB object is about to be closed anyway.
       
  2504 		SetSequentialMode(ETrue);
       
  2505 		__PRINT(_L("CFileCB::PromoteShare - FileSequential mode is enabled"));
       
  2506 		}
       
  2507 	__ASSERT_DEBUG(iBody->iNonSequentialFileModes>=0, Fault(EFileShareBadPromoteCount));
  2504 	}
  2508 	}
  2505 
  2509 
  2506 
  2510 
  2507 RArray<TAsyncReadRequest>& CFileCB::AsyncReadRequests()
  2511 RArray<TAsyncReadRequest>& CFileCB::AsyncReadRequests()
  2508 //
  2512 //
  2733 		SetSize64(aSize, EFalse);	// assume not locked
  2737 		SetSize64(aSize, EFalse);	// assume not locked
  2734 	}
  2738 	}
  2735 
  2739 
  2736 /**
  2740 /**
  2737 Constructor.
  2741 Constructor.
  2738 Locks the mount resource to which the shared file resides.
  2742 Locks the mount resource to which the shared file resides
       
  2743 and adds the share to the file's FileShare List.
  2739 
  2744 
  2740 @param aFileCB File to be shared.
  2745 @param aFileCB File to be shared.
  2741 */
  2746 */
  2742 CFileShare::CFileShare(CFileCB* aFileCB)
  2747 CFileShare::CFileShare(CFileCB* aFileCB)
  2743 	: iFile(aFileCB)
  2748 	: iFile(aFileCB)
  2744 	{
  2749 	{
  2745 	AddResource(iFile->Mount());
  2750 	AddResource(iFile->Mount());
       
  2751 	iFile->AddShare(*this);
  2746 	}
  2752 	}
  2747 
  2753 
  2748 /**
  2754 /**
  2749 Destructor.
  2755 Destructor.
  2750 
  2756 
  2751 Frees mount resource to which the shared file resides,
  2757 Frees mount resource to which the shared file resides,
       
  2758 removes the share from the file's FileShare List,
  2752 removes share status from the shared file and finally closes
  2759 removes share status from the shared file and finally closes
  2753 the file.
  2760 the file.
  2754 */
  2761 */
  2755 CFileShare::~CFileShare()
  2762 CFileShare::~CFileShare()
  2756 	{
  2763 	{
  2757 	// We shouldn't be deleting the file share with a valid request queue or there will be request (& memory) leakage
  2764 	// We shouldn't be deleting the file share with a valid request queue or there will be request (& memory) leakage
  2758 	__ASSERT_DEBUG(iCurrentRequest == NULL, Fault(ERequestQueueNotEmpty));
  2765 	__ASSERT_DEBUG(iCurrentRequest == NULL, Fault(ERequestQueueNotEmpty));
  2759 
  2766 
  2760 	RemoveResource(iFile->Mount());
  2767 	RemoveResource(iFile->Mount());
       
  2768 	iShareLink.Deque();
  2761 	iFile->RemoveLocks(this);
  2769 	iFile->RemoveLocks(this);
  2762 	iFile->DemoteShare(this);
  2770 	iFile->DemoteShare(this);
  2763 	iFile->CancelAsyncReadRequest(this, NULL);
  2771 	iFile->CancelAsyncReadRequest(this, NULL);
  2764 	iFile->Close();
  2772 	iFile->Close();
  2765 	}
  2773 	}
  2954 	}
  2962 	}
  2955 
  2963 
  2956 void CFileCB::ReadL(TInt64 aPos,TInt& aLength,TDes8* aDes,const RMessagePtr2& aMessage, TInt aOffset)
  2964 void CFileCB::ReadL(TInt64 aPos,TInt& aLength,TDes8* aDes,const RMessagePtr2& aMessage, TInt aOffset)
  2957 	{
  2965 	{
  2958 	TRACETHREADID(aMessage);
  2966 	TRACETHREADID(aMessage);
  2959 	TRACE7(UTF::EBorder, UTraceModuleFileSys::ECFileCBReadL, EF32TraceUidFileSys, 
  2967 	OstTraceExt5(TRACE_FILESYSTEM, FSYS_ECFILECBREADLA, "this %x clientThreadId %x aPos %x:%x aLength %d", (TUint) this, (TUint) threadId, (TUint) I64HIGH(aPos), (TUint) I64LOW(aPos), (TUint) aLength);
  2960 		this, I64LOW(aPos), I64HIGH(aPos), aLength, aDes, threadId, aOffset);
       
  2961 
       
  2962 	iBody->iExtendedFileInterface->ReadL(aPos,aLength,aDes,aMessage,aOffset);
  2968 	iBody->iExtendedFileInterface->ReadL(aPos,aLength,aDes,aMessage,aOffset);
  2963 
  2969 
  2964 	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECFileCBReadLRet, EF32TraceUidFileSys, KErrNone);
  2970 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBREADLRET, "r %d", KErrNone);
  2965 	}
  2971 	}
  2966 
  2972 
  2967 void CFileCB::WriteL(TInt64 aPos,TInt& aLength,const TDesC8* aDes,const RMessagePtr2& aMessage, TInt aOffset)
  2973 void CFileCB::WriteL(TInt64 aPos,TInt& aLength,const TDesC8* aDes,const RMessagePtr2& aMessage, TInt aOffset)
  2968 	{
  2974 	{
  2969 	TRACETHREADID(aMessage);
  2975 	TRACETHREADID(aMessage);
  2970 	TRACE7(UTF::EBorder, UTraceModuleFileSys::ECFileCBWriteL, EF32TraceUidFileSys, 
  2976 	OstTraceExt5(TRACE_FILESYSTEM, FSYS_ECFILECBWRITEL, "this %x clientThreadId %x aPos %x:%x aLength %d", (TUint) this, (TUint) threadId, (TUint) I64HIGH(aPos), (TUint) I64LOW(aPos), (TUint) aLength);
  2971 		this, I64LOW(aPos), I64HIGH(aPos), aLength, aDes, threadId, aOffset);
       
  2972 
       
  2973 	iBody->iExtendedFileInterface->WriteL(aPos,aLength,aDes,aMessage,aOffset);
  2977 	iBody->iExtendedFileInterface->WriteL(aPos,aLength,aDes,aMessage,aOffset);
  2974 
  2978 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBWRITELRET, "r %d", KErrNone);
  2975 	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECFileCBWriteLRet, EF32TraceUidFileSys, KErrNone);
       
  2976 	}
  2979 	}
  2977 
  2980 
  2978 void CFileCB::SetSizeL(TInt64 aSize)
  2981 void CFileCB::SetSizeL(TInt64 aSize)
  2979 	{
  2982 	{
  2980 	TRACE3(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetSizeL, EF32TraceUidFileSys, this, I64LOW(aSize), I64HIGH(aSize));
  2983 	OstTraceExt3(TRACE_FILESYSTEM, FSYS_ECFILECBSETSIZEL, "this %x aSize %x:%x", (TUint) this, (TUint) I64HIGH(aSize), (TUint) I64LOW(aSize));
  2981 
       
  2982 	iBody->iExtendedFileInterface->SetSizeL(aSize);
  2984 	iBody->iExtendedFileInterface->SetSizeL(aSize);
  2983 
  2985 	OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBSETSIZELRET, "r %d", KErrNone);
  2984 	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetSizeLRet, EF32TraceUidFileSys, KErrNone);
       
  2985 	}
  2986 	}
  2986 
  2987 
  2987 TBool CFileCB::ExtendedFileInterfaceSupported()
  2988 TBool CFileCB::ExtendedFileInterfaceSupported()
  2988 	{
  2989 	{
  2989 	return iBody->ExtendedFileInterfaceSupported();
  2990 	return iBody->ExtendedFileInterfaceSupported();
  3025 	return iBody->iDeleteOnClose;
  3026 	return iBody->iDeleteOnClose;
  3026 	}
  3027 	}
  3027 
  3028 
  3028 TInt CFileCB::GetInterfaceTraced(TInt aInterfaceId, TAny*& aInterface, TAny* aInput)
  3029 TInt CFileCB::GetInterfaceTraced(TInt aInterfaceId, TAny*& aInterface, TAny* aInput)
  3029 	{
  3030 	{
  3030 	TRACE2(UTF::EBorder, UTraceModuleFileSys::ECFileCBGetInterface, EF32TraceUidFileSys, aInterfaceId, aInput);
  3031 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILECBGETINTERFACE, "aInterfaceId %d aInput %x", (TUint) aInterfaceId, (TUint) aInput);
  3031 
       
  3032 	TInt r = GetInterface(aInterfaceId, aInterface, aInput);
  3032 	TInt r = GetInterface(aInterfaceId, aInterface, aInput);
  3033 
  3033 	OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILECBGETINTERFACERET, "r %d aInterface %x", (TUint) r, (TUint) aInterface);
  3034 	TRACERET2(UTF::EBorder, UTraceModuleFileSys::ECFileCBGetInterfaceRet, EF32TraceUidFileSys, r, aInterface);
       
  3035 
       
  3036 	return r;
  3034 	return r;
  3037 	}
  3035 	}
  3038 
  3036 
  3039 CFileBody::CFileBody(CFileCB* aFileCB, CFileCB::MExtendedFileInterface* aExtendedFileInterface)
  3037 CFileBody::CFileBody(CFileCB* aFileCB, CFileCB::MExtendedFileInterface* aExtendedFileInterface)
  3040   : iFileCB(aFileCB),
  3038   : iFileCB(aFileCB),
  3041 	iExtendedFileInterface(aExtendedFileInterface ? aExtendedFileInterface : this),
  3039 	iExtendedFileInterface(aExtendedFileInterface ? aExtendedFileInterface : this),
       
  3040 	iShareList(_FOFF(CFileShare,iShareLink)),
  3042 	iSizeHigh(0)
  3041 	iSizeHigh(0)
  3043 	{
  3042 	{
  3044 	iFairSchedulingLen = TFileCacheSettings::FairSchedulingLen(iFileCB->DriveNumber());
  3043 	iFairSchedulingLen = TFileCacheSettings::FairSchedulingLen(iFileCB->DriveNumber());
  3045     iMaxSupportedFileSize = KMaxSupportedFileSize;
  3044     iMaxSupportedFileSize = KMaxSupportedFileSize;
  3046 	}
  3045 	}
  3110 	if (((share->iMode&EFileWrite)) || ((share->File().Att()&KEntryAttModified)))
  3109 	if (((share->iMode&EFileWrite)) || ((share->File().Att()&KEntryAttModified)))
  3111 		{
  3110 		{
  3112 		r=share->CheckMount();
  3111 		r=share->CheckMount();
  3113 		if (r!=KErrNone)
  3112 		if (r!=KErrNone)
  3114 			return(r);
  3113 			return(r);
  3115 
  3114 		OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBFLUSHDATAL2, "this %x", &share->File());
  3116 		TRACE1(UTF::EBorder, UTraceModuleFileSys::ECFileCBFlushDataL, EF32TraceUidFileSys, &share->File());
       
  3117 		TRAP(r,share->File().FlushDataL());
  3115 		TRAP(r,share->File().FlushDataL());
  3118 		TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECFileCBFlushDataLRet, EF32TraceUidFileSys, r);
  3116 		OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBFLUSHDATAL2RET, "r %d", r);
  3119 
       
  3120 		if(r!=KErrNone)
  3117 		if(r!=KErrNone)
  3121 			return(r);
  3118 			return(r);
  3122 		}
  3119 		}
  3123 
  3120 
  3124 	RFileClamp clamp;
  3121 	RFileClamp clamp;
  3588 
  3585 
  3589     return KErrNone;
  3586     return KErrNone;
  3590 	}
  3587 	}
  3591 
  3588 
  3592 
  3589 
       
  3590 //---------------------------------------------------------------------------------------------------------------------
       
  3591 /**
       
  3592 Gets the 'Sequential' mode of the file.
       
  3593 
       
  3594 @return	ETrue, if the file is in 'Sequential' mode
       
  3595 */
       
  3596 EXPORT_C TBool CFileCB::IsSequentialMode() const
       
  3597 	{
       
  3598 	return iBody->iSequential;
       
  3599 	}
       
  3600 
       
  3601 /**
       
  3602 Sets the 'Sequential' mode of the file.
       
  3603  */
       
  3604 void CFileCB::SetSequentialMode(TBool aSequential)
       
  3605 	{
       
  3606 	iBody->iSequential = aSequential;
       
  3607 	}
       
  3608 
       
  3609 //---------------------------------------------------------------------------------------------------------------------
       
  3610 /**
       
  3611 Gets the list containing the shares associated with the file.
       
  3612 
       
  3613 @return	The FileShare List
       
  3614 */
       
  3615 TDblQue<CFileShare>& CFileCB::FileShareList() const
       
  3616 	{
       
  3617 	return iBody->iShareList;
       
  3618 	}
       
  3619 
       
  3620 /**
       
  3621 Adds the share to the end of the FileShare List.
       
  3622 */
       
  3623 void CFileCB::AddShare(CFileShare& aFileShare)
       
  3624 	{
       
  3625 	iBody->iShareList.AddLast(aFileShare);
       
  3626 	}
       
  3627 
       
  3628 
  3593 //#####################################################################################################################
  3629 //#####################################################################################################################
  3594 //#  TFileShareLock class implementation
  3630 //#  TFileShareLock class implementation
  3595 //#####################################################################################################################
  3631 //#####################################################################################################################
  3596 
  3632 
  3597 TFileShareLock::TFileShareLock(const CFileShare* aOwner, TUint64 aPosLow, TUint64 aPosHigh) 
  3633 TFileShareLock::TFileShareLock(const CFileShare* aOwner, TUint64 aPosLow, TUint64 aPosHigh) 
  3636     }
  3672     }
  3637 
  3673 
  3638 
  3674 
  3639 
  3675 
  3640 
  3676 
  3641 
       
  3642 EXPORT_C TBool CFileCB::DirectIOMode(const RMessagePtr2& aMessage)
  3677 EXPORT_C TBool CFileCB::DirectIOMode(const RMessagePtr2& aMessage)
  3643 	{
  3678 	{
  3644 	CFsMessageRequest* msgRequest = CFsMessageRequest::RequestFromMessage(aMessage);
  3679 	CFsMessageRequest* msgRequest = CFsMessageRequest::RequestFromMessage(aMessage);
  3645 
  3680 
  3646 	TInt func = msgRequest->Operation()->Function();
  3681 	TInt func = msgRequest->Operation()->Function();
  3647 	ASSERT(func == EFsFileRead || func == EFsFileWrite || func == EFsFileWriteDirty  || func == EFsReadFileSection);
  3682 	ASSERT(func == EFsFileRead || func == EFsFileWrite || func == EFsFileWriteDirty || func == EFsReadFileSection);
  3648 
  3683 
  3649 	CFileShare* share;
  3684 	CFileShare* share;
  3650 	CFileCB* file;
  3685 	CFileCB* file;
  3651 	GetFileFromScratch(msgRequest, share, file);
  3686 	GetFileFromScratch(msgRequest, share, file);
  3652 	if (share == NULL)		// no share indicates this is a request originating from the file cache
  3687 	if (share == NULL)		// no share indicates this is a request originating from the file cache