userlibandfileserver/fileserver/sfile/sf_file.cpp
branchRCL_3
changeset 42 a179b74831c9
parent 41 0ffb4e86fcc9
child 43 c1f20ce4abcf
--- a/userlibandfileserver/fileserver/sfile/sf_file.cpp	Thu Jul 15 20:11:42 2010 +0300
+++ b/userlibandfileserver/fileserver/sfile/sf_file.cpp	Thu Aug 19 11:14:22 2010 +0300
@@ -699,8 +699,18 @@
 			// Current operation points to a local buffer
 			// The request originated from the file server (e.g. file cache) with a local message handle (KLocalMessageHandle)
 			TPtr8 dataDesc((TUint8*) currentOperation.iReadWriteArgs.iData + currentOperation.iReadWriteArgs.iOffset, len, len);
-			const RLocalMessage msg;
-			TRAP(r,file->ReadL(pos, len, &dataDesc, msg, 0));
+
+			// save the client's RMessage2
+			const RMessage2 msgClient = aRequest->Message();
+			
+			// overwrite RMessage2 in CFsMessageRequest with RLocalMessage 
+			const RLocalMessage msgLocal;					
+			const_cast<RMessage2&> (aRequest->Message()) = msgLocal;
+
+			TRAP(r,file->ReadL(pos, len, &dataDesc, aRequest->Message(), 0));
+							
+			// restore the client's RMessage2
+			const_cast<RMessage2&> (aRequest->Message()) = msgClient;
 			}
 		}
 
@@ -958,10 +968,6 @@
         {//-- this call is originated from explicit file write operation. Set 'Archive' attribute and new file time.
         aFile->SetArchiveAttribute(); //-- it will also set KEntryAttModified
         }
-    else
-        {//-- don't touch data and attributes if it is cache flushing dirty data
-        aFile->iAtt |= KEntryAttModified;
-        }
 
 
 	return KErrNone;
@@ -1094,8 +1100,18 @@
 		else
 			{
 			TPtr8 dataDesc((TUint8*) currentOperation.iReadWriteArgs.iData + currentOperation.iReadWriteArgs.iOffset, len, len);
-			const RLocalMessage msg;
-			TRAP(r,file->WriteL(pos, len, &dataDesc, msg, 0));
+
+			// save the client's RMessage2
+			const RMessage2 msgClient = aRequest->Message();
+			
+			// overwrite RMessage2 in CFsMessageRequest with RLocalMessage 
+			const RLocalMessage msgLocal;					
+			const_cast<RMessage2&> (aRequest->Message()) = msgLocal;
+
+			TRAP(r,file->WriteL(pos, len, &dataDesc, aRequest->Message(), 0));
+							
+			// restore the client's RMessage2
+			const_cast<RMessage2&> (aRequest->Message()) = msgClient;
 			}
 		}
 
@@ -1567,13 +1583,11 @@
 	
 	CFileCB& file=share->File();
 
-	// flush the write cache
-	CFileCache* fileCache = share->File().FileCache();
-	if (fileCache && (r = fileCache->FlushDirty(aRequest)) != CFsRequest::EReqActionComplete)
-		return r;
-	
 	if (size==file.Size64())
+		{
+		file.SetCachedSize64(size);	// Ensure the cache size doesn't exceeed the physical size
 		return(KErrNone);
+		}
 	
 	TBool fileHasGrown = size > file.Size64();
 	if (fileHasGrown)
@@ -1627,6 +1641,7 @@
 	CFileShare* share=(CFileShare*)aRequest->ScratchValue();
 //	TInt att=(TInt)aRequest->FileShare()->File().Att()&KEntryAttMaskSupported;
 	TInt att=(TInt)share->File().Att();	// DRM: let ROM XIP attribute through
+	att&= ~KEntryAttModified;	// this is an internal attribute and should not be returned to the client
 	TPtrC8 pA((TUint8*)&att,sizeof(TInt));
 	aRequest->WriteL(KMsgPtr0,pA);
 	
@@ -1666,7 +1681,7 @@
 	ValidateAtts(setAttMask,clearAttMask);
 
 	TRACE5(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryL, EF32TraceUidFileSys, &share->File(), 0, 0, setAttMask,clearAttMask);
-	TRAP(r,share->File().SetEntryL(TTime(0),setAttMask,clearAttMask))
+	TRAP(r,share->File().SetEntryL(share->File().Modified(),setAttMask,clearAttMask))
 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryLRet, EF32TraceUidFileSys, r);
 
 	return(r);
@@ -1775,12 +1790,12 @@
     TTime time;
 	TPtr8 t((TUint8*)&time,sizeof(TTime));
 	aRequest->ReadL(KMsgPtr0,t);
-	TUint setAttMask=(TUint)(aRequest->Message().Int1()|KEntryAttModified);
+	TUint setAttMask=(TUint)(aRequest->Message().Int1());
 	TUint clearAttMask=(TUint)aRequest->Message().Int2();
 	ValidateAtts(setAttMask,clearAttMask);//	Validate attributes
 
 	TRACE5(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryL, EF32TraceUidFileSys, &share->File(), 0, 0, setAttMask,clearAttMask);
-	TRAP(r,share->File().SetEntryL(time,setAttMask,clearAttMask))
+	TRAP(r,share->File().SetEntryL(time,setAttMask|KEntryAttModified,clearAttMask))
 	TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryLRet, EF32TraceUidFileSys, r);
 
 	return(r);
@@ -3624,13 +3639,25 @@
 
 
 
-
-
-
-
-
-
-
-
-
-
+EXPORT_C TBool CFileCB::DirectIOMode(const RMessagePtr2& aMessage)
+	{
+	CFsMessageRequest* msgRequest = CFsMessageRequest::RequestFromMessage(aMessage);
+
+	TInt func = msgRequest->Operation()->Function();
+	ASSERT(func == EFsFileRead || func == EFsFileWrite || func == EFsFileWriteDirty  || func == EFsReadFileSection);
+
+	CFileShare* share;
+	CFileCB* file;
+	GetFileFromScratch(msgRequest, share, file);
+	if (share == NULL)		// no share indicates this is a request originating from the file cache
+		return EFalse;
+
+	return func == EFsFileRead ? share->iMode & EFileReadDirectIO : share->iMode & EFileWriteDirectIO; 
+	}
+
+
+
+
+
+
+