697 else |
699 else |
698 { |
700 { |
699 // Current operation points to a local buffer |
701 // Current operation points to a local buffer |
700 // The request originated from the file server (e.g. file cache) with a local message handle (KLocalMessageHandle) |
702 // The request originated from the file server (e.g. file cache) with a local message handle (KLocalMessageHandle) |
701 TPtr8 dataDesc((TUint8*) currentOperation.iReadWriteArgs.iData + currentOperation.iReadWriteArgs.iOffset, len, len); |
703 TPtr8 dataDesc((TUint8*) currentOperation.iReadWriteArgs.iData + currentOperation.iReadWriteArgs.iOffset, len, len); |
702 const RLocalMessage msg; |
704 |
703 TRAP(r,file->ReadL(pos, len, &dataDesc, msg, 0)); |
705 // save the client's RMessage2 |
|
706 const RMessage2 msgClient = aRequest->Message(); |
|
707 |
|
708 // overwrite RMessage2 in CFsMessageRequest with RLocalMessage |
|
709 const RLocalMessage msgLocal; |
|
710 const_cast<RMessage2&> (aRequest->Message()) = msgLocal; |
|
711 |
|
712 TRAP(r,file->ReadL(pos, len, &dataDesc, aRequest->Message(), 0)); |
|
713 |
|
714 // restore the client's RMessage2 |
|
715 const_cast<RMessage2&> (aRequest->Message()) = msgClient; |
704 } |
716 } |
705 } |
717 } |
706 |
718 |
707 |
719 |
708 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
720 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
1095 TRAP(r,file->WriteL(pos, len, (const TPtrC8*) aRequest->Message().Ptr0(), aRequest->Message(), currentOperation.iReadWriteArgs.iOffset)) |
1104 TRAP(r,file->WriteL(pos, len, (const TPtrC8*) aRequest->Message().Ptr0(), aRequest->Message(), currentOperation.iReadWriteArgs.iOffset)) |
1096 } |
1105 } |
1097 else |
1106 else |
1098 { |
1107 { |
1099 TPtr8 dataDesc((TUint8*) currentOperation.iReadWriteArgs.iData + currentOperation.iReadWriteArgs.iOffset, len, len); |
1108 TPtr8 dataDesc((TUint8*) currentOperation.iReadWriteArgs.iData + currentOperation.iReadWriteArgs.iOffset, len, len); |
1100 const RLocalMessage msg; |
1109 |
1101 TRAP(r,file->WriteL(pos, len, &dataDesc, msg, 0)); |
1110 // save the client's RMessage2 |
|
1111 const RMessage2 msgClient = aRequest->Message(); |
|
1112 |
|
1113 // overwrite RMessage2 in CFsMessageRequest with RLocalMessage |
|
1114 const RLocalMessage msgLocal; |
|
1115 const_cast<RMessage2&> (aRequest->Message()) = msgLocal; |
|
1116 |
|
1117 TRAP(r,file->WriteL(pos, len, &dataDesc, aRequest->Message(), 0)); |
|
1118 |
|
1119 // restore the client's RMessage2 |
|
1120 const_cast<RMessage2&> (aRequest->Message()) = msgClient; |
1102 } |
1121 } |
1103 } |
1122 } |
1104 |
1123 |
1105 //RDebug::Print(_L("WriteR: req %08X pos %ld\t len %d file %08X\n"), aRequest, pos, len, file); |
1124 //RDebug::Print(_L("WriteR: req %08X pos %ld\t len %d file %08X\n"), aRequest, pos, len, file); |
1106 |
1125 |
1492 if ((share->iMode&EFileWrite)==0) |
1511 if ((share->iMode&EFileWrite)==0) |
1493 return(KErrAccessDenied); |
1512 return(KErrAccessDenied); |
1494 r=share->CheckMount(); |
1513 r=share->CheckMount(); |
1495 if (r!=KErrNone) |
1514 if (r!=KErrNone) |
1496 return(r); |
1515 return(r); |
1497 |
1516 OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBFLUSHDATAL1, "this %x", &share->File()); |
1498 TRACE1(UTF::EBorder, UTraceModuleFileSys::ECFileCBFlushDataL, EF32TraceUidFileSys, &share->File()); |
|
1499 TRAP(r,share->File().FlushDataL()); |
1517 TRAP(r,share->File().FlushDataL()); |
1500 TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECFileCBFlushDataLRet, EF32TraceUidFileSys, r); |
1518 OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBFLUSHDATAL1RET, "r %d", r); |
1501 |
|
1502 return(r); |
1519 return(r); |
1503 } |
1520 } |
1504 |
1521 |
1505 TInt TFsFileFlush::Initialise(CFsRequest* aRequest) |
1522 TInt TFsFileFlush::Initialise(CFsRequest* aRequest) |
1506 // |
1523 // |
1664 if ((share->iMode&EFileWrite)==EFalse) |
1681 if ((share->iMode&EFileWrite)==EFalse) |
1665 return(KErrAccessDenied); |
1682 return(KErrAccessDenied); |
1666 |
1683 |
1667 TUint setAttMask=(TUint)(aRequest->Message().Int0()); |
1684 TUint setAttMask=(TUint)(aRequest->Message().Int0()); |
1668 TUint clearAttMask=(TUint)aRequest->Message().Int1(); |
1685 TUint clearAttMask=(TUint)aRequest->Message().Int1(); |
1669 ValidateAtts(share->File().Att(),setAttMask,clearAttMask); |
1686 ValidateAtts(setAttMask,clearAttMask); |
1670 |
1687 OstTraceExt3(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL1, "this %x aSetAttMask %x aClearAttMask %x", (TUint) &share->File(), (TUint) setAttMask, (TUint) clearAttMask); |
1671 TRACE5(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryL, EF32TraceUidFileSys, &share->File(), 0, 0, setAttMask,clearAttMask); |
|
1672 TRAP(r,share->File().SetEntryL(TTime(0),setAttMask,clearAttMask)) |
1688 TRAP(r,share->File().SetEntryL(TTime(0),setAttMask,clearAttMask)) |
1673 TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryLRet, EF32TraceUidFileSys, r); |
1689 OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL1RET, "r %d", r); |
1674 |
|
1675 return(r); |
1690 return(r); |
1676 } |
1691 } |
1677 |
1692 |
1678 |
1693 |
1679 TInt TFsFileSetAtt::Initialise(CFsRequest* aRequest) |
1694 TInt TFsFileSetAtt::Initialise(CFsRequest* aRequest) |
1731 return(KErrAccessDenied); |
1746 return(KErrAccessDenied); |
1732 |
1747 |
1733 TTime time; |
1748 TTime time; |
1734 TPtr8 t((TUint8*)&time,sizeof(TTime)); |
1749 TPtr8 t((TUint8*)&time,sizeof(TTime)); |
1735 aRequest->ReadL(KMsgPtr0,t); |
1750 aRequest->ReadL(KMsgPtr0,t); |
1736 |
1751 OstTraceExt3(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL2, "this %x aSetAttMask %x aClearAttMask %x", (TUint) &share->File(), (TUint) KEntryAttModified, (TUint) 0); |
1737 TRACE5(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryL, EF32TraceUidFileSys, &share->File(), 0, 0, KEntryAttModified,0); |
|
1738 TRAP(r,share->File().SetEntryL(time,KEntryAttModified,0)) |
1752 TRAP(r,share->File().SetEntryL(time,KEntryAttModified,0)) |
1739 TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryLRet, EF32TraceUidFileSys, r); |
1753 OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL2RET, "r %d", r); |
1740 |
|
1741 return(r); |
1754 return(r); |
1742 } |
1755 } |
1743 |
1756 |
1744 |
1757 |
1745 TInt TFsFileSetModified::Initialise(CFsRequest* aRequest) |
1758 TInt TFsFileSetModified::Initialise(CFsRequest* aRequest) |
1778 TTime time; |
1791 TTime time; |
1779 TPtr8 t((TUint8*)&time,sizeof(TTime)); |
1792 TPtr8 t((TUint8*)&time,sizeof(TTime)); |
1780 aRequest->ReadL(KMsgPtr0,t); |
1793 aRequest->ReadL(KMsgPtr0,t); |
1781 TUint setAttMask=(TUint)(aRequest->Message().Int1()|KEntryAttModified); |
1794 TUint setAttMask=(TUint)(aRequest->Message().Int1()|KEntryAttModified); |
1782 TUint clearAttMask=(TUint)aRequest->Message().Int2(); |
1795 TUint clearAttMask=(TUint)aRequest->Message().Int2(); |
1783 ValidateAtts(share->File().Att(),setAttMask,clearAttMask);// Validate attributes |
1796 ValidateAtts(setAttMask,clearAttMask);// Validate attributes |
1784 |
1797 |
1785 TRACE5(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryL, EF32TraceUidFileSys, &share->File(), 0, 0, setAttMask,clearAttMask); |
1798 OstTraceExt3(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL3, "this %x aSetAttMask %x aClearAttMask %x", (TUint) &share->File(), (TUint) setAttMask, (TUint) clearAttMask); |
1786 TRAP(r,share->File().SetEntryL(time,setAttMask,clearAttMask)) |
1799 TRAP(r,share->File().SetEntryL(time,setAttMask,clearAttMask)) |
1787 TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetEntryLRet, EF32TraceUidFileSys, r); |
1800 OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBSETENTRYL3RET, "r %d", r); |
1788 |
|
1789 return(r); |
1801 return(r); |
1790 } |
1802 } |
1791 |
1803 |
1792 TInt TFsFileSet::Initialise(CFsRequest* aRequest) |
1804 TInt TFsFileSet::Initialise(CFsRequest* aRequest) |
1793 // |
1805 // |
1885 if ((share->iMode&EFileWrite)==0) |
1897 if ((share->iMode&EFileWrite)==0) |
1886 return(KErrAccessDenied); // File must have write permission |
1898 return(KErrAccessDenied); // File must have write permission |
1887 |
1899 |
1888 TPtrC filePath = aRequest->Dest().FullName().Mid(2); |
1900 TPtrC filePath = aRequest->Dest().FullName().Mid(2); |
1889 CFileCB& file = share->File(); |
1901 CFileCB& file = share->File(); |
1890 |
1902 OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBRENAMEL, "this %x", (TUint) &file); |
1891 TRACEMULT2(UTF::EBorder, UTraceModuleFileSys::ECFileCBRenameL, EF32TraceUidFileSys, |
1903 OstTraceData(TRACE_FILESYSTEM, FSYS_ECFILECBRENAMELYS_EFILENAME, "FileName %S", filePath.Ptr(), filePath.Length()<<1); |
1892 (TUint) &file, filePath); |
|
1893 TRAP(r,file.RenameL(filePath)); |
1904 TRAP(r,file.RenameL(filePath)); |
1894 TRACERETMULT1(UTF::EBorder, UTraceModuleFileSys::ECFileCBRenameLRet, EF32TraceUidFileSys, r); |
1905 OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBRENAMELRET, "r %d", r); |
1895 |
|
1896 // Re-write the file's folded name & re-calculate the hash |
1906 // Re-write the file's folded name & re-calculate the hash |
1897 if (r == KErrNone) |
1907 if (r == KErrNone) |
1898 { |
1908 { |
1899 TFileName filePathF; |
1909 TFileName filePathF; |
1900 filePathF.CopyF(filePath); |
1910 filePathF.CopyF(filePath); |
2335 // as CFileCache may steal it (!) |
2345 // as CFileCache may steal it (!) |
2336 if (FileCache()) |
2346 if (FileCache()) |
2337 FileCache()->Close(); |
2347 FileCache()->Close(); |
2338 if (iBody && iBody->iDeleteOnClose) |
2348 if (iBody && iBody->iDeleteOnClose) |
2339 { |
2349 { |
2340 TRACEMULT2(UTF::EBorder, UTraceModuleFileSys::ECMountCBDeleteL, EF32TraceUidFileSys, DriveNumber(), FileName()); |
2350 OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBDELETEL2, "drive %d", DriveNumber()); |
|
2351 OstTraceData(TRACE_FILESYSTEM, FSYS_ECMOUNTCBDELETEL2_EFILENAME, "FileName %S", FileName().Ptr(), FileName().Length()<<1); |
2341 TInt r; |
2352 TInt r; |
2342 TRAP(r, iMount->DeleteL(FileName())); |
2353 TRAP(r, iMount->DeleteL(FileName())); |
2343 TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECMountCBDeleteLRet, EF32TraceUidFileSys, r); |
2354 OstTrace1(TRACE_FILESYSTEM, FSYS_ECMOUNTCBDELETEL2RET, "r %d", r); |
2344 } |
2355 } |
2345 |
2356 |
2346 if(iMount) |
2357 if(iMount) |
2347 iMount->Close(); |
2358 iMount->Close(); |
2348 if (iMountLink.iNext!=NULL) |
2359 if (iMountLink.iNext!=NULL) |
2956 } |
2967 } |
2957 |
2968 |
2958 void CFileCB::ReadL(TInt64 aPos,TInt& aLength,TDes8* aDes,const RMessagePtr2& aMessage, TInt aOffset) |
2969 void CFileCB::ReadL(TInt64 aPos,TInt& aLength,TDes8* aDes,const RMessagePtr2& aMessage, TInt aOffset) |
2959 { |
2970 { |
2960 TRACETHREADID(aMessage); |
2971 TRACETHREADID(aMessage); |
2961 TRACE7(UTF::EBorder, UTraceModuleFileSys::ECFileCBReadL, EF32TraceUidFileSys, |
2972 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); |
2962 this, I64LOW(aPos), I64HIGH(aPos), aLength, aDes, threadId, aOffset); |
|
2963 |
|
2964 iBody->iExtendedFileInterface->ReadL(aPos,aLength,aDes,aMessage,aOffset); |
2973 iBody->iExtendedFileInterface->ReadL(aPos,aLength,aDes,aMessage,aOffset); |
2965 |
2974 |
2966 TRACE1(UTF::EBorder, UTraceModuleFileSys::ECFileCBReadLRet, EF32TraceUidFileSys, KErrNone); |
2975 OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBREADLRET, "r %d", KErrNone); |
2967 } |
2976 } |
2968 |
2977 |
2969 void CFileCB::WriteL(TInt64 aPos,TInt& aLength,const TDesC8* aDes,const RMessagePtr2& aMessage, TInt aOffset) |
2978 void CFileCB::WriteL(TInt64 aPos,TInt& aLength,const TDesC8* aDes,const RMessagePtr2& aMessage, TInt aOffset) |
2970 { |
2979 { |
2971 TRACETHREADID(aMessage); |
2980 TRACETHREADID(aMessage); |
2972 TRACE7(UTF::EBorder, UTraceModuleFileSys::ECFileCBWriteL, EF32TraceUidFileSys, |
2981 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); |
2973 this, I64LOW(aPos), I64HIGH(aPos), aLength, aDes, threadId, aOffset); |
|
2974 |
|
2975 iBody->iExtendedFileInterface->WriteL(aPos,aLength,aDes,aMessage,aOffset); |
2982 iBody->iExtendedFileInterface->WriteL(aPos,aLength,aDes,aMessage,aOffset); |
2976 |
2983 OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBWRITELRET, "r %d", KErrNone); |
2977 TRACE1(UTF::EBorder, UTraceModuleFileSys::ECFileCBWriteLRet, EF32TraceUidFileSys, KErrNone); |
|
2978 } |
2984 } |
2979 |
2985 |
2980 void CFileCB::SetSizeL(TInt64 aSize) |
2986 void CFileCB::SetSizeL(TInt64 aSize) |
2981 { |
2987 { |
2982 TRACE3(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetSizeL, EF32TraceUidFileSys, this, I64LOW(aSize), I64HIGH(aSize)); |
2988 OstTraceExt3(TRACE_FILESYSTEM, FSYS_ECFILECBSETSIZEL, "this %x aSize %x:%x", (TUint) this, (TUint) I64HIGH(aSize), (TUint) I64LOW(aSize)); |
2983 |
|
2984 iBody->iExtendedFileInterface->SetSizeL(aSize); |
2989 iBody->iExtendedFileInterface->SetSizeL(aSize); |
2985 |
2990 OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBSETSIZELRET, "r %d", KErrNone); |
2986 TRACE1(UTF::EBorder, UTraceModuleFileSys::ECFileCBSetSizeLRet, EF32TraceUidFileSys, KErrNone); |
|
2987 } |
2991 } |
2988 |
2992 |
2989 TBool CFileCB::ExtendedFileInterfaceSupported() |
2993 TBool CFileCB::ExtendedFileInterfaceSupported() |
2990 { |
2994 { |
2991 return iBody->ExtendedFileInterfaceSupported(); |
2995 return iBody->ExtendedFileInterfaceSupported(); |
3027 return iBody->iDeleteOnClose; |
3031 return iBody->iDeleteOnClose; |
3028 } |
3032 } |
3029 |
3033 |
3030 TInt CFileCB::GetInterfaceTraced(TInt aInterfaceId, TAny*& aInterface, TAny* aInput) |
3034 TInt CFileCB::GetInterfaceTraced(TInt aInterfaceId, TAny*& aInterface, TAny* aInput) |
3031 { |
3035 { |
3032 TRACE2(UTF::EBorder, UTraceModuleFileSys::ECFileCBGetInterface, EF32TraceUidFileSys, aInterfaceId, aInput); |
3036 OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILECBGETINTERFACE, "aInterfaceId %d aInput %x", (TUint) aInterfaceId, (TUint) aInput); |
3033 |
|
3034 TInt r = GetInterface(aInterfaceId, aInterface, aInput); |
3037 TInt r = GetInterface(aInterfaceId, aInterface, aInput); |
3035 |
3038 OstTraceExt2(TRACE_FILESYSTEM, FSYS_ECFILECBGETINTERFACERET, "r %d aInterface %x", (TUint) r, (TUint) aInterface); |
3036 TRACERET2(UTF::EBorder, UTraceModuleFileSys::ECFileCBGetInterfaceRet, EF32TraceUidFileSys, r, aInterface); |
|
3037 |
|
3038 return r; |
3039 return r; |
3039 } |
3040 } |
3040 |
3041 |
3041 CFileBody::CFileBody(CFileCB* aFileCB, CFileCB::MExtendedFileInterface* aExtendedFileInterface) |
3042 CFileBody::CFileBody(CFileCB* aFileCB, CFileCB::MExtendedFileInterface* aExtendedFileInterface) |
3042 : iFileCB(aFileCB), |
3043 : iFileCB(aFileCB), |
3113 if (((share->iMode&EFileWrite)) || ((share->File().Att()&KEntryAttModified))) |
3114 if (((share->iMode&EFileWrite)) || ((share->File().Att()&KEntryAttModified))) |
3114 { |
3115 { |
3115 r=share->CheckMount(); |
3116 r=share->CheckMount(); |
3116 if (r!=KErrNone) |
3117 if (r!=KErrNone) |
3117 return(r); |
3118 return(r); |
3118 |
3119 OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBFLUSHDATAL2, "this %x", &share->File()); |
3119 TRACE1(UTF::EBorder, UTraceModuleFileSys::ECFileCBFlushDataL, EF32TraceUidFileSys, &share->File()); |
|
3120 TRAP(r,share->File().FlushDataL()); |
3120 TRAP(r,share->File().FlushDataL()); |
3121 TRACERET1(UTF::EBorder, UTraceModuleFileSys::ECFileCBFlushDataLRet, EF32TraceUidFileSys, r); |
3121 OstTrace1(TRACE_FILESYSTEM, FSYS_ECFILECBFLUSHDATAL2RET, "r %d", r); |
3122 |
|
3123 if(r!=KErrNone) |
3122 if(r!=KErrNone) |
3124 return(r); |
3123 return(r); |
3125 } |
3124 } |
3126 |
3125 |
3127 RFileClamp clamp; |
3126 RFileClamp clamp; |
3440 @param aSize The size of the file. |
3439 @param aSize The size of the file. |
3441 @param aDriveLocked The status of the Drive Lock. If it is EFalse, |
3440 @param aDriveLocked The status of the Drive Lock. If it is EFalse, |
3442 the file size shall be modified after acquiring the iLock mutex and if it is ETrue, |
3441 the file size shall be modified after acquiring the iLock mutex and if it is ETrue, |
3443 the file size shall be modified without aquiring the iLock mutex. |
3442 the file size shall be modified without aquiring the iLock mutex. |
3444 */ |
3443 */ |
3445 EXPORT_C void CFileCB::SetSize64(TInt64 aSize, TBool aDriveLocked) |
3444 EXPORT_C void CFileCB::SetSize64(TInt64 aSize, TBool /*aDriveLocked*/) |
3446 { |
3445 { |
3447 if(aDriveLocked) |
3446 // cuurently this should only be called from the drive thread |
3448 { |
3447 ASSERT(FsThreadManager::IsDriveThread(Drive().DriveNumber(),EFalse)); |
3449 iSize = (TInt)I64LOW(aSize); |
3448 iSize = (TInt)I64LOW(aSize); |
3450 iBody->iSizeHigh = (TInt)I64HIGH(aSize); |
3449 iBody->iSizeHigh = (TInt)I64HIGH(aSize); |
3451 } |
|
3452 else |
|
3453 { |
|
3454 Drive().Lock(); |
|
3455 iSize = (TInt)I64LOW(aSize); |
|
3456 iBody->iSizeHigh = (TInt)I64HIGH(aSize); |
|
3457 Drive().UnLock(); |
|
3458 } |
|
3459 } |
3450 } |
3460 |
3451 |
3461 |
3452 |
3462 /** used to organize key comparison for the TFileShareLock*/ |
3453 /** used to organize key comparison for the TFileShareLock*/ |
3463 TInt LockOrder(const TFileShareLock& aMatch, const TFileShareLock& anEntry) |
3454 TInt LockOrder(const TFileShareLock& aMatch, const TFileShareLock& anEntry) |