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