sl@0
|
1 |
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
|
sl@0
|
17 |
#include <e32std.h>
|
sl@0
|
18 |
#include <f32fsys.h>
|
sl@0
|
19 |
#include <f32ver.h>
|
sl@0
|
20 |
#include <e32rom.h>
|
sl@0
|
21 |
#include <rofs.h>
|
sl@0
|
22 |
#include <f32dbg.h>
|
sl@0
|
23 |
|
sl@0
|
24 |
IMPORT_C TUint32 DebugRegister();
|
sl@0
|
25 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
|
sl@0
|
26 |
#define __LOCK_SR_STD__
|
sl@0
|
27 |
#define __PRINT(t) {if (DebugRegister()&KROFS) RDebug::Print(t);}
|
sl@0
|
28 |
#define __PRINT1(t,d) {if (DebugRegister()&KROFS) RDebug::Print(t,d);}
|
sl@0
|
29 |
#define __PRINT2(t,d,d1) {if (DebugRegister()&KROFS) RDebug::Print( t, d , d1);}
|
sl@0
|
30 |
#else
|
sl@0
|
31 |
#define __PRINT(t)
|
sl@0
|
32 |
#define __PRINT1(t,d)
|
sl@0
|
33 |
#define __PRINT2(t,d,d1)
|
sl@0
|
34 |
#endif
|
sl@0
|
35 |
|
sl@0
|
36 |
//
|
sl@0
|
37 |
|
sl@0
|
38 |
#define _USE_TRUE_LRU_CACHE
|
sl@0
|
39 |
|
sl@0
|
40 |
const TUint KFileHidden = 0xFFFFFFFF;
|
sl@0
|
41 |
|
sl@0
|
42 |
class CRofs : public CFileSystem
|
sl@0
|
43 |
{
|
sl@0
|
44 |
public:
|
sl@0
|
45 |
enum TPanic
|
sl@0
|
46 |
{
|
sl@0
|
47 |
EPanicEntryNotDir,
|
sl@0
|
48 |
EPanicNullSubDir,
|
sl@0
|
49 |
EPanicNullFileBlock,
|
sl@0
|
50 |
EPanicNullFileBlock2,
|
sl@0
|
51 |
EPanicEntryBeforeDirectory,
|
sl@0
|
52 |
EPanicEntryAfterDirectory,
|
sl@0
|
53 |
EPanicBadMatchName,
|
sl@0
|
54 |
EPanicRemountNotSupported,
|
sl@0
|
55 |
EPanicGetFileInfo,
|
sl@0
|
56 |
EPanicFileTooBig,
|
sl@0
|
57 |
EPanicReadUid,
|
sl@0
|
58 |
EPanicDirCacheNull,
|
sl@0
|
59 |
EPanicDriveInfo
|
sl@0
|
60 |
};
|
sl@0
|
61 |
static void Panic( TPanic aPanic );
|
sl@0
|
62 |
|
sl@0
|
63 |
public:
|
sl@0
|
64 |
CRofs();
|
sl@0
|
65 |
~CRofs();
|
sl@0
|
66 |
|
sl@0
|
67 |
static CRofs* New();
|
sl@0
|
68 |
|
sl@0
|
69 |
TInt Install();
|
sl@0
|
70 |
CMountCB* NewMountL() const;
|
sl@0
|
71 |
CFileCB* NewFileL() const;
|
sl@0
|
72 |
CDirCB* NewDirL() const;
|
sl@0
|
73 |
CFormatCB* NewFormatL() const;
|
sl@0
|
74 |
|
sl@0
|
75 |
void DriveInfo(TDriveInfo& anInfo,TInt aDriveNumber) const;
|
sl@0
|
76 |
TInt DefaultPath(TDes& aPath) const;
|
sl@0
|
77 |
TInt TotalSupportedDrives() const;
|
sl@0
|
78 |
TBool IsExtensionSupported() const{ return(ETrue);};
|
sl@0
|
79 |
private:
|
sl@0
|
80 |
TInt iTotalSupportedDrives;
|
sl@0
|
81 |
};
|
sl@0
|
82 |
|
sl@0
|
83 |
|
sl@0
|
84 |
class CRofsMountCB;
|
sl@0
|
85 |
class CDirectoryCache : public CBase
|
sl@0
|
86 |
{
|
sl@0
|
87 |
public:
|
sl@0
|
88 |
CDirectoryCache( CRofsMountCB& aMount, CProxyDrive& aLocalDrive, const TRofsHeader& aHeader );
|
sl@0
|
89 |
~CDirectoryCache();
|
sl@0
|
90 |
|
sl@0
|
91 |
void ConstructL();
|
sl@0
|
92 |
|
sl@0
|
93 |
void FindLeafDirL(const TDesC& aName, const TRofsDir*& aDir) const;
|
sl@0
|
94 |
void FindFileEntryL(const TDesC& aName, const TRofsEntry*& aEntry) const;
|
sl@0
|
95 |
void FindDirectoryEntryL(const TDesC& aName, const TRofsDir*& aDir) const;
|
sl@0
|
96 |
void GetNextMatchingL(const TDesC& aName, TUint aAtt, const TRofsDir*& aDir, const TRofsEntry*& aEntry, TInt aError, TBool bUseBinarySearch) const;
|
sl@0
|
97 |
void FindGeneralEntryL(const TDesC& aName, TUint aAtt, const TRofsDir*& aDir, const TRofsEntry*& aEntry ) const;
|
sl@0
|
98 |
|
sl@0
|
99 |
static inline const TText* NameAddress( const TRofsEntry* aEntry );
|
sl@0
|
100 |
TUint8 GetMountId(void);
|
sl@0
|
101 |
|
sl@0
|
102 |
private:
|
sl@0
|
103 |
CDirectoryCache();
|
sl@0
|
104 |
static inline TUint32 AlignUp( TUint32 aValue );
|
sl@0
|
105 |
inline const TRofsDir* RootDirectory() const;
|
sl@0
|
106 |
inline const TRofsDir* RofsDirFromMediaOffset( TUint aMediaOffset ) const;
|
sl@0
|
107 |
inline const TRofsDir* RofsDirFromSubDirEntry( const TRofsEntry* aEntry ) const;
|
sl@0
|
108 |
static inline const TRofsEntry* FirstSubDirEntryFromDir( const TRofsDir* aDir );
|
sl@0
|
109 |
inline const TRofsEntry* FirstFileEntryFromDir( const TRofsDir* aDir ) const;
|
sl@0
|
110 |
inline const TAny* EndOfFileBlockPlusOne( const TRofsDir* aDir ) const;
|
sl@0
|
111 |
inline const TAny* EndOfDirPlusOne( const TRofsDir* aDir ) const;
|
sl@0
|
112 |
static inline const TRofsEntry* NextEntry( const TRofsEntry* aEntry );
|
sl@0
|
113 |
|
sl@0
|
114 |
TInt DoFindSubDir(const TDesC& aName, TUint aAtt, const TRofsDir* aDir, const TRofsEntry*& aEntry) const;
|
sl@0
|
115 |
TInt DoFindFile(const TDesC& aName, TUint aAtt, const TRofsDir* aDir, const TRofsEntry*& aEntry) const;
|
sl@0
|
116 |
|
sl@0
|
117 |
TInt DoBinaryFindSubDir(const TDesC& aName, TUint aAtt, const TRofsDir* aDir, const TRofsEntry*& aEntry) const;
|
sl@0
|
118 |
TInt DoBinaryFindFile(const TDesC& aName, TUint aAtt, const TRofsDir* aDir, const TRofsEntry*& aEntry) const;
|
sl@0
|
119 |
|
sl@0
|
120 |
TInt GetDirCount(const TRofsDir* aDir) const;
|
sl@0
|
121 |
TInt GetFileCount(const TRofsDir* aDir) const;
|
sl@0
|
122 |
TInt Compare(const TDesC& aLeft, const TDesC& aRight) const;
|
sl@0
|
123 |
TInt ExtractMangleInfo(const TDesC& searchName, TUint8 &MountId, TUint8 &Reserved) const;
|
sl@0
|
124 |
private:
|
sl@0
|
125 |
CRofsMountCB& iMount;
|
sl@0
|
126 |
CProxyDrive& iLocalDrive;
|
sl@0
|
127 |
const TUint iTreeMediaOffset;
|
sl@0
|
128 |
const TUint iTreeSize;
|
sl@0
|
129 |
const TUint iFilesMediaOffset;
|
sl@0
|
130 |
const TUint iFilesSize;
|
sl@0
|
131 |
HBufC8* iTreeBuffer;
|
sl@0
|
132 |
HBufC8* iFilesBuffer;
|
sl@0
|
133 |
};
|
sl@0
|
134 |
|
sl@0
|
135 |
class CRofsFileCB;
|
sl@0
|
136 |
/**
|
sl@0
|
137 |
|
sl@0
|
138 |
*/
|
sl@0
|
139 |
class CRofsLruCache;
|
sl@0
|
140 |
class CRofsMountCB : public CLocDrvMountCB, public CMountCB::MFileAccessor
|
sl@0
|
141 |
{
|
sl@0
|
142 |
public:
|
sl@0
|
143 |
CRofsMountCB();
|
sl@0
|
144 |
void MountL(TBool aForceMount);
|
sl@0
|
145 |
TInt ReMount();
|
sl@0
|
146 |
void Dismounted();
|
sl@0
|
147 |
void VolumeL(TVolumeInfo& aVolume) const;
|
sl@0
|
148 |
void SetVolumeL(TDes& aName);
|
sl@0
|
149 |
void MkDirL(const TDesC& aName);
|
sl@0
|
150 |
void RmDirL(const TDesC& aName);
|
sl@0
|
151 |
void DeleteL(const TDesC& aName);
|
sl@0
|
152 |
void RenameL(const TDesC& anOldName,const TDesC& anNewName);
|
sl@0
|
153 |
void ReplaceL(const TDesC& anOldName,const TDesC& anNewName);
|
sl@0
|
154 |
void EntryL(const TDesC& aName,TEntry& anEntry) const;
|
sl@0
|
155 |
void SetEntryL(const TDesC& aName,const TTime& aTime,TUint aMask,TUint aVal);
|
sl@0
|
156 |
void FileOpenL(const TDesC& aName,TUint aMode,TFileOpen anOpen,CFileCB* aFile);
|
sl@0
|
157 |
void DirOpenL(const TDesC& aName,CDirCB* aDir);
|
sl@0
|
158 |
void RawReadL(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt anOffset,const RMessagePtr2& aMessage) const;
|
sl@0
|
159 |
void RawWriteL(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt anOffset,const RMessagePtr2& aMessage);
|
sl@0
|
160 |
void GetShortNameL(const TDesC& aLongName,TDes& aShortName);
|
sl@0
|
161 |
void GetLongNameL(const TDesC& aShortName,TDes& aLongName);
|
sl@0
|
162 |
void ReadSectionL(const TDesC& aName,TInt aPos,TAny* aTrg,TInt aLength,const RMessagePtr2& aMessage);
|
sl@0
|
163 |
void ReadUidL( TUint aMediaOffset, TEntry& aEntry, TRofsEntry* aRofsEntry) const;
|
sl@0
|
164 |
inline CRofs& FileSystem() const;
|
sl@0
|
165 |
virtual TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput);
|
sl@0
|
166 |
virtual TInt GetFileUniqueId(const TDesC& aName, TInt64& aUniqueId);
|
sl@0
|
167 |
virtual TInt Spare3(TInt aVal, TAny* aPtr1, TAny* aPtr2);
|
sl@0
|
168 |
virtual TInt Spare2(TInt aVal, TAny* aPtr1, TAny* aPtr2);
|
sl@0
|
169 |
virtual TInt Spare1(TInt aVal, TAny* aPtr1, TAny* aPtr2);
|
sl@0
|
170 |
|
sl@0
|
171 |
#ifdef _USE_TRUE_LRU_CACHE
|
sl@0
|
172 |
void CacheReadL(TInt aPos, TInt aLength, const TAny* aDes, TInt anOffset, const RMessagePtr2& aMessage) const;
|
sl@0
|
173 |
#endif
|
sl@0
|
174 |
TUint8 iMountId;
|
sl@0
|
175 |
|
sl@0
|
176 |
private:
|
sl@0
|
177 |
TInt CheckHeader() const;
|
sl@0
|
178 |
TInt CheckExtension();
|
sl@0
|
179 |
|
sl@0
|
180 |
private:
|
sl@0
|
181 |
TPckgBuf<TRofsHeader> iHeader;
|
sl@0
|
182 |
CDirectoryCache* iDirectoryCache;
|
sl@0
|
183 |
TInt64 iMediaSize;
|
sl@0
|
184 |
|
sl@0
|
185 |
#ifdef _USE_TRUE_LRU_CACHE
|
sl@0
|
186 |
CRofsLruCache* iDataCache;
|
sl@0
|
187 |
#endif
|
sl@0
|
188 |
|
sl@0
|
189 |
};
|
sl@0
|
190 |
|
sl@0
|
191 |
class CRofsFileCB : public CFileCB, public CFileCB::MBlockMapInterface, public CFileCB::MExtendedFileInterface
|
sl@0
|
192 |
{
|
sl@0
|
193 |
public:
|
sl@0
|
194 |
CRofsFileCB();
|
sl@0
|
195 |
void RenameL(const TDesC& aNewName);
|
sl@0
|
196 |
void ReadL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage);
|
sl@0
|
197 |
void WriteL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage);
|
sl@0
|
198 |
void SetSizeL(TInt aSize);
|
sl@0
|
199 |
void SetEntryL(const TTime& aTime,TUint aMask,TUint aVal);
|
sl@0
|
200 |
void FlushDataL();
|
sl@0
|
201 |
void FlushAllL();
|
sl@0
|
202 |
inline void SetMediaBase(const TUint aBase);
|
sl@0
|
203 |
inline void SetAttExtra( TUint8 aAttExtra );
|
sl@0
|
204 |
TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput);
|
sl@0
|
205 |
|
sl@0
|
206 |
// from CFileCB::MExtendedFileInterface
|
sl@0
|
207 |
virtual void ReadL(TInt64 aPos,TInt& aLength,TDes8* aDes,const RMessagePtr2& aMessage, TInt aOffset);
|
sl@0
|
208 |
virtual void WriteL(TInt64 aPos,TInt& aLength,const TDesC8* aDes,const RMessagePtr2& aMessage, TInt aOffset);
|
sl@0
|
209 |
virtual void SetSizeL(TInt64 aSize);
|
sl@0
|
210 |
|
sl@0
|
211 |
private:
|
sl@0
|
212 |
inline CRofsMountCB& RofsMount();
|
sl@0
|
213 |
TInt BlockMap(SBlockMapInfo& aInfo, TInt64& aStartPos, TInt64 aEndPos);
|
sl@0
|
214 |
|
sl@0
|
215 |
private:
|
sl@0
|
216 |
TUint iMediaBase;
|
sl@0
|
217 |
TUint8 iAttExtra;
|
sl@0
|
218 |
};
|
sl@0
|
219 |
|
sl@0
|
220 |
class CRofsDirCB : public CDirCB
|
sl@0
|
221 |
{
|
sl@0
|
222 |
public:
|
sl@0
|
223 |
CRofsDirCB();
|
sl@0
|
224 |
~CRofsDirCB();
|
sl@0
|
225 |
void ReadL(TEntry& anEntry);
|
sl@0
|
226 |
void SetDir(const TRofsDir* aDir, const TDesC& aMatch, TInt64& aTimeStamp );
|
sl@0
|
227 |
inline void SetCache( CDirectoryCache* aCache );
|
sl@0
|
228 |
private:
|
sl@0
|
229 |
TBool MatchUid();
|
sl@0
|
230 |
private:
|
sl@0
|
231 |
CDirectoryCache* iCache;
|
sl@0
|
232 |
TEntry iEntry;
|
sl@0
|
233 |
TTime iTimeStamp;
|
sl@0
|
234 |
const TRofsDir* iDir;
|
sl@0
|
235 |
const TRofsEntry* iNext;
|
sl@0
|
236 |
HBufC* iMatch;
|
sl@0
|
237 |
};
|
sl@0
|
238 |
|
sl@0
|
239 |
#ifdef _USE_TRUE_LRU_CACHE
|
sl@0
|
240 |
const TInt KSizeOfCacheInPages = 5; // 5K Cache
|
sl@0
|
241 |
const TInt KSizeOfSegment = 1024; //Two pages
|
sl@0
|
242 |
const TInt KPageSize = 512;
|
sl@0
|
243 |
|
sl@0
|
244 |
class TCacheSegment
|
sl@0
|
245 |
{
|
sl@0
|
246 |
public:
|
sl@0
|
247 |
TCacheSegment();
|
sl@0
|
248 |
void Set(TInt aPos);
|
sl@0
|
249 |
TUint8* Data() {return(((TUint8*)this)+sizeof(TCacheSegment));}
|
sl@0
|
250 |
public:
|
sl@0
|
251 |
TInt iPos;
|
sl@0
|
252 |
TDblQueLink iLink;
|
sl@0
|
253 |
};
|
sl@0
|
254 |
|
sl@0
|
255 |
//
|
sl@0
|
256 |
//Data cache for Rofs, (read only cache)
|
sl@0
|
257 |
//
|
sl@0
|
258 |
class CRofsLruCache: public CBase
|
sl@0
|
259 |
{
|
sl@0
|
260 |
public:
|
sl@0
|
261 |
~CRofsLruCache();
|
sl@0
|
262 |
static CRofsLruCache* New(TInt aSegmentSize, CRofsMountCB* aMount, TInt64 aMediaSize);
|
sl@0
|
263 |
TUint8* Find(TInt aPos , TInt aLength);
|
sl@0
|
264 |
TUint8* ReadL(TInt aPos , TInt aLength);
|
sl@0
|
265 |
protected:
|
sl@0
|
266 |
CRofsLruCache(CRofsMountCB* aMount, TInt64 aMediaSize);
|
sl@0
|
267 |
private:
|
sl@0
|
268 |
TDblQue<TCacheSegment> iQue;
|
sl@0
|
269 |
CRofsMountCB* iMount;
|
sl@0
|
270 |
TInt64 iMediaSize;
|
sl@0
|
271 |
};
|
sl@0
|
272 |
#endif
|
sl@0
|
273 |
|
sl@0
|
274 |
|
sl@0
|
275 |
#include "sr_rofs.inl"
|