|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Based on the test code under f32test\fsstress |
|
15 * |
|
16 */ |
|
17 |
|
18 #if !defined(__SVPHOSTFSY_H__) |
|
19 #define __SVPHOSTFSY_H__ |
|
20 |
|
21 #include <f32fsys.h> |
|
22 #include <f32file.h> |
|
23 #include <e32test.h> |
|
24 #include <e32hal.h> |
|
25 #include <e32math.h> |
|
26 #include <f32dbg.h> |
|
27 |
|
28 #include <rsvphostfsdriver.h> |
|
29 |
|
30 // |
|
31 // Common constants used by both EFSRV and the filesystems |
|
32 // |
|
33 |
|
34 const TUint KEntryAttIllegal=(KEntryAttVolume|KEntryAttDir); |
|
35 const TUint KEntryAttModified=0x20000000; |
|
36 const TUint KEntryAttMustBeFile=0x80000000; |
|
37 const TInt KCurrentPosition=KMinTInt; |
|
38 |
|
39 |
|
40 GLDEF_D const TInt KMaxParses=7; |
|
41 GLDEF_D const TInt KHeapSize=0x2000; |
|
42 GLREF_C void TurnAllocFailureOff(); |
|
43 GLREF_C void TurnAllocFailureOn(); |
|
44 GLREF_C void ReportCheckDiskFailure(TInt aRet); |
|
45 GLREF_D RTest test; |
|
46 GLREF_D TFileName gSessionPath; |
|
47 GLREF_D TInt gAllocFailOff; |
|
48 GLREF_D TInt gAllocFailOn; |
|
49 |
|
50 #if defined(_DEBUG) |
|
51 #define SetAllocFailure(a) SetAllocFailure(a) |
|
52 #else |
|
53 #define SetAllocFailure(a) IsRomAddress(NULL) |
|
54 #define KAllocFailureOn 0 |
|
55 #define KAllocFailureOff 0 |
|
56 #endif |
|
57 |
|
58 // Debug virtual host file service - uncomment define below |
|
59 //#define SVPDBG |
|
60 #ifdef SVPDBG |
|
61 IMPORT_C TUint32 DebugRegister(); |
|
62 #define DP(format...) { if (DebugRegister()&KFSYS) RDebug::Print(format);} |
|
63 #else |
|
64 #define DP(format...) |
|
65 #endif |
|
66 |
|
67 #define SVP_HOST_FS_DEVICE() (((CSVPHostMountCB&)Mount()).Device()) |
|
68 #define SVP_HOST_FS_DEVICE_ID 0xc51d0008 |
|
69 |
|
70 enum TPanic |
|
71 { |
|
72 EFileTimeToSystemTime, |
|
73 EFileClose, |
|
74 EFileCloseSetAttributes, |
|
75 EDirClose, |
|
76 EMapCouldNotConnect |
|
77 }; |
|
78 |
|
79 // utility to convert file system times to TTime format |
|
80 void fileTimeToTime(TUint32 t,TTime& aTime, TFileTimeType aType); |
|
81 |
|
82 // utility to produce a canonicalized pathname (i.e. with a drive letter) suitable to pass to the FS device. |
|
83 |
|
84 void CanonicalizePathname(const TDesC& aName, TInt aDrive, THostFileName& aHostName); |
|
85 |
|
86 class CSessionFs; |
|
87 |
|
88 class CSVPHostMountCB : public CMountCB |
|
89 { |
|
90 public: |
|
91 CSVPHostMountCB(); |
|
92 ~CSVPHostMountCB(); |
|
93 void MountL(TBool aForceMount); |
|
94 TInt ReMount(); |
|
95 void Dismounted(); |
|
96 void VolumeL(TVolumeInfo& aVolume) const; |
|
97 void SetVolumeL(TDes& aName); |
|
98 void MkDirL(const TDesC& aName); |
|
99 void RmDirL(const TDesC& aName); |
|
100 void DeleteL(const TDesC& aName); |
|
101 void RenameL(const TDesC& anOldName,const TDesC& anNewName); |
|
102 void ReplaceL(const TDesC& anOldName,const TDesC& anNewName); |
|
103 void EntryL(const TDesC& aName,TEntry& anEntry) const; |
|
104 void SetEntryL(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask); |
|
105 void FileOpenL(const TDesC& aName,TUint aMode,TFileOpen anOpen,CFileCB* aFile); |
|
106 void DirOpenL(const TDesC& aName,CDirCB* aDir); |
|
107 void RawReadL(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt anOffset,const RMessagePtr2& aMessage) const; |
|
108 void RawWriteL(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt anOffset,const RMessagePtr2& aMessage); |
|
109 void ReadUidL(const TDesC& aName,TEntry& anEntry) const; |
|
110 void GetShortNameL(const TDesC& aLongName,TDes& aShortName); |
|
111 void GetLongNameL(const TDesC& aShortName,TDes& aLongName); |
|
112 void IsFileInRom(const TDesC& aFileName,TUint8*& aFileStart); |
|
113 void ReadSectionL(const TDesC& aName,TInt aPos,TAny* aTrg,TInt aLength,const RMessagePtr2& aMessage); |
|
114 |
|
115 inline const CSVPHostMountCB& Mount() const { return *this; } |
|
116 inline RSVPHostFsDriver& Device() { return iDevice; } |
|
117 |
|
118 |
|
119 private: |
|
120 TBool IsRomDrive() const; |
|
121 RSVPHostFsDriver iDevice; |
|
122 }; |
|
123 |
|
124 |
|
125 class RConsole; |
|
126 class CSVPHostFileCB : public CFileCB |
|
127 { |
|
128 public: |
|
129 CSVPHostFileCB(); |
|
130 ~CSVPHostFileCB(); |
|
131 void RenameL(const TDesC& aNewName); |
|
132 void ReadL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage); |
|
133 void WriteL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage); |
|
134 TInt Address(TInt& aPos) const; |
|
135 void SetSizeL(TInt aSize); |
|
136 void SetEntryL(const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask); |
|
137 void FlushDataL(); |
|
138 void FlushAllL(); |
|
139 void CheckPos(TInt aPos); |
|
140 void SetHandle(TUint aHandle) { iHandle = aHandle; } |
|
141 TUint Handle() const { return iHandle; } |
|
142 private: |
|
143 TBool IsRomDrive() const; |
|
144 private: |
|
145 TInt iCurrentPos; |
|
146 // TUint8* iFilePtr; |
|
147 TUint iHandle; |
|
148 }; |
|
149 |
|
150 class CSVPHostDirCB : public CDirCB |
|
151 { |
|
152 public: |
|
153 CSVPHostDirCB(/*CSessionFs* aSession*/); |
|
154 ~CSVPHostDirCB(); |
|
155 void ReadL(TEntry& anEntry); |
|
156 inline void SetFullName(const TDesC& aName) {iFullName.Set(aName,NULL,NULL);} |
|
157 inline void SetHandle(TUint32 aHandle) { iHandle = aHandle; } |
|
158 |
|
159 private: |
|
160 TBool MatchUid(); |
|
161 public: |
|
162 TEntry iEntry; |
|
163 private: |
|
164 TUint32 iHandle; |
|
165 TParse iFullName; |
|
166 }; |
|
167 |
|
168 class CSVPHostFormatCB : public CFormatCB |
|
169 { |
|
170 public: |
|
171 CSVPHostFormatCB(/*CSessionFs* aSession*/); |
|
172 ~CSVPHostFormatCB(); |
|
173 public: |
|
174 virtual void DoFormatStepL(); |
|
175 }; |
|
176 |
|
177 class CSVPHostFileSystem : public CFileSystem |
|
178 { |
|
179 public: |
|
180 CSVPHostFileSystem(); |
|
181 ~CSVPHostFileSystem(); |
|
182 TInt Install(); |
|
183 TInt DefaultPath(TDes& aPath) const; |
|
184 void DriveInfo(TDriveInfo& anInfo,TInt aDriveNumber) const; |
|
185 private: |
|
186 CMountCB* NewMountL() const; |
|
187 CFileCB* NewFileL() const; |
|
188 CDirCB* NewDirL() const; |
|
189 CFormatCB* NewFormatL() const; |
|
190 public: |
|
191 static CFileSystem* NewL(); |
|
192 |
|
193 public: |
|
194 inline RSVPHostFsDriver& Device() { return iDevice; }; |
|
195 private: |
|
196 RSVPHostFsDriver iDevice; |
|
197 TUint32 iDriveMap[DRIVE_MAP_SIZE]; |
|
198 }; |
|
199 |
|
200 #endif |
|
201 |
|
202 |