os/kernelhwsrv/userlibandfileserver/fileserver/sfile/sf_std.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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
// f32\sfile\sf_std.h
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
 
sl@0
    18
sl@0
    19
#ifndef SF_STD_H
sl@0
    20
#define SF_STD_H
sl@0
    21
sl@0
    22
#include "common.h"
sl@0
    23
#include "message.h"
sl@0
    24
#include <f32fsys.h>
sl@0
    25
#include <f32ver.h>
sl@0
    26
#include <f32dbg.h>
sl@0
    27
#include <e32svr.h>
sl@0
    28
#include <e32hal.h>
sl@0
    29
#include <e32uid.h>
sl@0
    30
#include <e32std_private.h>
sl@0
    31
#include <e32def_private.h>
sl@0
    32
#include <e32const_private.h>
sl@0
    33
#include "sf_plugin.h"
sl@0
    34
#include "sf_func.h"
sl@0
    35
#include <F32plugin.h>
sl@0
    36
#include "f32trace.h"
sl@0
    37
#include <utraceefile.h>
sl@0
    38
sl@0
    39
#define __PRINT1TEMP_ALWAYS(t,a) {{TBuf<KMaxFileName>temp(a);RDebug::Print(t,&temp);}}
sl@0
    40
#define __PRINT2TEMP_ALWAYS(t,a,b) {{TBuf<KMaxFileName>temp(b);RDebug::Print(t,a,&temp);}}
sl@0
    41
#define __PRINT3TEMP_ALWAYS(t,a,b,c) {{TBuf<KMaxFileName>temp(c);RDebug::Print(t,a,b,&temp);}}
sl@0
    42
#define __PRINT4TEMP_ALWAYS(t,a,b,c,d) {{TBuf<KMaxFileName>temp(d);RDebug::Print(t,a,b,c,&temp);}}
sl@0
    43
sl@0
    44
#define _THRD_BUF() (_L("thread id 0x"));buf.AppendNum(RThread().Id(),EHex);buf.Append(_L(" "))
sl@0
    45
#define __THRD_PRINT_ALWAYS(t) {{TBuf<KMaxFileName> buf=_THRD_BUF();buf.Append(t);RDebug::Print(buf);}}
sl@0
    46
#define __THRD_PRINT1_ALWAYS(t,a) {{TBuf<KMaxFileName> buf=_THRD_BUF();buf.Append(t);RDebug::Print(buf,a);}}
sl@0
    47
#define __THRD_PRINT2_ALWAYS(t,a,b) {{TBuf<KMaxFileName> buf=_THRD_BUF();buf.Append(t);RDebug::Print(buf,a,b);}}
sl@0
    48
#define __THRD_PRINT3_ALWAYS(t,a,b,c) {{TBuf<KMaxFileName> buf=_THRD_BUF();buf.Append(t);RDebug::Print(buf,a,b,c);}}
sl@0
    49
#define __THRD_PRINT4_ALWAYS(t,a,b,c,d) {{TBuf<KMaxFileName> buf=_THRD_BUF();buf.Append(t);RDebug::Print(buf,a,b,c,d);}}
sl@0
    50
sl@0
    51
sl@0
    52
#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
sl@0
    53
#define __PRINT(t) {if (DebugReg&KFSERV) RDebug::Print(t);}
sl@0
    54
#define __PRINT1(t,a) {if (DebugReg&KFSERV) RDebug::Print(t,a);}
sl@0
    55
#define __PRINT2(t,a,b) {if (DebugReg&KFSERV) RDebug::Print(t,a,b);}
sl@0
    56
#define __PRINT3(t,a,b,c) {if (DebugReg&KFSERV) RDebug::Print(t,a,b,c);}
sl@0
    57
#define __PRINT4(t,a,b,c,d) {if (DebugReg&KFSERV) RDebug::Print(t,a,b,c,d);}
sl@0
    58
#define __IF_DEBUG(t) {if (DebugReg&KFLDR) RDebug::t;}
sl@0
    59
#define __LDRTRACE(t) {if (DebugReg&KFLDR) t;}
sl@0
    60
#define __PRINTALLOC(t,a,b,c) {if (DebugReg&KALLOC) RDebug::Print(t,a,b,c);}
sl@0
    61
#define __PRINT1TEMP(t,a) {if (DebugReg&KFSERV) {TBuf<KMaxFileName>temp(a);RDebug::Print(t,&temp);}}
sl@0
    62
#define __PRINT2TEMP(t,a,b) {if (DebugReg&KFSERV) {TBuf<KMaxFileName>temp(b);RDebug::Print(t,a,&temp);}}
sl@0
    63
#define __PRINT3TEMP(t,a,b,c) {if (DebugReg&KFSERV) {TBuf<KMaxFileName>temp(c);RDebug::Print(t,a,b,&temp);}}
sl@0
    64
#define __PRINT4TEMP(t,a,b,c,d) {if (DebugReg&KFSERV) {TBuf<KMaxFileName>temp(d);RDebug::Print(t,a,b,c,&temp);}}
sl@0
    65
#define __CALL(t) {t;}
sl@0
    66
sl@0
    67
#define __THRD_PRINT(t) {if (DebugReg&KTHRD) {TBuf<KMaxFileName> buf=_THRD_BUF();buf.Append(t);RDebug::Print(buf);}}
sl@0
    68
#define __THRD_PRINT1(t,a) {if (DebugReg&KTHRD) {TBuf<KMaxFileName> buf=_THRD_BUF();buf.Append(t);RDebug::Print(buf,a);}}
sl@0
    69
#define __THRD_PRINT2(t,a,b) {if (DebugReg&KTHRD) {TBuf<KMaxFileName> buf=_THRD_BUF();buf.Append(t);RDebug::Print(buf,a,b);}}
sl@0
    70
#define __THRD_PRINT3(t,a,b,c) {if (DebugReg&KTHRD) {TBuf<KMaxFileName> buf=_THRD_BUF();buf.Append(t);RDebug::Print(buf,a,b,c);}}
sl@0
    71
#define __THRD_PRINT4(t,a,b,c,d) {if (DebugReg&KTHRD) {TBuf<KMaxFileName> buf=_THRD_BUF();buf.Append(t);RDebug::Print(buf,a,b,c,d);}}
sl@0
    72
sl@0
    73
#define __CACHE_PRINT(t) {if (DebugReg&KCACHE) RDebug::Print(t);}
sl@0
    74
#define __CACHE_PRINT1(t,a) {if (DebugReg&KCACHE) RDebug::Print(t,a);}
sl@0
    75
#define __CACHE_PRINT2(t,a,b) {if (DebugReg&KCACHE) RDebug::Print(t,a,b);}
sl@0
    76
#define __CACHE_PRINT3(t,a,b,c) {if (DebugReg&KCACHE) RDebug::Print(t,a,b,c);}
sl@0
    77
#define __CACHE_PRINT4(t,a,b,c,d) {if (DebugReg&KCACHE) RDebug::Print(t,a,b,c,d);}
sl@0
    78
#define __CACHE_PRINT5(t,a,b,c,d,e) {if (DebugReg&KCACHE) RDebug::Print(t,a,b,c,d,e);}
sl@0
    79
#define __CACHE_PRINT6(t,a,b,c,d,e,f) {if (DebugReg&KCACHE) RDebug::Print(t,a,b,c,d,e,f);}
sl@0
    80
#define __CACHE_PRINT7(t,a,b,c,d,e,f,g) {if (DebugReg&KCACHE) RDebug::Print(t,a,b,c,d,e,f,g);}
sl@0
    81
#define __PLUGIN_PRINT(t) {if (DebugReg&KPLUGIN) RDebug::Print(t);}
sl@0
    82
#define __PLUGIN_PRINT1(t,a) {if (DebugReg&KPLUGIN) RDebug::Print(t,a);}
sl@0
    83
#define __PLUGIN_PRINT2(t,a,b) {if (DebugReg&KPLUGIN) RDebug::Print(t,a,b);}
sl@0
    84
#define __PLUGIN_PRINT3(t,a,b,c) {if (DebugReg&KPLUGIN) RDebug::Print(t,a,b,c);}
sl@0
    85
#else
sl@0
    86
#define __PRINT(t)
sl@0
    87
#define __PRINT1(t,a)
sl@0
    88
#define __PRINT2(t,a,b)
sl@0
    89
#define __PRINT3(t,a,b,c)
sl@0
    90
#define __PRINT4(t,a,b,c,d)
sl@0
    91
#define __IF_DEBUG(t)
sl@0
    92
#define __LDRTRACE(t)
sl@0
    93
#define __PRINTALLOC(t,a,b,c) {if (DebugReg&KALLOC) RDebug::Print(t,a,b,c);}
sl@0
    94
#define __PRINT1TEMP(t,a)
sl@0
    95
#define __PRINT2TEMP(t,a,b)
sl@0
    96
#define __PRINT3TEMP(t,a,b,c)
sl@0
    97
#define __PRINT4TEMP(t,a,b,c,d)
sl@0
    98
#define __CALL(t)
sl@0
    99
#define __THRD_PRINT(t)
sl@0
   100
#define __THRD_PRINT1(t,a)
sl@0
   101
#define __THRD_PRINT2(t,a,b)
sl@0
   102
#define __THRD_PRINT3(t,a,b,c)
sl@0
   103
#define __THRD_PRINT4(t,a,b,c,d)
sl@0
   104
#define __CACHE_PRINT(t)
sl@0
   105
#define __CACHE_PRINT1(t,a)
sl@0
   106
#define __CACHE_PRINT2(t,a,b)
sl@0
   107
#define __CACHE_PRINT3(t,a,b,c)
sl@0
   108
#define __CACHE_PRINT4(t,a,b,c,d)
sl@0
   109
#define __CACHE_PRINT5(t,a,b,c,d,e)
sl@0
   110
#define __CACHE_PRINT6(t,a,b,c,d,e,f)
sl@0
   111
#define __CACHE_PRINT7(t,a,b,c,d,e,f,g)
sl@0
   112
#define __PLUGIN_PRINT(t)
sl@0
   113
#define __PLUGIN_PRINT1(t,a)
sl@0
   114
#define __PLUGIN_PRINT2(t,a,b)
sl@0
   115
#define __PLUGIN_PRINT3(t,a,b,c)
sl@0
   116
#endif
sl@0
   117
sl@0
   118
const TInt KMaxTotalDriveReserved	=0x100000;
sl@0
   119
const TInt KMaxSessionDriveReserved	=0x10000;
sl@0
   120
sl@0
   121
// If TFsFileDuplciate::DoRequestL() is called a new sub-session is created and 
sl@0
   122
// the new sub-session handle is returned, mangled by KSubSessionMangleBit - 
sl@0
   123
// this is to discourage use of the duplicated handle.
sl@0
   124
// If TFsFileAdopt::DoRequestL() is called then the passed sub-session handle is 
sl@0
   125
// assumed to be already mangled by KSubSessionMangleBit and the same sub-session 
sl@0
   126
// handle is returned de-mangled.
sl@0
   127
const TInt KSubSessionMangleBit = 0x4000;
sl@0
   128
sl@0
   129
sl@0
   130
#define __CHECK_DRIVETHREAD(d) {__ASSERT_DEBUG(FsThreadManager::IsDriveThread(d,ETrue),Fault(EFsDriveThreadError));}
sl@0
   131
#define __CHECK_MAINTHREAD() {__ASSERT_DEBUG(FsThreadManager::IsMainThread(),Fault(EFsMainThreadError));}
sl@0
   132
sl@0
   133
#define __LAZY_DLL_UNLOAD
sl@0
   134
sl@0
   135
const TInt KMaxTempNameAttempts=50;
sl@0
   136
const TInt KHeapMinSize=0x1000;
sl@0
   137
const TInt KHeapMaxSize=0x400000;
sl@0
   138
const TInt KLoaderStackSize=0x8000;
sl@0
   139
sl@0
   140
//-- maximum file size that was supported before introducing File Server 64-bit addressing support.
sl@0
   141
//-- It is 2G-1. Used in legacy code that does not understand RFile64
sl@0
   142
const TUint64 KMaxLegacyFileSize    = 0x7fffffff;
sl@0
   143
sl@0
   144
//-- absolute maximum file size that file server supports
sl@0
   145
const TUint64 KMaxSupportedFileSize = KMaxTUint64;
sl@0
   146
sl@0
   147
//__DATA_CAGING__
sl@0
   148
const TUint SHA1_LBLOCK=16;
sl@0
   149
const TUint SHA1_HASH=20;
sl@0
   150
#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
sl@0
   151
sl@0
   152
class TCorruptNameRec;
sl@0
   153
class TCorruptLogRec
sl@0
   154
	{
sl@0
   155
public:
sl@0
   156
	TCorruptLogRec();
sl@0
   157
	~TCorruptLogRec();
sl@0
   158
	TInt Construct(TCorruptNameRec* aNameRec, TPtrC* aProcessName, TCorruptLogRec* aChain);
sl@0
   159
	inline TPtrC ProcessName(){return iProcessName->Des();};
sl@0
   160
	static TInt GetLogRecord(TFsDebugCorruptLogRecordBuf& aLogRecord,TInt aLogRecNum);
sl@0
   161
	static void DestroyList();
sl@0
   162
private:
sl@0
   163
	HBufC* iProcessName;
sl@0
   164
	TCorruptNameRec* iNameRec;
sl@0
   165
	TCorruptLogRec* iNext;
sl@0
   166
	};
sl@0
   167
sl@0
   168
TInt OutputTraceInfo(TCorruptNameRec* aNameRec, CFsRequest* aRequest);
sl@0
   169
sl@0
   170
class TText8FileReader
sl@0
   171
	{
sl@0
   172
	enum {EMaxLine=1024};
sl@0
   173
public:
sl@0
   174
	TText8FileReader();
sl@0
   175
	~TText8FileReader();
sl@0
   176
	TInt Set(RFile& aFile);
sl@0
   177
	TInt Read(TPtr& aPtr);	
sl@0
   178
public:
sl@0
   179
	RFile iFile;
sl@0
   180
	TBuf8<EMaxLine> iBuf;
sl@0
   181
	TInt iBufPos;
sl@0
   182
	TText* iFileDataBuf;
sl@0
   183
	TInt iFileSize;	
sl@0
   184
	};	
sl@0
   185
sl@0
   186
class TCorruptNameRec
sl@0
   187
	{
sl@0
   188
public:
sl@0
   189
	TCorruptNameRec();
sl@0
   190
	TInt Construct(TPtr* aName,TInt aReturnCode, TBool aUseOnce, TCorruptNameRec* aChain);
sl@0
   191
	static void ResetListConsumed();
sl@0
   192
	inline TPtrC Name(){return iName->Des();};
sl@0
   193
	inline TInt ReturnCode(){return iReturnCode;};
sl@0
   194
	inline TBool Consumed(){return iConsumed;};
sl@0
   195
	inline void SetConsumed(){iConsumed=iUseOnce;};
sl@0
   196
	inline TCorruptNameRec* Next(){return iNext;};
sl@0
   197
private:
sl@0
   198
	HBufC*	iName;
sl@0
   199
	TInt	iReturnCode;
sl@0
   200
	TBool	iUseOnce;
sl@0
   201
	TBool	iConsumed;
sl@0
   202
	TCorruptNameRec* iNext;
sl@0
   203
	};
sl@0
   204
#endif
sl@0
   205
//
sl@0
   206
sl@0
   207
//
sl@0
   208
_LIT(KFsClient,"FSCLIENT");
sl@0
   209
sl@0
   210
NONSHARABLE_CLASS(CSHA1) : public CBase
sl@0
   211
	{
sl@0
   212
public:
sl@0
   213
	static CSHA1* NewL(void);
sl@0
   214
	void Update(const TDesC8& aMessage);
sl@0
   215
	TPtrC8 Final(void);
sl@0
   216
	~CSHA1(void);
sl@0
   217
	void Reset(void);
sl@0
   218
private:
sl@0
   219
	CSHA1(void);
sl@0
   220
	TUint iA;
sl@0
   221
	TUint iB;
sl@0
   222
	TUint iC;
sl@0
   223
	TUint iD;
sl@0
   224
	TUint iE;
sl@0
   225
	TBuf8<SHA1_HASH> iHash;
sl@0
   226
	TUint iNl;
sl@0
   227
	TUint iNh;
sl@0
   228
	TUint iData[SHA1_LBLOCK*5];
sl@0
   229
	void DoUpdate(const TUint8* aData,TUint aLength);
sl@0
   230
	void DoFinal(void);
sl@0
   231
	void Block();
sl@0
   232
	void ConstructL(void);
sl@0
   233
	TUint8* iTempData;
sl@0
   234
	};
sl@0
   235
sl@0
   236
enum TFsPanic
sl@0
   237
	{
sl@0
   238
	ELdrImportedOrdinalDoesNotExist
sl@0
   239
	};
sl@0
   240
//
sl@0
   241
enum TFsFault
sl@0
   242
	{
sl@0
   243
	EDrvIllegalShareValue,			//0
sl@0
   244
	EMainCreateScheduler,
sl@0
   245
	EMainCreateServer,
sl@0
   246
	EMainStartServer,
sl@0
   247
	EMainCreateResources1,
sl@0
   248
	EMainGetLocalFileSystem,
sl@0
   249
	EMainGetLocalDefaultPath,
sl@0
   250
	EInitConnectLocalDrive,
sl@0
   251
	EMainCreateStartupThread1,
sl@0
   252
	EInitDriveMappingDriveInfo,
sl@0
   253
	EInitCreateDriveName,			//10
sl@0
   254
	EMainStartupNoEStart,
sl@0
   255
	ESesPathBadDrive,
sl@0
   256
	EFileDuplicateLock,
sl@0
   257
	ESysDefaultPathNotSupported,
sl@0
   258
	ESysAddLocalFileSystem,
sl@0
   259
	ESvrBadSessionIndex,
sl@0
   260
	EGetLocalDrive1,
sl@0
   261
	EGetLocalDrive2,
sl@0
   262
	ELdrRestartInit,
sl@0
   263
	ELdrRestartSemaphore,			//20
sl@0
   264
	EStripBackSlashBadName,
sl@0
   265
	EIsSubDirBadDes,
sl@0
   266
	ERawDiskBadAccessCount2,
sl@0
   267
	ERawDiskBadAccessCount1,
sl@0
   268
	ERawDiskBadAccessCount,
sl@0
   269
	EDriveNoDiskMounted,
sl@0
   270
	ESvrNotifierIsNULL,
sl@0
   271
	EMainCreateResources5,
sl@0
   272
	EMainCreateStartupThread2,
sl@0
   273
	EMainCreateStartupThread3,		//30
sl@0
   274
	EMainCreateStartupThread4,
sl@0
   275
	EMainStartupWriteToDiskSemaphore,	
sl@0
   276
	EMainCreateResources6,
sl@0
   277
	EMainScanMediaDriversMem1,
sl@0
   278
	EMainScanMediaDriversLocation,
sl@0
   279
	EMainScanMediaDriversMem2,
sl@0
   280
	EMainScanMediaDriverConnect,
sl@0
   281
	EMainScanMediaDriverDirOpen,
sl@0
   282
	EMainScanMediaDriverDirRead,
sl@0
   283
	EMainLoadMediaDriver,			//40
sl@0
   284
	EInitCreateMediaChangeNotifier,
sl@0
   285
	ELdrCleanupCreate,
sl@0
   286
	ELdrSchedulerCreate,
sl@0
   287
	ELdrServerCreate,
sl@0
   288
	ELdrFsConnect,
sl@0
   289
	ELdrFsSetPath,
sl@0
   290
	ELdrCacheInit,
sl@0
   291
	ELdrSchedulerStopped,
sl@0
   292
	ESvrFormatOpenFailed,
sl@0
   293
	ESvrRawDiskOpenFailed,			//50
sl@0
   294
	EProxyDriveConstruction,
sl@0
   295
	ELocDrvInitLocalDrive,
sl@0
   296
	ELocDrvDismountedLocalDrive,
sl@0
   297
	EBaseExtConstruction,
sl@0
   298
	ECreateProxyDriveL,
sl@0
   299
	EExtensionInfoCount0,
sl@0
   300
	EExtensionInfoCount1,
sl@0
   301
	EExtensionInfoCount2,
sl@0
   302
	EStdChangeRequestType,
sl@0
   303
	EExtChangeNameLength,			//60
sl@0
   304
	EDiskSpaceThreshold,
sl@0
   305
	EDebugChangeType,
sl@0
   306
	EBaseQueConstruction,
sl@0
   307
	EChangeQueType,
sl@0
   308
	EDiskSpaceQueType1,
sl@0
   309
	EDiskSpaceQueType2,
sl@0
   310
	EBaseQueCancel,
sl@0
   311
	EDebugQueType,
sl@0
   312
	EBaseRequestSrc,
sl@0
   313
	EBaseRequestDest,			//70
sl@0
   314
	EBaseRequestDrive,
sl@0
   315
	EBaseRequestSubstedDrive,
sl@0
   316
	EBaseRequestSetDrive,
sl@0
   317
	EBaseRequestSetSubstedDrive,
sl@0
   318
	EBaseRequestMessage,
sl@0
   319
	EBaseRequestSet1,
sl@0
   320
	EBaseRequestSet2,
sl@0
   321
	EDiskSpaceQueDrive,
sl@0
   322
	ENotifyInfoDestructor,
sl@0
   323
	EChangeBadIndex,			//80
sl@0
   324
	EBadDiskNotifyType,
sl@0
   325
	EBadDebugNotifyType,
sl@0
   326
	EDiskChangeDrive,
sl@0
   327
	EBadChangeNotifyType,
sl@0
   328
	EDiskBadIndex1,
sl@0
   329
	EDiskBadIndex2,
sl@0
   330
	EDiskBadIndex3,
sl@0
   331
	ESvrFreeDiskSpace,
sl@0
   332
	EFsThreadBadDrvNum,
sl@0
   333
	EFsThreadConstructor,			//90
sl@0
   334
	EFsThreadDriveClose1,
sl@0
   335
	EFsThreadDriveClose2,
sl@0
   336
	EFsThreadGetThread,
sl@0
   337
	EMainInitialiseRomFs,
sl@0
   338
	EFsDriveThreadError,
sl@0
   339
	EFsMainThreadError,
sl@0
   340
	ETFsSetSubstNotNull,
sl@0
   341
	EMountFileSystemFSys,
sl@0
   342
	EDisMountFileSystemFSys,
sl@0
   343
	EIsValidDriveMapping,			//100
sl@0
   344
	EInitDriveMappingSocketNo,
sl@0
   345
	ECompleteNotifSocketNo,
sl@0
   346
	EObjRemoveContainerNotFound,
sl@0
   347
	EObjDestructorAccessCount,
sl@0
   348
	EObjDestructorContainer,
sl@0
   349
	EObjRemoveBadHandle,
sl@0
   350
	EArrayIndexOutOfRange,
sl@0
   351
	EObjFindBadHandle,
sl@0
   352
	EObjRemoveObjectNotFound,
sl@0
   353
	EObjFindIndexOutOfRange,			//110
sl@0
   354
	ESubOpenBadHandle,
sl@0
   355
	EMainDisconnectThread,
sl@0
   356
	EInternalRequestProcess,
sl@0
   357
	EInternalRequestComplete1,
sl@0
   358
	EInternalRequestComplete2,
sl@0
   359
	EInternalRequestComplete3,
sl@0
   360
	ERequestThreadDestructor,
sl@0
   361
	EThreadManagerInitDrive,
sl@0
   362
	EDriveCurrentWriteFunction,
sl@0
   363
	EDriveGetNotifyUser,				//120
sl@0
   364
	EDriveThreadWriteable,
sl@0
   365
	EDriveThreadNotifyUser1,
sl@0
   366
	EDriveThreadNotifyUser2,
sl@0
   367
	ERequestDestructorFree,
sl@0
   368
	ESessionDisconnectThread1,
sl@0
   369
	ESessionDisconnectThread2,
sl@0
   370
	EDismountFsDriveThread,
sl@0
   371
	EDisconnectRequestDispatch1,
sl@0
   372
	EDisconnectRequestDispatch2,
sl@0
   373
	EDisonncectRequestProcess,			//130
sl@0
   374
	EDispatchObjectDispatch,
sl@0
   375
	EDispatchObjectThread,
sl@0
   376
	EInternalRequestDispatch1,
sl@0
   377
	EInternalRequestDispatch2,
sl@0
   378
	EInternalRequestDispatch3,
sl@0
   379
	EFsObjectIxDestructor,
sl@0
   380
	EDisconnectRequestComplete,
sl@0
   381
	EMountExtensionFSys,
sl@0
   382
	EObjectConDestructor,
sl@0
   383
	EParseSubstSession,					//140
sl@0
   384
	ELdrGetKernelInfoFailed,
sl@0
   385
	EObjectIxMainThread,
sl@0
   386
	ESwapFileSystemNull,
sl@0
   387
	ESwapFileSystemMount,
sl@0
   388
	ESwapFileSystemRom,
sl@0
   389
	EReserveSpaceArithmetic,
sl@0
   390
	ECloseSubBadMessage,
sl@0
   391
	EFsCacheLockFailure,
sl@0
   392
	EFsPluginThreadError,				
sl@0
   393
	EBadDismountNotifyType,				//150
sl@0
   394
	ENotifyDismount,
sl@0
   395
	EAllowDismount,
sl@0
   396
	ENotifyDismountCancel,
sl@0
   397
	EFileDuplicateAsyncReadRequest,
sl@0
   398
	EFileFailedToServiceAsyncReadRequest,
sl@0
   399
	ELdrCsIdWrap,
sl@0
   400
	EFileShareBadPromoteCount,
sl@0
   401
	EInternalRequestDispatchCancelPlugin,
sl@0
   402
	EMainCreateStartupThread0,
sl@0
   403
	ERequestAllocatorOpenSubFailed,		//160
sl@0
   404
	ETParsePoolGet,
sl@0
   405
	EInvalidDrive,
sl@0
   406
	ELocDrvInvalidLocalDrive,
sl@0
   407
	ELdrReaperCreate,
sl@0
   408
	ELdrReaperCleanupTimerCreate,
sl@0
   409
	EFsParsePoolLockFailure,
sl@0
   410
	ELdrReaperCantGetDriveList,
sl@0
   411
	EFileCacheCreateFailed,
sl@0
   412
	EBadOperationIndex,
sl@0
   413
	EBadOperationCompletionCode,		//170
sl@0
   414
	EReadOffsetNonZero,
sl@0
   415
	ETooManyOperations,
sl@0
   416
	EInvalidOperationIndex,
sl@0
   417
	EInvalidReadLength,
sl@0
   418
	EInvalidWriteLength,
sl@0
   419
	ERequestThreadNotInitialised,
sl@0
   420
	EMemoryInfoFailed,
sl@0
   421
	EMsgRestartBadFunction,
sl@0
   422
	EPushOpNoCallback,
sl@0
   423
	EFreeingMsgWithMsgOp,				//180
sl@0
   424
	ENotUnused,
sl@0
   425
	ELdrFileDataAllocInit,
sl@0
   426
	ELdrFileDataAllocError,
sl@0
   427
	EDismountLocked,
sl@0
   428
	EInvalidMsgState,
sl@0
   429
	EGetProxyDriveMapping1,
sl@0
   430
	EGetProxyDriveMapping2,
sl@0
   431
	EExtProxyDriveCaps,
sl@0
   432
	EIsProxyDrive,
sl@0
   433
	EClearProxyDriveMapping1,			//190
sl@0
   434
	EClearProxyDriveMapping2,
sl@0
   435
	ERequestQueueNotEmpty,
sl@0
   436
	ESetupMediaChange,
sl@0
   437
	ECancelNotifyChange,
sl@0
   438
	EPluginOpError,
sl@0
   439
	EBadMessageSlotIndex,
sl@0
   440
	EInvalidCompletionFlags,
sl@0
   441
	ECacheMemoryManagerCreateFailed,
sl@0
   442
	EFileBodyIsNull,
sl@0
   443
	ETraceLddLoadFailure,				//200
sl@0
   444
	ETooManyDrivesPerSocket,
sl@0
   445
	ENotificationFault,
sl@0
   446
	EFsObjectOpen
sl@0
   447
	};
sl@0
   448
sl@0
   449
sl@0
   450
NONSHARABLE_CLASS(CFsObjectConIx) : public CBase
sl@0
   451
	{
sl@0
   452
public:
sl@0
   453
	static CFsObjectConIx* NewL();
sl@0
   454
	~CFsObjectConIx();
sl@0
   455
	CFsObjectCon* CreateL();
sl@0
   456
	void Remove(CFsObjectCon* aCon);
sl@0
   457
protected:
sl@0
   458
	CFsObjectConIx();
sl@0
   459
	void CreateContainerL(CFsObjectCon*& anObject);
sl@0
   460
private:
sl@0
   461
	TInt iCount;
sl@0
   462
	TInt iAllocated;
sl@0
   463
	TInt iNextUniqueID;
sl@0
   464
	CFsObjectCon** iContainers;
sl@0
   465
	};
sl@0
   466
sl@0
   467
struct SFsObjectIxRec
sl@0
   468
	{
sl@0
   469
	TInt16 instance;
sl@0
   470
	TInt16 uniqueID;
sl@0
   471
	CFsObject* obj;
sl@0
   472
	};
sl@0
   473
sl@0
   474
NONSHARABLE_CLASS(CFsObjectIx) : public CBase
sl@0
   475
	{
sl@0
   476
public:
sl@0
   477
	static CFsObjectIx* NewL();
sl@0
   478
	~CFsObjectIx();
sl@0
   479
	TInt AddL(CFsObject* anObj,TBool aLock);
sl@0
   480
	void Remove(TInt aHandle,TBool aLock);
sl@0
   481
	CFsObject* At(TInt aHandle,TInt aUniqueID,TBool aLock);	
sl@0
   482
	CFsObject* At(TInt aHandle,TBool aLock);
sl@0
   483
	TInt At(const CFsObject* anObj,TBool aLock);
sl@0
   484
	CFsObject* operator[](TInt anIndex);
sl@0
   485
	void CloseMainThreadObjects();
sl@0
   486
	inline TInt Count() const;
sl@0
   487
	inline TInt ActiveCount() const;
sl@0
   488
	inline void Lock();
sl@0
   489
	inline void Unlock();
sl@0
   490
protected:
sl@0
   491
	CFsObjectIx();
sl@0
   492
private:
sl@0
   493
	TInt iNumEntries;		// number of actual entries in the index
sl@0
   494
	TInt iHighWaterMark;	// 1+highest active index
sl@0
   495
	TInt iAllocated;		// max entries before realloc needed
sl@0
   496
	TInt iNextInstance;
sl@0
   497
	SFsObjectIxRec *iObjects;
sl@0
   498
	RFastLock iLock;
sl@0
   499
	};
sl@0
   500
sl@0
   501
NONSHARABLE_CLASS(CFsObjectCon) : public CBase
sl@0
   502
	{
sl@0
   503
protected:
sl@0
   504
	enum {ENotOwnerID};
sl@0
   505
public:
sl@0
   506
	static CFsObjectCon* NewL();
sl@0
   507
	~CFsObjectCon();
sl@0
   508
	void AddL(CFsObject* anObj,TBool aLock);
sl@0
   509
	void Remove(CFsObject* anObj,TBool aLock);
sl@0
   510
	CFsObject* operator[](TInt anIndex);
sl@0
   511
	CFsObject* At(TInt aFindHandle) const;
sl@0
   512
	CFsObject* AtL(TInt aFindHandle) const;	
sl@0
   513
	TInt FindByName(TInt& aFindHandle,const TDesC& aMatch) const;
sl@0
   514
	inline void Lock();
sl@0
   515
	inline void Unlock();
sl@0
   516
	inline TInt UniqueID() const;
sl@0
   517
	inline TInt Count() const;
sl@0
   518
protected:
sl@0
   519
	CFsObjectCon(TInt aUniqueID);
sl@0
   520
	TInt CheckUniqueName(const CFsObject* anObject) const;
sl@0
   521
	TBool NamesMatch(const TName& anObjectName, const CFsObject* aCurrentObject) const;
sl@0
   522
public:
sl@0
   523
	TInt iUniqueID;
sl@0
   524
	TInt iCount;
sl@0
   525
	TInt iAllocated;
sl@0
   526
	CFsObject** iObjects;
sl@0
   527
	RFastLock iLock;
sl@0
   528
friend class CFsObjectConIx;
sl@0
   529
friend class CFsObject;
sl@0
   530
	};
sl@0
   531
sl@0
   532
sl@0
   533
NONSHARABLE_CLASS(CFsSyncMessageScheduler) : public CActive
sl@0
   534
	{
sl@0
   535
public:
sl@0
   536
	static CFsSyncMessageScheduler* NewL();
sl@0
   537
	void DoCancel();
sl@0
   538
	void RunL();
sl@0
   539
	void Dispatch(CFsRequest* aRequest);
sl@0
   540
	void CompleteSessionRequests(CSessionFs* aSession, TInt aValue);
sl@0
   541
private:
sl@0
   542
	CFsSyncMessageScheduler();
sl@0
   543
	void ConstructL();
sl@0
   544
private:
sl@0
   545
	RThread iThread;
sl@0
   546
	RFastLock iLock;
sl@0
   547
	TDblQue<CFsRequest> iList;
sl@0
   548
	TBool iSignalled;
sl@0
   549
	};
sl@0
   550
sl@0
   551
sl@0
   552
NONSHARABLE_CLASS(CNotifyMediaChange) : public CActive
sl@0
   553
	{
sl@0
   554
public:
sl@0
   555
	CNotifyMediaChange(RLocalDrive* aDrive,TInt aSocketNo);
sl@0
   556
	void DoCancel() {};
sl@0
   557
	void RunL();
sl@0
   558
private:
sl@0
   559
	RLocalDrive* iDrive;
sl@0
   560
	TInt iSocket;
sl@0
   561
	};
sl@0
   562
sl@0
   563
sl@0
   564
const TInt KMaxDrivesPerSocket=16;
sl@0
   565
sl@0
   566
class LocalDrives
sl@0
   567
	{
sl@0
   568
public:
sl@0
   569
	static void Initialise();
sl@0
   570
	static TBusLocalDrive& GetLocalDrive(TInt aDriveNumber);
sl@0
   571
	static CExtProxyDrive* GetProxyDrive(TInt aDrive);
sl@0
   572
	static TInt InitProxyDrive(CFsRequest* aRequest);
sl@0
   573
	static TInt MountProxyDrive(CFsRequest* aRequest);
sl@0
   574
	static TInt DismountProxyDrive(TInt iDriveNumber);
sl@0
   575
	static TBool IsValidDriveMapping(TInt aDrvNumber);
sl@0
   576
	static TInt DriveNumberToLocalDriveNumber(TInt aDrvNumber);
sl@0
   577
	static TInt SetDriveMappingL(CFsRequest* aRequest);
sl@0
   578
	static void CompleteNotifications(TInt aSocket);
sl@0
   579
	static void CompleteDriveNotifications(TInt aDriveNumber);
sl@0
   580
	static TInt GetLocalSocket(TInt aControllerRelativeSocket, TMediaDevice aMediaType);
sl@0
   581
	static TInt GetDriveFromLocalDrive(TInt aLocDrv);
sl@0
   582
	static TInt GetLocalDriveNumber(TBusLocalDrive* aLocDrv);
sl@0
   583
	static TBool IsProxyDrive(TInt aDrive);
sl@0
   584
	static void ClearProxyDriveMapping(TInt aDrive);
sl@0
   585
	static TBool IsProxyDriveInUse(CExtProxyDriveFactory* aDevice);
sl@0
   586
	static TInt SetupMediaChange(TInt aDrive);
sl@0
   587
	static void NotifyChangeCancel(TInt aDrive);
sl@0
   588
private:
sl@0
   589
	static void InitDriveMapping();
sl@0
   590
	static TInt SwapDriveMapping(TInt aFirstDrive,TInt aSecondDrive);
sl@0
   591
private:
sl@0
   592
	class TSocketDesc
sl@0
   593
		{
sl@0
   594
	public:
sl@0
   595
		TInt iDriveNumbers[KMaxDrivesPerSocket];	// drive numbers assigned to this socket
sl@0
   596
		CNotifyMediaChange* iMediaChanges;
sl@0
   597
		TMediaDevice iMediaType;
sl@0
   598
		TInt iControllerRelativeSocket;
sl@0
   599
		};
sl@0
   600
	static TSocketDesc iSocketDescs[KMaxPBusSockets];
sl@0
   601
	static TBusLocalDrive iLocalDrives[KMaxLocalDrives];			
sl@0
   602
	static TInt iMapping[KMaxDrives];		// maps drive to local drive
sl@0
   603
	static TBool iMappingSet;
sl@0
   604
	static TInt iReverseMapping[KMaxLocalDrives];// opposite mapping of iMapping. local drive to drive (1 to [potentially] many)
sl@0
   605
	// i.e. LocalDrive1 -> DriveX
sl@0
   606
	//		LocalDrive2 -> DriveX
sl@0
   607
	static TBool iIsMultiSlotDrive[KMaxDrives]; // index is drive number
sl@0
   608
	static CExtProxyDrive* iProxyDriveMapping[KMaxProxyDrives];
sl@0
   609
	
sl@0
   610
	friend void TFsAddCompositeMount::AddFsToCompositeMountL(TInt aDriveNumber, CFileSystem& aFileSystem, TInt aLocalDriveNumber);
sl@0
   611
	friend void TDrive::MultiSlotDriveCheck(); // for dual/multi slot drive map swapping. (iMapping/iReverseMapping)
sl@0
   612
	};
sl@0
   613
sl@0
   614
NONSHARABLE_CLASS(CLogon) : public CActive
sl@0
   615
	{
sl@0
   616
public:
sl@0
   617
	enum {EPriority=3000};
sl@0
   618
public:
sl@0
   619
	static CLogon* NewL();
sl@0
   620
	TInt Logon(RThread aThread);
sl@0
   621
	virtual void DoCancel();
sl@0
   622
	virtual void RunL();
sl@0
   623
protected:
sl@0
   624
	CLogon(TInt aPriority);
sl@0
   625
private:
sl@0
   626
	RThread iThread;
sl@0
   627
	};
sl@0
   628
sl@0
   629
#ifdef __LAZY_DLL_UNLOAD
sl@0
   630
NONSHARABLE_CLASS(CLazyUnloadTimer): public CTimer
sl@0
   631
	{
sl@0
   632
public:
sl@0
   633
	CLazyUnloadTimer();
sl@0
   634
	~CLazyUnloadTimer();
sl@0
   635
	static void New();
sl@0
   636
	static void Finish();
sl@0
   637
private:
sl@0
   638
	void RunL();
sl@0
   639
	void Start();
sl@0
   640
	};
sl@0
   641
#endif
sl@0
   642
sl@0
   643
NONSHARABLE_CLASS(CSessionLoader) : public CSession2
sl@0
   644
	{
sl@0
   645
private:
sl@0
   646
	virtual void ServiceL(const RMessage2& aMessage);
sl@0
   647
	TInt DeleteExecutable(const TDesC& aName);
sl@0
   648
	};
sl@0
   649
sl@0
   650
NONSHARABLE_CLASS(CServerLoader) : public CServer2
sl@0
   651
	{
sl@0
   652
public:
sl@0
   653
	enum {EPriority=2000};
sl@0
   654
public:
sl@0
   655
	static CServerLoader* New();
sl@0
   656
	virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
sl@0
   657
	virtual TInt RunError(TInt aError);
sl@0
   658
private:
sl@0
   659
	CServerLoader(TInt aPriority);
sl@0
   660
	};
sl@0
   661
sl@0
   662
class RLoaderMsg : public RMessage2
sl@0
   663
	{
sl@0
   664
public:
sl@0
   665
	TInt GetString(HBufC8*& aBuf, TInt aParam, TInt aMaxLen, TInt aHeadroom, TBool aReduce) const;
sl@0
   666
	TInt GetLdrInfo(TLdrInfo& aInfo) const;
sl@0
   667
	TInt UpdateLdrInfo(const TLdrInfo& aInfo) const;
sl@0
   668
	};
sl@0
   669
sl@0
   670
 void Fault(TFsFault aFault);
sl@0
   671
sl@0
   672
class CSessionFs;
sl@0
   673
class TOperation;
sl@0
   674
class CRequestThread;
sl@0
   675
sl@0
   676
typedef TInt (*TFsRequestFunc)(CFsRequest*);
sl@0
   677
sl@0
   678
class TThreadTimer
sl@0
   679
	{
sl@0
   680
public:
sl@0
   681
	TThreadTimer(TInt (*aCallBackFunction)(TAny* aPtr),TAny* aPtr);
sl@0
   682
sl@0
   683
	void Start(CRequestThread* aRequestThread, TTimeIntervalMicroSeconds32 aTime);
sl@0
   684
	void Stop();
sl@0
   685
sl@0
   686
private:
sl@0
   687
	TTickCountQueLink iLink;
sl@0
   688
	TCallBack iCallBack;
sl@0
   689
	CRequestThread* iRequestThread;	// the thread the timer is running on, NULL if timer not running
sl@0
   690
sl@0
   691
	friend class CFsDeltaTimer;
sl@0
   692
	};
sl@0
   693
sl@0
   694
// Class adapted from CDeltaTimer (but unlike CDeltaTimer, not derived from CActive).
sl@0
   695
// Used to support multiple timer events in drive threads.
sl@0
   696
NONSHARABLE_CLASS(CFsDeltaTimer) : public CBase
sl@0
   697
	{
sl@0
   698
public:
sl@0
   699
	static CFsDeltaTimer* New(CRequestThread& aRequestThread, TInt aPriority);
sl@0
   700
	~CFsDeltaTimer();
sl@0
   701
sl@0
   702
	void Start(TThreadTimer& aEntry, TTimeIntervalMicroSeconds32 aTime);
sl@0
   703
	void Stop(TThreadTimer& aEntry);
sl@0
   704
sl@0
   705
	void RunL();
sl@0
   706
private:
sl@0
   707
	CFsDeltaTimer(CRequestThread& aRequestThread, TInt aPriority, TInt aTickPeriod);
sl@0
   708
	void Cancel();
sl@0
   709
	void Activate();
sl@0
   710
	TInt QueueLong(TTimeIntervalMicroSeconds aTimeInMicroSeconds, TThreadTimer& aEntry);
sl@0
   711
private:	
sl@0
   712
	CRequestThread& iRequestThread;
sl@0
   713
	TThreadId iThreadId;
sl@0
   714
	RTimer iTimer;
sl@0
   715
	TTickCountQue iQueue;
sl@0
   716
	const TInt iTickPeriod;
sl@0
   717
	TBool iQueueBusy;
sl@0
   718
	RFastLock iLock;
sl@0
   719
	TBool iRestartNeeded;	// timer needs to be restarted as it was scheduled from a different thread
sl@0
   720
public:
sl@0
   721
	TRequestStatus iStatus;
sl@0
   722
	};
sl@0
   723
sl@0
   724
sl@0
   725
NONSHARABLE_CLASS(CRequestThread) : public CBase
sl@0
   726
	{
sl@0
   727
public:
sl@0
   728
	TInt ThreadFunction();
sl@0
   729
	void DeliverBack(CFsRequest* aRequest, TBool aLowPriority = EFalse);
sl@0
   730
	void DeliverFront(CFsRequest* aRequests);
sl@0
   731
sl@0
   732
	~CRequestThread();
sl@0
   733
sl@0
   734
	CFsDeltaTimer* Timer();
sl@0
   735
sl@0
   736
	void CompleteAllRequests(TInt aValue);
sl@0
   737
protected:
sl@0
   738
	CRequestThread();
sl@0
   739
	TInt DoStart(RThread& aThread);
sl@0
   740
	inline TInt Initialise();
sl@0
   741
	void Deliver(CFsRequest* aRequest,TBool aIsFront, TBool aLowPriority = EFalse);
sl@0
   742
	void Receive();
sl@0
   743
	virtual TInt DoThreadInitialise();
sl@0
   744
protected:
sl@0
   745
	CFsRequest* iRequest;
sl@0
   746
	TDblQue<CFsRequest> iList;
sl@0
   747
	RFastLock iListLock;
sl@0
   748
	TBool iIsWaiting;
sl@0
   749
	TBool iExit;
sl@0
   750
	RThread iThread;
sl@0
   751
	CFsDeltaTimer* iTimer;
sl@0
   752
	TBool iLowPriority;		// if true, drive thread's priority has been (temporarily) reduced
sl@0
   753
	friend class CFsDeltaTimer;
sl@0
   754
	};
sl@0
   755
sl@0
   756
sl@0
   757
sl@0
   758
sl@0
   759
NONSHARABLE_CLASS(CDriveThread) : public CRequestThread
sl@0
   760
	{
sl@0
   761
public:
sl@0
   762
	void CompleteReadWriteRequests();
sl@0
   763
	void CompleteSessionRequests(CSessionFs* aSession, TInt aValue);
sl@0
   764
	void CompleteClientRequests(TInt aValue);
sl@0
   765
	TBool IsRequestWriteable();
sl@0
   766
	TBool IsSessionNotifyUser();
sl@0
   767
private:
sl@0
   768
	CDriveThread();
sl@0
   769
	static CDriveThread* NewL();
sl@0
   770
	TUint StartL(TInt aDrvNumber);
sl@0
   771
	TInt DoThreadInitialise();
sl@0
   772
sl@0
   773
	void StartFinalisationTimer();
sl@0
   774
	void StopFinalisationTimer();
sl@0
   775
sl@0
   776
	static TInt FinaliseTimerEvent(TAny* aFileCache);
sl@0
   777
private:
sl@0
   778
	TInt iDriveNumber;
sl@0
   779
	TThreadTimer iFinaliseTimer;
sl@0
   780
sl@0
   781
friend class FsThreadManager;
sl@0
   782
	};
sl@0
   783
sl@0
   784
class CFsInternalRequest;
sl@0
   785
sl@0
   786
NONSHARABLE_CLASS(CDisconnectThread) : public CRequestThread
sl@0
   787
	{
sl@0
   788
public:
sl@0
   789
	inline CFsInternalRequest* GetRequest();
sl@0
   790
private:
sl@0
   791
	static CDisconnectThread* NewL();
sl@0
   792
	TUint StartL();
sl@0
   793
	~CDisconnectThread();	
sl@0
   794
private:
sl@0
   795
	CFsInternalRequest* iRequest;
sl@0
   796
friend class FsThreadManager;
sl@0
   797
	};
sl@0
   798
sl@0
   799
class CFsPlugin;
sl@0
   800
NONSHARABLE_CLASS(CPluginThread) : public CRequestThread
sl@0
   801
	{
sl@0
   802
public:
sl@0
   803
	CPluginThread(CFsPlugin& aPlugin);
sl@0
   804
	~CPluginThread();
sl@0
   805
	
sl@0
   806
	void CompleteSessionRequests(CSessionFs* aSession, TInt aValue);
sl@0
   807
sl@0
   808
	/** @prototype */
sl@0
   809
	void OperationLockWait();
sl@0
   810
sl@0
   811
	/** @prototype */
sl@0
   812
	void OperationLockSignal();
sl@0
   813
sl@0
   814
private:
sl@0
   815
	static CPluginThread* NewL(CFsPlugin& aPlugin);
sl@0
   816
	TUint StartL();
sl@0
   817
	virtual TInt DoThreadInitialise();
sl@0
   818
private:
sl@0
   819
	CFsPlugin& iPlugin;
sl@0
   820
sl@0
   821
	/** @prototype */
sl@0
   822
	RSemaphore iOperationLock;
sl@0
   823
sl@0
   824
friend class FsPluginManager;
sl@0
   825
	};
sl@0
   826
sl@0
   827
class TFsDriveThread
sl@0
   828
	{
sl@0
   829
public:
sl@0
   830
	TFsDriveThread();
sl@0
   831
public:
sl@0
   832
	RMutex iFSLock;
sl@0
   833
	TBool iIsAvailable;
sl@0
   834
	TBool iIsSync;
sl@0
   835
	CDriveThread* iThread;
sl@0
   836
	TUint iId;
sl@0
   837
	TBool iIsHung;				// drive is hung waiting for a critical notifier
sl@0
   838
	TBool iMediaChangePending;	// media change is pending while hung
sl@0
   839
	};
sl@0
   840
sl@0
   841
sl@0
   842
class FsThreadManager
sl@0
   843
	{
sl@0
   844
public:
sl@0
   845
	static TInt CreateDisconnectThread();
sl@0
   846
	static inline CDisconnectThread* GetDisconnectThread() {return(iDisconnectThread);}
sl@0
   847
	static TBool IsDisconnectThread();
sl@0
   848
//
sl@0
   849
	static void SetMainThreadId();
sl@0
   850
	static TBool IsMainThread();
sl@0
   851
//
sl@0
   852
	static TInt InitDrive(TInt aDrvNumber,TBool aIsSync);
sl@0
   853
	static TInt ChangeSync(TInt aDrvNumber,TBool aIsSync);
sl@0
   854
sl@0
   855
	static TInt GetDriveThread(TInt aDrvNumber, CDriveThread** aDrvThread);
sl@0
   856
	static void CloseDrive(TInt aDrvNumber);
sl@0
   857
	static TBool IsDriveThread(TInt aDrvNumber,TBool aLock);
sl@0
   858
	static TBool IsDriveSync(TInt aDrvNumber,TBool aLock);
sl@0
   859
	static TBool IsDriveAvailable(TInt aDrvNumber,TBool aLock);
sl@0
   860
	static void LockDrive(TInt aDrvNumber);
sl@0
   861
	static void UnlockDrive(TInt aDrvNumber);			
sl@0
   862
	static void SetDriveHung(TInt aDrvNumber, TBool aIsHung);
sl@0
   863
	static TBool IsDriveHung(TInt aDrvNumber);
sl@0
   864
	static void SetMediaChangePending(TInt aDrvNumber);
sl@0
   865
	static void StartFinalisationTimer(TInt aDriveNumber);
sl@0
   866
	static void StopFinalisationTimer(TInt aDriveNumber);
sl@0
   867
private:
sl@0
   868
	inline static TFsDriveThread& GetFsDriveThread(TInt aDrvNumber) {return(iFsThreads[aDrvNumber]);}
sl@0
   869
private:
sl@0
   870
	static TFsDriveThread iFsThreads[KMaxDrives];
sl@0
   871
	static TUint iMainId;
sl@0
   872
	static CDisconnectThread* iDisconnectThread;
sl@0
   873
	static TUint iDisconnectThreadId;
sl@0
   874
	};
sl@0
   875
sl@0
   876
sl@0
   877
const TInt KReservedDriveAccessArrayGranularity = 2;
sl@0
   878
sl@0
   879
class TReservedDriveAccess
sl@0
   880
	{
sl@0
   881
public:
sl@0
   882
	inline TReservedDriveAccess(TInt aDriveNumber);
sl@0
   883
	inline TReservedDriveAccess(TInt aDriveNumber, TInt aReservedSpace);
sl@0
   884
private:
sl@0
   885
	TReservedDriveAccess();
sl@0
   886
public:
sl@0
   887
	TInt iDriveNumber;
sl@0
   888
	TInt iReservedSpace;
sl@0
   889
	TInt iReservedAccess;
sl@0
   890
	};
sl@0
   891
sl@0
   892
sl@0
   893
class CFsMessageRequest;
sl@0
   894
NONSHARABLE_CLASS(CSessionFs) : public CSession2
sl@0
   895
	{
sl@0
   896
public:
sl@0
   897
	static CSessionFs* NewL();
sl@0
   898
	~CSessionFs();
sl@0
   899
	virtual void CreateL();
sl@0
   900
	TInt CurrentDrive();
sl@0
   901
	void ServiceL(const RMessage2& aMessage);
sl@0
   902
	TInt CountResources();
sl@0
   903
	void ResourceCountMarkStart();
sl@0
   904
	void ResourceCountMarkEnd(const RMessage2& aMessage);
sl@0
   905
	TBool GetNotifyUser();
sl@0
   906
	void SetNotifyUser(TBool aNotification);
sl@0
   907
	TBool IsChangeNotify();
sl@0
   908
	void SetSessionFlags(TUint32 aBitsToSet, TUint32 aBitsToClear);
sl@0
   909
	TBool TestSessionFlags(TUint32 aFlags);
sl@0
   910
	void CloseRequestCountInc();
sl@0
   911
	void CloseRequestCountDec();
sl@0
   912
	
sl@0
   913
	//
sl@0
   914
	virtual void Disconnect(const RMessage2& aMessage);
sl@0
   915
	//
sl@0
   916
	inline void IncResourceCount();
sl@0
   917
	inline void DecResourceCount();
sl@0
   918
	inline CFsObjectIx& Handles();
sl@0
   919
	inline HBufC& Path();
sl@0
   920
	inline void SetPath(HBufC* aPath);
sl@0
   921
	inline TThreadId& ThreadId();
sl@0
   922
	inline void SetThreadId(const TThreadId& aId);
sl@0
   923
	//
sl@0
   924
	TUint Reserved(TInt aDriveNumber) const;
sl@0
   925
	TInt SetReserved(const TInt aDriveNumber, const TInt aReservedValue);
sl@0
   926
	TBool ReservedAccess(TInt aDriveNumber) const;
sl@0
   927
	void SetReservedAccess(const TInt aDriveNumber, const TBool aReservedAccess);
sl@0
   928
private:
sl@0
   929
	CSessionFs();
sl@0
   930
sl@0
   931
private:
sl@0
   932
	TInt iResourceCountMark;
sl@0
   933
	TInt iResourceCount;
sl@0
   934
	TInt iSessionFlags;
sl@0
   935
	RFastLock iSessionFlagsLock;
sl@0
   936
	CFsObjectIx* iHandles;
sl@0
   937
	HBufC* iPath;
sl@0
   938
	CFsMessageRequest* iDisconnectRequest;
sl@0
   939
	RArray<TReservedDriveAccess> iReservedDriveAccess;
sl@0
   940
	TThreadId iId;
sl@0
   941
	TInt iCloseRequestCount;	// number of close requests owned by this sessions on the RequestAllocator close queue
sl@0
   942
friend class CFsDisconnectRequest;
sl@0
   943
	};
sl@0
   944
sl@0
   945
NONSHARABLE_CLASS(CServerFs) : public CServer2
sl@0
   946
	{
sl@0
   947
public:
sl@0
   948
	enum {EPriority=1000};
sl@0
   949
public:
sl@0
   950
	virtual ~CServerFs();
sl@0
   951
	static void New();
sl@0
   952
	virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
sl@0
   953
	CSessionFs* operator[](TInt anIndex);
sl@0
   954
	inline void SessionQueueLockWait();
sl@0
   955
	inline void SessionQueueLockSignal();
sl@0
   956
protected:
sl@0
   957
	// from CServerFs
sl@0
   958
	void RunL();
sl@0
   959
sl@0
   960
private:
sl@0
   961
	CServerFs(TInt aPriority);
sl@0
   962
	// lock to protect iSessionQ
sl@0
   963
	RFastLock iSessionQueueLock;
sl@0
   964
	};
sl@0
   965
sl@0
   966
NONSHARABLE_CLASS(CActiveSchedulerFs) : public CActiveScheduler
sl@0
   967
	{
sl@0
   968
public:
sl@0
   969
	static void New();
sl@0
   970
	virtual void Error(TInt anError) const;
sl@0
   971
	};
sl@0
   972
sl@0
   973
NONSHARABLE_CLASS(CActiveSchedulerLoader) : public CActiveScheduler
sl@0
   974
	{
sl@0
   975
public:
sl@0
   976
	static CActiveSchedulerLoader* New();
sl@0
   977
	virtual void Error(TInt anError) const;
sl@0
   978
	};
sl@0
   979
sl@0
   980
sl@0
   981
class TNameChecker
sl@0
   982
	{
sl@0
   983
public:
sl@0
   984
	TNameChecker(const TDesC& aPathName): iName(aPathName){};
sl@0
   985
	TBool IsIllegalChar(TText& aChar);
sl@0
   986
	TBool IsIllegalName();
sl@0
   987
	TBool IsIllegalName(TText& aChar);
sl@0
   988
	TBool IsIllegalPath();
sl@0
   989
	TBool IsIllegalPath(TText& aChar);
sl@0
   990
	void SetName(const TDesC& aName){iName=aName;};
sl@0
   991
private:
sl@0
   992
	TBool IsIllegal(TText& aChar) const;
sl@0
   993
private:
sl@0
   994
	TFileName iName;
sl@0
   995
	TParse iParse;
sl@0
   996
	};
sl@0
   997
sl@0
   998
enum TOperationFlags
sl@0
   999
		{
sl@0
  1000
		ESync = 0x01, 
sl@0
  1001
		EInternalRequest = 0x02,	// NB Not really used!
sl@0
  1002
		EParseSrc = 0x04, 
sl@0
  1003
		EParseDst = 0x08,
sl@0
  1004
		EFileShare = 0x10,			// Operates on an open file share
sl@0
  1005
		};
sl@0
  1006
sl@0
  1007
class TOperation
sl@0
  1008
	{
sl@0
  1009
public:
sl@0
  1010
	TBool IsChangeNotify() const;
sl@0
  1011
	TBool IsDiskSpaceNotify() const;
sl@0
  1012
	TBool IsWrite() const;
sl@0
  1013
	TUint NotifyType() const;
sl@0
  1014
	TBool IsCompleted() const;
sl@0
  1015
	TBool IsOpenSubSess() const; //used to allocate for close as well as open task for subsessions
sl@0
  1016
	TBool IsCloseSubSess() const;
sl@0
  1017
sl@0
  1018
	inline TBool IsSync() const;
sl@0
  1019
	inline TInt Function();
sl@0
  1020
	inline TInt Initialise(CFsRequest* aRequest);
sl@0
  1021
	inline TInt PostInitialise(CFsRequest* aRequest);
sl@0
  1022
	inline TInt DoRequestL(CFsRequest* aRequest);
sl@0
  1023
	inline TFsPluginRequest::TF32ArgType Arg(TUint aIndex);
sl@0
  1024
	
sl@0
  1025
public:
sl@0
  1026
	TInt iFunction;
sl@0
  1027
	TUint iFlags;
sl@0
  1028
	TFsRequestFunc iInitialise;
sl@0
  1029
	// optional processing step. Runs initially in context of main file server thread
sl@0
  1030
	// but may be executed again in drive thread context if request is postponed
sl@0
  1031
	TFsRequestFunc iPostInitialise;
sl@0
  1032
	TFsRequestFunc iDoRequestL;
sl@0
  1033
	TUint32 iArgs;
sl@0
  1034
	};
sl@0
  1035
sl@0
  1036
class TMsgOperation
sl@0
  1037
	{
sl@0
  1038
public:
sl@0
  1039
	inline void Set(TInt64 aPos, TInt aLength, TUint8* aData, TInt aOffset = 0, TInt aNextState = 0);
sl@0
  1040
	inline void Set(TInt64 aPos, TInt aLength, TDesC8* aData, TInt aOffset = 0, TInt aNextState = 0);
sl@0
  1041
public:
sl@0
  1042
	
sl@0
  1043
	typedef struct
sl@0
  1044
		{
sl@0
  1045
		TAny* iData;	// pointer to local buffer (TUint8*) or remote client decriptor (TDesC8*)
sl@0
  1046
		TInt iTotalLength;
sl@0
  1047
		TInt64 iPos;
sl@0
  1048
		TInt iLength;	// length of current fair-scheduled read/write 
sl@0
  1049
		TInt iOffset;	// offset into iData
sl@0
  1050
		} SReadWriteArgs;
sl@0
  1051
sl@0
  1052
	union
sl@0
  1053
		{
sl@0
  1054
		TInt iArgs[KMaxMessageArguments];
sl@0
  1055
		SReadWriteArgs iReadWriteArgs;
sl@0
  1056
		};
sl@0
  1057
sl@0
  1058
	TInt iFunction;				// the current function (usually, but not always the same as TOperation.iFunction
sl@0
  1059
	TFsRequestFunc iComplete;	// function to call when CFsMessageRequest::Complete() is called
sl@0
  1060
	CFsPlugin* iCurrentPlugin;	// The current plugin at the stage this Operation was pushed
sl@0
  1061
sl@0
  1062
	TBool iClientRequest;		// The current request originated through RFile/RFilePlugin, so uses a descriptor buffer: 
sl@0
  1063
								// An EFSRV client request 		non-local handle	non-local buffer	descriptor
sl@0
  1064
								// A plugin request				local handle		local buffer		descriptor
sl@0
  1065
								// An internal (cache) request	local handle		local buffer		raw pointer
sl@0
  1066
	TInt iState;
sl@0
  1067
	TMsgOperation* iNext;
sl@0
  1068
	TMsgOperation* iPrev;
sl@0
  1069
	TBool iIsAllocated;
sl@0
  1070
	TAny* iScratchValue0;
sl@0
  1071
	TAny* iScratchValue1;
sl@0
  1072
	TInt64 iClientPosition;
sl@0
  1073
	};
sl@0
  1074
sl@0
  1075
sl@0
  1076
sl@0
  1077
NONSHARABLE_CLASS(CFsRequest) : public CBase
sl@0
  1078
	{
sl@0
  1079
public:
sl@0
  1080
	/** Request states - these indicate a message's current stage of processing 
sl@0
  1081
	*/
sl@0
  1082
	enum TReqStates
sl@0
  1083
		{
sl@0
  1084
		/** Need to call iOperation.iInitialise() */
sl@0
  1085
		EReqStateInitialise,
sl@0
  1086
		/** Need to call PostInitialise() */
sl@0
  1087
		EReqStatePostInitialise,
sl@0
  1088
		/** Need to call iOperation.iDoRequestL */
sl@0
  1089
		EReqStateDoRequest,
sl@0
  1090
		};
sl@0
  1091
sl@0
  1092
sl@0
  1093
	/** 
sl@0
  1094
	Request actions - these indicate what further processing is required 
sl@0
  1095
	and may be returned by any of:	
sl@0
  1096
sl@0
  1097
		CFsRequest::iOperation->Initialise()
sl@0
  1098
		CFsPlugin::DoRequestL()
sl@0
  1099
		CFsMessageRequest::iOperation->iPostInitialise()
sl@0
  1100
		CFsRequest::iOperation->DoRequestL()
sl@0
  1101
		CFsMessageRequest::iCurrentOperation->iComplete()
sl@0
  1102
sl@0
  1103
	The last 3 bits of each return code are used in CFsMessageRequest::Complete() 
sl@0
  1104
	as an array look up to determine what action to take
sl@0
  1105
	 */
sl@0
  1106
	enum TReqActions 
sl@0
  1107
		{
sl@0
  1108
		/** 
sl@0
  1109
		Continue with processing, dispatching to drive thread if necessary
sl@0
  1110
		NB same value as KErrNone to maintain compatibility with existing code
sl@0
  1111
		*/
sl@0
  1112
		EReqActionContinue = KErrNone,			// 0x00000000, last 3 bits = 0
sl@0
  1113
sl@0
  1114
		/** 
sl@0
  1115
		Complete and free the message 
sl@0
  1116
		*/
sl@0
  1117
		EReqActionComplete = KErrCompletion,		// 0xFFFFFFEF, last 3 bits = 7
sl@0
  1118
		
sl@0
  1119
		/** 
sl@0
  1120
		A resource is in use, so dispatch message again to back of drive thread's request queue
sl@0
  1121
		If returned by Initialise(), then Initialse() will be called again
sl@0
  1122
		If returned by Complete(), then iPostInitialise() will be called again
sl@0
  1123
		*/
sl@0
  1124
		EReqActionBusy = -0x1002,				// 0xFFFFEFFE, last 3 bits = 6
sl@0
  1125
		
sl@0
  1126
		/** 
sl@0
  1127
		Neither dispatch nor complete the message - 
sl@0
  1128
		a plugin thread has taken ownership of the message
sl@0
  1129
		*/
sl@0
  1130
		EReqActionOwnedByPlugin = -0x1003,		// 0xFFFFEFFD, last 3 bits = 5
sl@0
  1131
sl@0
  1132
		/**
sl@0
  1133
		The request cannot be processed because there is already an active read/write request 
sl@0
  1134
		for the associated file share. This request has been linked to the currently active
sl@0
  1135
		request and will be dispatched to the the drive thread when the current request has completed.
sl@0
  1136
		@see CFileShare::RequestStart() & CFileShare::RequestEnd()
sl@0
  1137
		*/
sl@0
  1138
		EReqActionPending = EReqActionOwnedByPlugin,
sl@0
  1139
		};
sl@0
  1140
public:
sl@0
  1141
	~CFsRequest();
sl@0
  1142
sl@0
  1143
	void ReadL(const TInt aMsgNum,TDes8& aDes);
sl@0
  1144
	void ReadL(const TInt aMsgNum,TDes8& aDes,TInt anOffset);
sl@0
  1145
	void ReadL(const TInt aMsgNum,TDes16& aDes);
sl@0
  1146
	void ReadL(const TInt aMsgNum,TDes16& aDes,TInt anOffset);
sl@0
  1147
sl@0
  1148
	void WriteL(const TInt aMsgNum,const TDesC8& aDes);
sl@0
  1149
	void WriteL(const TInt aMsgNum,const TDesC8& aDes,TInt anOffset);
sl@0
  1150
	void WriteL(const TInt aMsgNum,const TDesC16& aDes);
sl@0
  1151
	void WriteL(const TInt aMsgNum,const TDesC16& aDes,TInt anOffset);
sl@0
  1152
sl@0
  1153
	TInt Read(const TInt aMsgNum,TDes8& aDes);
sl@0
  1154
	TInt Read(const TInt aMsgNum,TDes8& aDes,TInt anOffset);
sl@0
  1155
	TInt Read(const TInt aMsgNum,TDes16& aDes);
sl@0
  1156
	TInt Read(const TInt aMsgNum,TDes16& aDes,TInt anOffset);
sl@0
  1157
sl@0
  1158
	TInt Write(const TInt aMsgNum,const TDesC8& aDes);
sl@0
  1159
	TInt Write(const TInt aMsgNum,const TDesC8& aDes,TInt anOffset);
sl@0
  1160
	TInt Write(const TInt aMsgNum,const TDesC16& aDes);
sl@0
  1161
	TInt Write(const TInt aMsgNum,const TDesC16& aDes,TInt anOffset);
sl@0
  1162
sl@0
  1163
	TInt GetDesLength(const TInt aMsgNum);
sl@0
  1164
sl@0
  1165
	inline void Kill(TInt aReason);
sl@0
  1166
	inline void Terminate(TInt aReason);
sl@0
  1167
	inline void Panic(const TDesC &aCategory,TInt aReason);
sl@0
  1168
	inline TBool ErrorPlugin(TInt aReason);
sl@0
  1169
sl@0
  1170
	TInt Read(TFsPluginRequest::TF32ArgType aType, TInt& aVal);
sl@0
  1171
	TInt Read(TFsPluginRequest::TF32ArgType aType, TUint& aVal);
sl@0
  1172
	TInt Read(TFsPluginRequest::TF32ArgType aType, TInt64& aVal);
sl@0
  1173
	//
sl@0
  1174
	TInt Read(TFsPluginRequest::TF32ArgType aType, TDes8& aDes,  TInt aOffset = 0);
sl@0
  1175
	TInt Read(TFsPluginRequest::TF32ArgType aType, TDes16& aDes, TInt aOffset = 0);
sl@0
  1176
	//
sl@0
  1177
	TInt Write(TFsPluginRequest::TF32ArgType aType, const TDesC8& aDes,  TInt aOffset = 0);
sl@0
  1178
	TInt Write(TFsPluginRequest::TF32ArgType aType, const TDesC16& aDes, TInt aOffset = 0);
sl@0
  1179
sl@0
  1180
	inline TInt Initialise(){return iOperation->Initialise(this);};
sl@0
  1181
	virtual void Process()=0;
sl@0
  1182
	virtual void Complete(TInt aError)=0;
sl@0
  1183
	virtual void Dispatch()=0;
sl@0
  1184
	virtual void Free()=0;
sl@0
  1185
	//
sl@0
  1186
	virtual TParse& Src();
sl@0
  1187
	virtual TParse& Dest();
sl@0
  1188
	virtual TDrive* Drive();
sl@0
  1189
	virtual TDrive* SubstedDrive();
sl@0
  1190
	virtual void SetDrive(TDrive* aDrive);
sl@0
  1191
	virtual void SetSubstedDrive(TDrive* aDrive);
sl@0
  1192
	virtual const RMessage2& Message();
sl@0
  1193
	//
sl@0
  1194
	inline TOperation* Operation();
sl@0
  1195
	inline CSessionFs* Session();
sl@0
  1196
	inline void SetSession(CSessionFs* aSession);
sl@0
  1197
	inline TInt DriveNumber();
sl@0
  1198
	inline void SetDriveNumber(TInt aDriveNumber);
sl@0
  1199
	inline TBool IsCompleted();
sl@0
  1200
	inline void SetCompleted(TBool aIsCompleted);
sl@0
  1201
	inline TUint ScratchValue();
sl@0
  1202
	inline void SetScratchValue(const TUint aValue);
sl@0
  1203
	inline TInt64 ScratchValue64();
sl@0
  1204
	inline void SetScratchValue64(const TInt64& aValue);
sl@0
  1205
	inline TBool IsSeparateThread();
sl@0
  1206
	inline TBool IsPostOperation() const;
sl@0
  1207
	inline TBool IsPluginSpecific() const;
sl@0
  1208
	inline TBool IsExpectedResult(TInt err) const;
sl@0
  1209
	inline TBool IsChangeNotify() const;
sl@0
  1210
	inline void SetState(TReqStates aReqState);
sl@0
  1211
	inline TBool DirectToDrive();
sl@0
  1212
	inline TBool IsDescData(TInt aMsgNum);
sl@0
  1213
	inline TInt FsFunction();
sl@0
  1214
sl@0
  1215
public:
sl@0
  1216
	CFsRequest();
sl@0
  1217
protected:
sl@0
  1218
	inline void Set(const TOperation& aOperation,CSessionFs* aSession);
sl@0
  1219
	inline void Set(CSessionFs* aSession);
sl@0
  1220
	inline void SetError(TInt aError);
sl@0
  1221
	inline TInt GetError() const;
sl@0
  1222
	inline void SetPostOperation(TBool aSet);
sl@0
  1223
sl@0
  1224
	inline TBool IsFsObjectOpen();
sl@0
  1225
	inline void SetFsObjectOpen(TBool aSet);
sl@0
  1226
	void SetAndOpenScratchValue(const TInt64& aValue);
sl@0
  1227
sl@0
  1228
private:
sl@0
  1229
	TInt GetSlot(TFsPluginRequest::TF32ArgType aType);
sl@0
  1230
public:
sl@0
  1231
	TDblQueLink iLink;
sl@0
  1232
	CFsPlugin* iCurrentPlugin;
sl@0
  1233
	CFsPlugin* iOwnerPlugin;	// the plugin which originated this request
sl@0
  1234
	TThreadId iClientThreadId;
sl@0
  1235
	TBool iDirectToDrive;
sl@0
  1236
protected:
sl@0
  1237
	CSessionFs* iSession;
sl@0
  1238
	TOperation* iOperation;
sl@0
  1239
	TInt iDriveNumber;
sl@0
  1240
	TBool iIsCompleted;
sl@0
  1241
	TInt64 iScratchValue;
sl@0
  1242
	
sl@0
  1243
	TReqStates iReqState;
sl@0
  1244
sl@0
  1245
	/** defines for iFlags
sl@0
  1246
	*/
sl@0
  1247
	enum TFsRequestFlags
sl@0
  1248
		{
sl@0
  1249
		EIsAllocated			= 0x01,
sl@0
  1250
		EFreeChanged			= 0x02,		// valid only for EFsFileWrite
sl@0
  1251
		EPostInterceptEnabled	= 0x04,
sl@0
  1252
		EPostOperation			= 0x08,
sl@0
  1253
		EFsObjectOpen			= 0x10,
sl@0
  1254
		};
sl@0
  1255
	TUint iFlags;
sl@0
  1256
sl@0
  1257
	TInt iError;
sl@0
  1258
	};
sl@0
  1259
sl@0
  1260
const TInt KOperationFunctionUnaltered = -1;
sl@0
  1261
sl@0
  1262
NONSHARABLE_CLASS(CFsMessageRequest) : public CFsRequest
sl@0
  1263
	{
sl@0
  1264
public:
sl@0
  1265
	void Set(const RMessage2& aMessage,CSessionFs* aSession);
sl@0
  1266
	void Set(const RMessage2& aMessage,const TOperation& aOperation,CSessionFs* aSession);
sl@0
  1267
	void Set(const TOperation& aOperation);
sl@0
  1268
	inline void SetPostInitialise(TFsRequestFunc aCacheFunction);
sl@0
  1269
	//
sl@0
  1270
	inline void SetMessage(RMessage2& aMessage);
sl@0
  1271
	//
sl@0
  1272
	virtual void Process();
sl@0
  1273
	virtual void Complete(TInt aError);
sl@0
  1274
sl@0
  1275
	virtual void Dispatch();
sl@0
  1276
	virtual void Free();
sl@0
  1277
	virtual TDrive* Drive();
sl@0
  1278
	virtual TDrive* SubstedDrive();
sl@0
  1279
	virtual void SetDrive(TDrive* aDrive);
sl@0
  1280
	virtual void SetSubstedDrive(TDrive* aDrive);
sl@0
  1281
	virtual const RMessage2& Message();
sl@0
  1282
sl@0
  1283
	inline TBool IsFreeChanged();
sl@0
  1284
	inline void SetFreeChanged(TBool aChanged);
sl@0
  1285
sl@0
  1286
	inline TBool PostInterceptEnabled();
sl@0
  1287
	inline void EnablePostIntercept(TBool aEnable);
sl@0
  1288
sl@0
  1289
	inline TBool IsAllocated();
sl@0
  1290
	inline void SetAllocated();
sl@0
  1291
	inline CFsMessageRequest();
sl@0
  1292
	
sl@0
  1293
	TInt PushOperation(TInt64 aPos, TInt aLength, TUint8* aData, TInt aOffset = 0, TFsRequestFunc aCallback = NULL, TInt aNextState = 0, TInt aFunction = KOperationFunctionUnaltered);
sl@0
  1294
	TInt PushOperation(TInt64 aPos, TInt aLength, TDesC8* aData, TInt aOffset = 0, TFsRequestFunc aCallback = NULL, TInt aNextState = 0, TInt aFunction = KOperationFunctionUnaltered);
sl@0
  1295
	TInt PushOperation(TFsRequestFunc aCallback = NULL, TInt aNextState = 0, TInt aFunction = KOperationFunctionUnaltered);
sl@0
  1296
	void PopOperation();
sl@0
  1297
	void SetOperationFunc(TInt aFunction);
sl@0
  1298
	TMsgOperation& CurrentOperation();
sl@0
  1299
	inline TMsgOperation* CurrentOperationPtr();
sl@0
  1300
	void Dispatch(TBool aInitialise, TBool aLowPriority = EFalse, TBool aDispatchToFront = EFalse);
sl@0
  1301
sl@0
  1302
	inline TInt& LastError();
sl@0
  1303
	inline void SetLastError(TInt aLastError);
sl@0
  1304
	inline void Init();
sl@0
  1305
	void ReStart();
sl@0
  1306
	TBool IsPluginRequest();
sl@0
  1307
	
sl@0
  1308
   // UID of the process to touching the file. (To be used in notification framework).
sl@0
  1309
   // TUid iUID;
sl@0
  1310
private:
sl@0
  1311
	void DoNotify(TInt aError);
sl@0
  1312
	TInt DoInitialise();
sl@0
  1313
	TInt PostInitialise();
sl@0
  1314
	TBool DispatchToPlugin();
sl@0
  1315
	void ProcessPostOperation();
sl@0
  1316
	void ProcessPreOperation();
sl@0
  1317
	void ProcessDriveOperation();
sl@0
  1318
	TBool CurrentPluginWaiting();
sl@0
  1319
	inline TInt DispatchToDrive(TBool aLowPriority, TBool aDispatchToFront);
sl@0
  1320
	TBool IsNotifierSpecific() const;
sl@0
  1321
	TBool IsNotifierSupported() const;
sl@0
  1322
protected:
sl@0
  1323
	RMessage2 iMessage;
sl@0
  1324
	TDrive* iDrive;
sl@0
  1325
	TDrive* iSubstedDrive;
sl@0
  1326
private:
sl@0
  1327
	TMsgOperation* iCurrentOperation;
sl@0
  1328
	TInt iLastError;
sl@0
  1329
	};
sl@0
  1330
sl@0
  1331
sl@0
  1332
NONSHARABLE_CLASS(TParsePool)
sl@0
  1333
	{
sl@0
  1334
private:
sl@0
  1335
	enum {KEBlockSize = 4};
sl@0
  1336
sl@0
  1337
public:
sl@0
  1338
	static TInt			Init();
sl@0
  1339
	static TParsePool*	Get();
sl@0
  1340
	static void			Release(TParsePool* aObject);
sl@0
  1341
	TParsePool ();
sl@0
  1342
	TParse& GetObject() {return   iObject;};
sl@0
  1343
sl@0
  1344
private:
sl@0
  1345
	TParsePool*        iNext;
sl@0
  1346
	TParsePool*        iPrev;
sl@0
  1347
sl@0
  1348
	TBool              iFree;
sl@0
  1349
	TParse             iObject;
sl@0
  1350
	static TParsePool* iFreeHead;
sl@0
  1351
	static TParsePool* iClosedHead;
sl@0
  1352
	static TInt        iCountFree;
sl@0
  1353
	static RFastLock   iLock;
sl@0
  1354
	};
sl@0
  1355
sl@0
  1356
	
sl@0
  1357
NONSHARABLE_CLASS(CFsClientMessageRequest) : public CFsMessageRequest
sl@0
  1358
	{
sl@0
  1359
public:
sl@0
  1360
    CFsClientMessageRequest();
sl@0
  1361
	virtual TParse& Src();
sl@0
  1362
	virtual TParse& Dest();
sl@0
  1363
	virtual void Free();
sl@0
  1364
	TInt AllocParseObjects(const TOperation& aOperation);
sl@0
  1365
public:
sl@0
  1366
	CFsClientMessageRequest* iNext;
sl@0
  1367
protected:
sl@0
  1368
	TParsePool* iPoolSrc;
sl@0
  1369
	TParsePool* iPoolDest;
sl@0
  1370
	};
sl@0
  1371
sl@0
  1372
NONSHARABLE_CLASS(CFsDisconnectRequest) : public CFsMessageRequest
sl@0
  1373
	{
sl@0
  1374
public:
sl@0
  1375
	virtual void Process();
sl@0
  1376
	virtual void Dispatch();
sl@0
  1377
	virtual void Complete(TInt aError);
sl@0
  1378
	};
sl@0
  1379
sl@0
  1380
NONSHARABLE_CLASS(CFsInternalRequest) : public CFsRequest
sl@0
  1381
	{
sl@0
  1382
public:
sl@0
  1383
	CFsInternalRequest();
sl@0
  1384
	void Set(const TOperation& aOperation,CSessionFs* aSession);
sl@0
  1385
	//
sl@0
  1386
	inline void SetThreadHandle(TInt aThreadHandle);
sl@0
  1387
	inline TInt ThreadHandle();
sl@0
  1388
	inline TRequestStatus& Status();
sl@0
  1389
	inline TBool IsAllocated();
sl@0
  1390
	inline void SetAllocated();
sl@0
  1391
	//
sl@0
  1392
	virtual void Process();
sl@0
  1393
	virtual void Complete(TInt aError);
sl@0
  1394
	virtual void Dispatch();
sl@0
  1395
	virtual void Free();
sl@0
  1396
private:
sl@0
  1397
	TUint iThreadHandle;
sl@0
  1398
	TRequestStatus iStatus;
sl@0
  1399
	TBool iIsAllocated;
sl@0
  1400
	};
sl@0
  1401
const TInt KMaxRequestAllocated		= 45;
sl@0
  1402
const TInt KMaxOperationAllocated	= KMaxRequestAllocated * 2;
sl@0
  1403
const TInt KAllocReqBlock=15;
sl@0
  1404
sl@0
  1405
class TParseCon
sl@0
  1406
	{
sl@0
  1407
public:
sl@0
  1408
	TParse iParse;
sl@0
  1409
	TParseCon* iNext;
sl@0
  1410
	};
sl@0
  1411
sl@0
  1412
sl@0
  1413
class RequestAllocator
sl@0
  1414
	{
sl@0
  1415
public:
sl@0
  1416
	static TInt GetMessageRequest(const TOperation& aOperation,const RMessage2& aMessage,CFsClientMessageRequest* &aRequest);
sl@0
  1417
	static void FreeRequest(CFsClientMessageRequest* aRequest); // Use the one from cache
sl@0
  1418
	static void OpenSubFailed(CSessionFs* aSession); 
sl@0
  1419
	static TInt AllocRequest(TInt aNum);
sl@0
  1420
sl@0
  1421
	static TInt AllocOperation();
sl@0
  1422
	static TInt GetOperation(TMsgOperation* &aOperation);
sl@0
  1423
	static void FreeOperation(TMsgOperation* aOperation);
sl@0
  1424
sl@0
  1425
sl@0
  1426
	static void Initialise();
sl@0
  1427
#if defined(_USE_CONTROLIO) || defined(_DEBUG) || defined(_DEBUG_RELEASE)
sl@0
  1428
	inline static TInt TotalCount();
sl@0
  1429
	static TInt CloseCount();
sl@0
  1430
	static TInt FreeCount();
sl@0
  1431
	inline static TInt AllocatedCount();
sl@0
  1432
private:
sl@0
  1433
	static TInt iAllocated;
sl@0
  1434
#endif
sl@0
  1435
public:
sl@0
  1436
	static RFastLock iCacheLock;
sl@0
  1437
private:
sl@0
  1438
	static TInt iAllocNum;
sl@0
  1439
	static CFsClientMessageRequest* iFreeHead;				
sl@0
  1440
	static CFsClientMessageRequest* iCloseHead;
sl@0
  1441
sl@0
  1442
	static TInt iAllocNumOperation;
sl@0
  1443
	static TMsgOperation* iFreeHeadSupOp;
sl@0
  1444
	};
sl@0
  1445
sl@0
  1446
sl@0
  1447
NONSHARABLE_CLASS(CNotifyInfo) : public CBase
sl@0
  1448
	{
sl@0
  1449
public:
sl@0
  1450
	
sl@0
  1451
    enum TInfoType {EDiskSpace,EStdChange,EExtChange,EDebugChange,EDismount};
sl@0
  1452
sl@0
  1453
public:
sl@0
  1454
	~CNotifyInfo();
sl@0
  1455
	void Initialise(TInfoType aType,TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession);
sl@0
  1456
	void Complete(TInt aError);
sl@0
  1457
	//
sl@0
  1458
	inline CSessionFs* Session();
sl@0
  1459
	inline TRequestStatus* Status();
sl@0
  1460
	inline TInfoType Type() const {return(iType);}
sl@0
  1461
public:
sl@0
  1462
	TDblQueLink iLink;
sl@0
  1463
protected:
sl@0
  1464
	TInfoType iType;
sl@0
  1465
	TRequestStatus* iStatus;
sl@0
  1466
	RMessagePtr2 iMessage;
sl@0
  1467
	CSessionFs* iSession;
sl@0
  1468
	};
sl@0
  1469
sl@0
  1470
sl@0
  1471
NONSHARABLE_CLASS(CStdChangeInfo) : public CNotifyInfo
sl@0
  1472
	{
sl@0
  1473
public:
sl@0
  1474
	void Initialise(TNotifyType aChangeType,TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession);
sl@0
  1475
	TUint RequestNotifyType(CFsRequest* aRequest);
sl@0
  1476
	TBool IsMatching(CFsRequest* aRequest);
sl@0
  1477
protected:
sl@0
  1478
	TNotifyType iChangeType;
sl@0
  1479
	};
sl@0
  1480
sl@0
  1481
NONSHARABLE_CLASS(CExtChangeInfo) : public CStdChangeInfo
sl@0
  1482
	{
sl@0
  1483
public:
sl@0
  1484
	void Initialise(TNotifyType aChangeType,TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession,const TDesC& aName);
sl@0
  1485
	TBool IsMatching(CFsRequest* aRequest);
sl@0
  1486
private:
sl@0
  1487
	TFileName iName;
sl@0
  1488
	};
sl@0
  1489
sl@0
  1490
NONSHARABLE_CLASS(CDiskSpaceInfo) : public CNotifyInfo
sl@0
  1491
	{
sl@0
  1492
public:
sl@0
  1493
	void Initialise(TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession,TInt64 aThreshold);
sl@0
  1494
	TBool IsMatching(TInt64& aBefore,TInt64& aAfter);
sl@0
  1495
private:
sl@0
  1496
	TInt64 iThreshold;
sl@0
  1497
	};
sl@0
  1498
sl@0
  1499
NONSHARABLE_CLASS(CDebugChangeInfo) : public CNotifyInfo
sl@0
  1500
	{
sl@0
  1501
public:
sl@0
  1502
	void Initialise(TUint aDebugType,TRequestStatus* iStatus,const RMessagePtr2& aMessage,CSessionFs* aSession);
sl@0
  1503
	TBool IsMatching(TUint aChange);
sl@0
  1504
private:
sl@0
  1505
	TUint iDebugType;
sl@0
  1506
	};
sl@0
  1507
sl@0
  1508
NONSHARABLE_CLASS(CDismountNotifyInfo) : public CNotifyInfo
sl@0
  1509
	{
sl@0
  1510
public:
sl@0
  1511
	~CDismountNotifyInfo();
sl@0
  1512
	void Initialise(TNotifyDismountMode aMode, TInt aDriveNumber,TRequestStatus* iStatus,const RMessagePtr2& aMessage,CSessionFs* aSession);
sl@0
  1513
	TBool IsMatching(TNotifyDismountMode aMode, TInt aDriveNumber, CSessionFs* aSession);
sl@0
  1514
private:
sl@0
  1515
	TNotifyDismountMode iMode;
sl@0
  1516
	TInt iDriveNumber;
sl@0
  1517
	};
sl@0
  1518
sl@0
  1519
const TInt KMaxNotifyQues=KMaxDrives+1;
sl@0
  1520
const TInt KMaxDiskQues=KMaxDrives;	
sl@0
  1521
sl@0
  1522
class TBaseQue
sl@0
  1523
	{
sl@0
  1524
protected:
sl@0
  1525
	TBaseQue();
sl@0
  1526
	~TBaseQue();
sl@0
  1527
	void DoAddNotify(CNotifyInfo* aInfo);
sl@0
  1528
	TBool DoCancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus=NULL);
sl@0
  1529
	void DoCancelAll(TInt aCompletionCode);
sl@0
  1530
	TBool IsEmpty();
sl@0
  1531
protected:
sl@0
  1532
	TDblQue<CNotifyInfo> iHeader;
sl@0
  1533
	RFastLock iQLock;
sl@0
  1534
	};
sl@0
  1535
sl@0
  1536
class TChangeQue :public TBaseQue
sl@0
  1537
	{
sl@0
  1538
public:
sl@0
  1539
	TInt AddNotify(CNotifyInfo* aInfo);
sl@0
  1540
	TBool CancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus=NULL);
sl@0
  1541
	void CancelAll(TInt aCompletionCode);
sl@0
  1542
	void CheckChange(CFsRequest* aRequest);
sl@0
  1543
	TBool IsEmpty();
sl@0
  1544
	};
sl@0
  1545
sl@0
  1546
class TDiskSpaceQue : public TBaseQue
sl@0
  1547
	{
sl@0
  1548
public:
sl@0
  1549
	inline void SetDriveNumber(TInt aDriveNumber) {iDriveNumber=aDriveNumber;}
sl@0
  1550
	TInt AddNotify(CNotifyInfo* aInfo);
sl@0
  1551
	TInt CancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus=NULL);
sl@0
  1552
	void CancelAll(TInt aCompletionCode);
sl@0
  1553
	void CheckDiskSpace();
sl@0
  1554
	void CheckDiskSpace(TInt64& aFreeDiskSpace);
sl@0
  1555
	TBool IsEmpty();
sl@0
  1556
private:
sl@0
  1557
	TInt GetFreeDiskSpace(TInt64& aFreeDiskSpace);
sl@0
  1558
private:
sl@0
  1559
	TInt64 iFreeDiskSpace;
sl@0
  1560
	TInt iDriveNumber;
sl@0
  1561
	TInt64 iReservedDiskSpace;
sl@0
  1562
	};
sl@0
  1563
sl@0
  1564
class TDebugQue : public TBaseQue
sl@0
  1565
	{
sl@0
  1566
public:
sl@0
  1567
	TInt AddNotify(CNotifyInfo* aInfo);
sl@0
  1568
	TInt CancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus=NULL);
sl@0
  1569
	void CancelAll(TInt aCompletionCode);
sl@0
  1570
	void CheckDebug(TUint aDebugChange);
sl@0
  1571
	};
sl@0
  1572
sl@0
  1573
class TDismountNotifyQue : public TBaseQue
sl@0
  1574
	{
sl@0
  1575
public:
sl@0
  1576
	TInt AddNotify(CNotifyInfo* aInfo);
sl@0
  1577
	TInt CancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus=NULL);
sl@0
  1578
	void CancelAll(TInt aCompletionCode);
sl@0
  1579
	void CheckDismount(TNotifyDismountMode aMode, TInt aDrive, TBool aRemove, TInt aError);
sl@0
  1580
	TBool HandlePendingDismount(CSessionFs* aSession, TInt aDrive);
sl@0
  1581
	};
sl@0
  1582
sl@0
  1583
class FsNotify
sl@0
  1584
	{
sl@0
  1585
public:
sl@0
  1586
	static void Initialise();
sl@0
  1587
	static TInt AddChange(CNotifyInfo* aInfo,TInt aDrive);
sl@0
  1588
	static TInt AddDiskSpace(CNotifyInfo* aDiskInfo,TInt aDrive);
sl@0
  1589
	static TInt AddDebug(CNotifyInfo* aDebugInfo);
sl@0
  1590
	static TInt AddDismountNotify(CNotifyInfo* aDismountNotifyInfo);
sl@0
  1591
	static void DiskChange(TInt aDrive);
sl@0
  1592
	static void HandleChange(CFsRequest* aRequest,TInt aDrive);
sl@0
  1593
	static void HandleDiskSpace(CFsRequest* aRequest,TInt aDrive);
sl@0
  1594
	static void HandleDiskSpace(TInt aDrive, TInt64& aFreeSpace);
sl@0
  1595
	static void HandleDebug(TUint aFunction);
sl@0
  1596
	static void HandleDismount(TNotifyDismountMode aMode, TInt aDrive, TBool aRemove, TInt err);
sl@0
  1597
	static void CancelChangeSession(CSessionFs* aSession,TRequestStatus* aStatus=NULL);
sl@0
  1598
	static void CancelDiskSpaceSession(CSessionFs* aSession,TRequestStatus* aStatus=NULL);
sl@0
  1599
	static void CancelDebugSession(CSessionFs* aSession, TRequestStatus* aStatus=NULL);
sl@0
  1600
	static void CancelDismountNotifySession(CSessionFs* aSession, TRequestStatus* aStatus=NULL);
sl@0
  1601
	static void CancelSession(CSessionFs* aSession);
sl@0
  1602
	static TBool HandlePendingDismount(CSessionFs* aSession, TInt aDriveNumber);
sl@0
  1603
	static TBool IsChangeQueEmpty(TInt aDrive);
sl@0
  1604
	static TBool IsDiskSpaceQueEmpty(TInt aDrive);
sl@0
  1605
private:
sl@0
  1606
	static TInt ChangeIndex(TInt aDrive);
sl@0
  1607
private:
sl@0
  1608
	static TChangeQue iChangeQues[KMaxNotifyQues];
sl@0
  1609
	static TDiskSpaceQue iDiskSpaceQues[KMaxDiskQues];
sl@0
  1610
	static TDebugQue iDebugQue;
sl@0
  1611
	static TDismountNotifyQue iDismountNotifyQue;
sl@0
  1612
	};
sl@0
  1613
sl@0
  1614
class CObjPromotion : public CFsObject
sl@0
  1615
	{
sl@0
  1616
public:
sl@0
  1617
	TInt UniqueID() const {return(CFsObject::UniqueID());}
sl@0
  1618
	};	
sl@0
  1619
sl@0
  1620
NONSHARABLE_CLASS(CKernEventNotifier) : public CActive
sl@0
  1621
     {
sl@0
  1622
public:
sl@0
  1623
     static CKernEventNotifier* New(TInt aPriority=EPriorityStandard);
sl@0
  1624
     ~CKernEventNotifier();
sl@0
  1625
     void Start();
sl@0
  1626
     inline TInt Change() const {return iChange;}
sl@0
  1627
private:
sl@0
  1628
     CKernEventNotifier(TInt aPriority) : CActive(aPriority) {}
sl@0
  1629
     void RunL();
sl@0
  1630
     void DoCancel();
sl@0
  1631
private:
sl@0
  1632
     static TInt LocaleChangeCallback(TAny* aPtr=NULL);
sl@0
  1633
     TInt FreeMemoryChangeCallback();
sl@0
  1634
private:
sl@0
  1635
     TInt iChange;
sl@0
  1636
     RChangeNotifier iChangeNotifier;
sl@0
  1637
     };
sl@0
  1638
sl@0
  1639
#if defined(_LOCKABLE_MEDIA)
sl@0
  1640
sl@0
  1641
class TDelayedWriterInit
sl@0
  1642
	{
sl@0
  1643
public:
sl@0
  1644
	const TDesC *iFileName;
sl@0
  1645
	const TDesC8 *iData;
sl@0
  1646
	const TDesC *iSemName;
sl@0
  1647
	};
sl@0
  1648
sl@0
  1649
sl@0
  1650
class TDelayedWriter
sl@0
  1651
	{
sl@0
  1652
public:
sl@0
  1653
	TDelayedWriter();
sl@0
  1654
	~TDelayedWriter();
sl@0
  1655
sl@0
  1656
	static TDelayedWriter *NewL(const TDelayedWriterInit *dwi);
sl@0
  1657
	void ConstructL(const TDelayedWriterInit *dwi);
sl@0
  1658
sl@0
  1659
	HBufC *iFileName;
sl@0
  1660
	HBufC8 *iData;
sl@0
  1661
	};
sl@0
  1662
sl@0
  1663
#endif
sl@0
  1664
sl@0
  1665
extern CFsObjectConIx* TheContainer;
sl@0
  1666
extern CFsObjectCon* FileSystems;
sl@0
  1667
extern CFsObjectCon* Files;
sl@0
  1668
extern CFsObjectCon* FileShares;
sl@0
  1669
extern CFsObjectCon* Dirs;
sl@0
  1670
extern CFsObjectCon* Formats;
sl@0
  1671
extern CFsObjectCon* RawDisks;
sl@0
  1672
extern CFsObjectCon* Extensions;
sl@0
  1673
extern CFsObjectCon* ProxyDrives;
sl@0
  1674
sl@0
  1675
extern CKernEventNotifier* TheKernEventNotifier;
sl@0
  1676
sl@0
  1677
extern RThread TheServerThread;
sl@0
  1678
extern RAllocator* ServerThreadAllocator;
sl@0
  1679
sl@0
  1680
extern CServerFs* TheFileServer;
sl@0
  1681
sl@0
  1682
extern HBufC* TheDriveNames[];
sl@0
  1683
extern TDrive TheDrives[KMaxDrives];
sl@0
  1684
extern TFileName TheDefaultPath;
sl@0
  1685
extern RFTrace TheFtrace;
sl@0
  1686
sl@0
  1687
extern SCapabilitySet AllCapabilities;
sl@0
  1688
extern SCapabilitySet DisabledCapabilities;
sl@0
  1689
sl@0
  1690
const TInt KDispatchObjectClose=KMaxTInt-1;
sl@0
  1691
const TInt KSessionDisconnect=KMaxTInt-2;
sl@0
  1692
const TInt KCancelSession=KMaxTInt-3;
sl@0
  1693
const TInt KCancelPlugin=KMaxTInt-4;
sl@0
  1694
const TInt KFileShareClose=KMaxTInt-5;
sl@0
  1695
const TInt KFlushDirtyData=KMaxTInt-6;
sl@0
  1696
sl@0
  1697
const TOperation DispatchObjectCloseOp=	{KDispatchObjectClose,	EInternalRequest,	&TFsCloseObject::Initialise,		NULL,	&TFsCloseObject::DoRequestL			};
sl@0
  1698
const TOperation SessionDisconnectOp=	{KSessionDisconnect,	EInternalRequest,	&TFsSessionDisconnect::Initialise,	NULL,	&TFsSessionDisconnect::DoRequestL	};
sl@0
  1699
const TOperation CancelSessionOp=		{KCancelSession,		EInternalRequest,	&TFsCancelSession::Initialise,		NULL,	&TFsCancelSession::DoRequestL		};
sl@0
  1700
const TOperation CancelPluginOp=		{KCancelPlugin,			EInternalRequest,	&TFsCancelPlugin::Initialise,		NULL,	&TFsCancelPlugin::DoRequestL		};
sl@0
  1701
const TOperation FileShareCloseOp=		{KFileShareClose,		EInternalRequest,	&TFsCloseFileShare::Initialise,		NULL,	&TFsCloseFileShare::DoRequestL		};
sl@0
  1702
const TOperation FlushDirtyDataOp=		{KFlushDirtyData,		EInternalRequest,	&TFsFlushDirtyData::Initialise,		NULL,	&TFsFlushDirtyData::DoRequestL		};
sl@0
  1703
sl@0
  1704
extern TBool OpenOnDriveZOnly;
sl@0
  1705
extern TBool LocalFileSystemInitialized;
sl@0
  1706
extern TBool StartupInitCompleted;
sl@0
  1707
extern TBool RefreshZDriveCache;
sl@0
  1708
extern TBool CompFsMounted;
sl@0
  1709
extern TBool CompFsSync;
sl@0
  1710
sl@0
  1711
 TInt InitializeLocalFileSystem(const TDesC& aName);
sl@0
  1712
 void InstallRomFileSystemL();
sl@0
  1713
 void InstallFatFileSystemL();
sl@0
  1714
 TInt InstallFileSystem(CFileSystem* aSys,RLibrary aLib);
sl@0
  1715
sl@0
  1716
 TInt LoadFileSystem(const TDesC& aName);
sl@0
  1717
sl@0
  1718
 CFsObject* SessionObjectFromHandle(TInt aHandle,TInt aUniqueID, CSessionFs* aSession);
sl@0
  1719
 CFileShare* GetShareFromHandle(CSessionFs* aSession, TInt aHandle);
sl@0
  1720
sl@0
  1721
 TInt  ValidateDrive(TInt aDriveNumber,CFsRequest* aRequest);
sl@0
  1722
 TInt  ValidateDriveDoSubst(TInt aDriveNumber,CFsRequest* aRequest);
sl@0
  1723
 void  ValidateAtts(TUint anEntryAtt,TUint& aSetAttMask,TUint& aClearAttMask);
sl@0
  1724
 TInt  ParseSubstPtr0(CFsRequest* aRequest,TParse& aParse, TBool aUseSessionPath = ETrue);
sl@0
  1725
 TInt  ParseNoWildSubstPtr0(CFsRequest* aRequest,TParse& aParse, TBool aUseSessionPath = ETrue);
sl@0
  1726
 TInt  ParseNoWildSubstPtr1(CFsRequest* aRequest,TParse& aParse);
sl@0
  1727
 TInt  ParseNoWildSubstCheckPtr0(CFsRequest* aRequest,TParse& aParse, TBool aUseSessionPath = ETrue);
sl@0
  1728
 TInt  ParseNoWildSubstCheckPtr1(CFsRequest* aRequest,TParse& aParse);
sl@0
  1729
 TInt  ParseNoWildSubstFileCheckPtr1(CFsRequest* aRequest,TParse& aParse);
sl@0
  1730
 TInt  ParseNoWildSubstCheckPathPtr0(CFsRequest* aRequest,TParse& aParse);
sl@0
  1731
 TInt  ParseNoWildSubstCheckPathPtr1(CFsRequest* aRequest,TParse& aParse);
sl@0
  1732
 TInt  ParsePathPtr0(CFsRequest* aRequest,TParse& aParse);
sl@0
  1733
 TInt  ParseNotificationPath(CFsRequest* aRequest, TParse& aParse, TDes& aNotifyPath);
sl@0
  1734
 TBool IsIllegalFullName(const TDesC& aName);
sl@0
  1735
 TBool IsIllegalFullName(const TParse& aParse);
sl@0
  1736
 void  AddResource(CMountCB& aMount);
sl@0
  1737
 void  RemoveResource(CMountCB& aMount);
sl@0
  1738
 void  AddDiskAccess(CMountCB& aMount);
sl@0
  1739
 void  RemoveDiskAccess(CMountCB& aMount);
sl@0
  1740
 void  NextInPath(const TDesC& aPath,TPtrC& anEntry,TInt& aPos);
sl@0
  1741
 TBool PowerOk();
sl@0
  1742
 void  Get16BitDllName(TDes& aFileName, const TDesC8& aDllName);
sl@0
  1743
 void  Get8BitDllName(TDes8& aDllName, const TDesC& aFileName);
sl@0
  1744
 TInt  MatchUidType(const TUidType &aMatch, const TUidType &aType);
sl@0
  1745
 TBool IsWriteFunction(TInt aFunction);
sl@0
  1746
 TInt  InitLoader();
sl@0
  1747
 TInt  CheckDiskSpace(TInt64 aThreshold, CFsRequest* aRequest);
sl@0
  1748
 void  CheckForLeaveAfterOpenL(TInt leaveError, CFsRequest* aRequest, TInt aHandle);
sl@0
  1749
 TInt  ParseSubst(const TInt aP, CFsRequest* aRequest,TParse& aParse, TBool aUseSessionPath = ETrue);
sl@0
  1750
sl@0
  1751
//#ifdef __DATA_CAGING__
sl@0
  1752
sl@0
  1753
 TBool CompareResource(const TDesC & aThePath);
sl@0
  1754
sl@0
  1755
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
sl@0
  1756
 TInt PathCheck(CFsRequest* aRequest, const TDesC& aThePath, const TSecurityPolicy* aSysCap, const TSecurityPolicy* aPriCap, const char* aDiag);
sl@0
  1757
 TInt PathCheck(CFsRequest* aRequest, const TDesC& aThePath, const TSecurityPolicy* aSysCap, const TSecurityPolicy* aPriCap, const TSecurityPolicy* aROCap, const char* aDiag);
sl@0
  1758
 TInt PathCheck(CFsRequest* aRequest, const TDesC& aThePath,const TSecurityPolicy* aCap, const char* aDiag, TBool aExactMatchAllowed = EFalse);
sl@0
  1759
#else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
sl@0
  1760
 TInt PathCheck(CFsRequest* aRequest, const TDesC& aThePath, const TSecurityPolicy* aSysCap, const TSecurityPolicy* aPriCap, OnlyCreateWithNull aDiag);
sl@0
  1761
 TInt PathCheck(CFsRequest* aRequest, const TDesC& aThePath, const TSecurityPolicy* aSysCap, const TSecurityPolicy* aPriCap, const TSecurityPolicy* aROCap, OnlyCreateWithNull aDiag); 
sl@0
  1762
 TInt PathCheck(CFsRequest* aRequest, const TDesC& aThePath,const TSecurityPolicy* aCap, OnlyCreateWithNull aDiag, TBool aExactMatchAllowed = EFalse);
sl@0
  1763
#endif //!__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
sl@0
  1764
sl@0
  1765
 TBool ComparePrivate(const TDesC & aThePath);
sl@0
  1766
 TBool CompareSystem(const TDesC & aThePath);
sl@0
  1767
 TBool SIDCheck(CFsRequest* aRequest, const TDesC& aThePath);
sl@0
  1768
 TBool ComparePaths(const TDesC& aPath1,const TDesC& aPath2);
sl@0
  1769
 TUint32 CalcNameHash(const TDesC& aName);
sl@0
  1770
sl@0
  1771
const TInt KResourceLength			=	9;
sl@0
  1772
const TInt KSystemLength			=	4;
sl@0
  1773
const TInt KPrivateLength			=	8;
sl@0
  1774
const TInt KPrivateLengthCheck		=	17;
sl@0
  1775
const TInt KSIDLength				=	8;
sl@0
  1776
const TInt KSIDPathOffset			=	9;
sl@0
  1777
sl@0
  1778
_LIT(KSlash, "\\");
sl@0
  1779
_LIT(KPrivate,"\\Private");
sl@0
  1780
_LIT(KPrivateSlash,"\\Private\\");
sl@0
  1781
_LIT(KSysHash,"?:\\Sys\\Hash\\");
sl@0
  1782
const TInt KBSlash='\\';
sl@0
  1783
const TInt KHashFileReadSize = 1024*8;
sl@0
  1784
sl@0
  1785
sl@0
  1786
const TInt KMsgPtr0	= 0;
sl@0
  1787
const TInt KMsgPtr1	= 1;
sl@0
  1788
const TInt KMsgPtr2	= 2;
sl@0
  1789
const TInt KMsgPtr3	= 3;
sl@0
  1790
sl@0
  1791
const TInt KIpcFunctionMask = 0x0000ffff;
sl@0
  1792
const TInt KIpcFlagMask     = 0xffff0000;
sl@0
  1793
const TInt KIpcFlagOffset   = 16;
sl@0
  1794
sl@0
  1795
#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
sl@0
  1796
 void  PrintStartUpReason(TMachineStartupType aReason);
sl@0
  1797
 TPtrC GetFunctionName(TInt aFunction);
sl@0
  1798
 void  SimulateAllocFailure(TInt aFunctionReturnValue,TInt aFunction);
sl@0
  1799
sl@0
  1800
extern TInt ErrorCondition;
sl@0
  1801
extern TInt ErrorCount;
sl@0
  1802
extern TUint32 DebugReg;
sl@0
  1803
extern TInt UserHeapAllocFailCount;
sl@0
  1804
extern TInt KernHeapAllocFailCount;
sl@0
  1805
extern TInt MessageCount;
sl@0
  1806
sl@0
  1807
void PrintHeapSize(const TDesC& aMessage);
sl@0
  1808
sl@0
  1809
extern TCorruptNameRec* gCorruptFileNameList;
sl@0
  1810
extern TCorruptLogRec* gCorruptLogRecordList;
sl@0
  1811
extern TInt gNumberOfCorruptHits;
sl@0
  1812
extern HBufC* gCorruptFileNamesListFile;
sl@0
  1813
#endif
sl@0
  1814
sl@0
  1815
typedef TPckgBuf<TMediaPswdReplyNotifyInfoV1> TMediaPswdReplyNotifyInfoV1Buf;
sl@0
  1816
sl@0
  1817
#if defined(__WINS__)
sl@0
  1818
 TInt MapWindowsFileName(TDes& aBuffer,const TDesC& aFileName);
sl@0
  1819
#endif
sl@0
  1820
sl@0
  1821
enum TDllFindMethod {EFindInPath, EFindInSystemLibs, EFindInSystemBin, EFindExhausted};
sl@0
  1822
sl@0
  1823
//---------------------------------------------------------------------------------------------------------------------
sl@0
  1824
sl@0
  1825
NONSHARABLE_CLASS(CFileBody) : public CBase, public CFileCB::MExtendedFileInterface
sl@0
  1826
	{
sl@0
  1827
protected:
sl@0
  1828
	~CFileBody();
sl@0
  1829
	CFileBody(CFileCB* aFileCB, CFileCB::MExtendedFileInterface* aExtendedFileInterface);
sl@0
  1830
	void InitL();
sl@0
  1831
sl@0
  1832
	TBool ExtendedFileInterfaceSupported();
sl@0
  1833
sl@0
  1834
	// from MExtendedFileInterface	
sl@0
  1835
	virtual void ReadL(TInt64 aPos,TInt& aLength,TDes8* aDes,const RMessagePtr2& aMessage, TInt aOffset = 0);
sl@0
  1836
	virtual void WriteL(TInt64 aPos,TInt& aLength,const TDesC8* aDes,const RMessagePtr2& aMessage, TInt aOffset = 0);
sl@0
  1837
	virtual void SetSizeL(TInt64 aSize);
sl@0
  1838
sl@0
  1839
sl@0
  1840
private:
sl@0
  1841
	CFileCB* iFileCB;
sl@0
  1842
	CFileCB::MExtendedFileInterface* iExtendedFileInterface;
sl@0
  1843
	TInt iFairSchedulingLen;
sl@0
  1844
	TBool iNotifyAsyncReadersPending;
sl@0
  1845
	TBool iDeleteOnClose;
sl@0
  1846
sl@0
  1847
protected:
sl@0
  1848
	TInt iPromotedShares;
sl@0
  1849
	RArray<TAsyncReadRequest>* iAsyncReadRequests;
sl@0
  1850
	CFileCache* iFileCache;	// pointer to owner CFileCache 
sl@0
  1851
	TBool iLocalBufferSupport;
sl@0
  1852
sl@0
  1853
    /** 
sl@0
  1854
    maximum file size supported by the filesystem that instantiates the CFileCB, associated with this object.
sl@0
  1855
    For example, FAT32 supports files not larger than 4GB-1. Other file systems can support larger files. 
sl@0
  1856
    This member allows file server to know maximum allowed position in the file.
sl@0
  1857
    The default value is KMaxTUint64
sl@0
  1858
    */
sl@0
  1859
    TUint64 iMaxSupportedFileSize; 
sl@0
  1860
sl@0
  1861
public:
sl@0
  1862
	// Provides support for large file size ( file size > 4GB - 1)
sl@0
  1863
	// Upper / High 32 bit word of the file size is saved here.
sl@0
  1864
	// This can be non-zero only if the CFileShare::iMode is ORed with EFileBigFile
sl@0
  1865
	// and the file size is > 4GB - 1.
sl@0
  1866
	// This shall be queried by CFileCB::Size64() from file systems or by direct access from file server
sl@0
  1867
	// This shall be updated by CFileCB::SetSize64() from file systems or by direct access from file server. 
sl@0
  1868
	TUint iSizeHigh;
sl@0
  1869
	
sl@0
  1870
protected:
sl@0
  1871
friend class CFileCB;
sl@0
  1872
friend class CFileCache;
sl@0
  1873
	};
sl@0
  1874
sl@0
  1875
//---------------------------------------------------------------------------------------------------------------------
sl@0
  1876
sl@0
  1877
NONSHARABLE_CLASS(CMountBody) : public CBase, public CMountCB::MFileAccessor, public CMountCB::MFileExtendedInterface
sl@0
  1878
	{
sl@0
  1879
protected:
sl@0
  1880
	CMountBody(CMountCB* aMountCB, CMountCB::MFileAccessor* aFileAccessor = NULL, CMountCB::MFileExtendedInterface* aFileInterface = NULL);
sl@0
  1881
	~CMountBody();
sl@0
  1882
sl@0
  1883
	// Clamping support
sl@0
  1884
	TInt ClampFile(const TInt aDriveNo,const TDesC& aName,TAny* aHandle);
sl@0
  1885
	TInt UnclampFile(RFileClamp* aHandle);
sl@0
  1886
	TInt IsFileClamped(const TInt64 aUniqueId);
sl@0
  1887
	TInt NoOfClamps();
sl@0
  1888
sl@0
  1889
	// Internal support clamping
sl@0
  1890
	static TInt CompareClampsByIdAndCount(const RFileClamp& aClampA, const RFileClamp& aClampB);
sl@0
  1891
	static TInt CompareClampsById(const RFileClamp& aClampA, const RFileClamp& aClampB);
sl@0
  1892
	static TInt FindClampByIdAndCount(const RFileClamp& aClampA, const RFileClamp& aClampB);
sl@0
  1893
	static TInt FindClampById(const RFileClamp& aClampA, const RFileClamp& aClampB);
sl@0
  1894
sl@0
  1895
	// from MFileAccessor
sl@0
  1896
	virtual TInt GetFileUniqueId(const TDesC& aName, TInt64& aUniqueId);
sl@0
  1897
	virtual TInt Spare3(TInt aVal, TAny* aPtr1, TAny* aPtr2);
sl@0
  1898
	virtual TInt Spare2(TInt aVal, TAny* aPtr1, TAny* aPtr2);
sl@0
  1899
	virtual TInt Spare1(TInt aVal, TAny* aPtr1, TAny* aPtr2);
sl@0
  1900
	
sl@0
  1901
	// From MFileExtendedInterface
sl@0
  1902
	virtual void ReadSection64L(const TDesC& aName, TInt64 aPos, TAny* aTrg, TInt aLength, const RMessagePtr2& aMessage);
sl@0
  1903
sl@0
  1904
	void SetProxyDriveDismounted();
sl@0
  1905
	TBool ProxyDriveDismounted();
sl@0
  1906
	
sl@0
  1907
sl@0
  1908
    inline CFileSystem* GetFileSystem() const;
sl@0
  1909
    inline void SetFileSystem(CFileSystem* aFsys);
sl@0
  1910
sl@0
  1911
private:
sl@0
  1912
	CMountCB* iMountCB;
sl@0
  1913
	RArray<RFileClamp> iClampIdentifiers;
sl@0
  1914
	TInt32 iClampCount;
sl@0
  1915
	CMountCB::MFileAccessor* iFileAccessor;
sl@0
  1916
	CMountCB::MFileExtendedInterface* iFileExtendedInterface;
sl@0
  1917
	TBool iProxyDriveDismounted;
sl@0
  1918
	CFileSystem* iFSys;  ///< link to the FileSystem object that has produced the mount (iMountCB)
sl@0
  1919
friend class CMountCB;
sl@0
  1920
	};
sl@0
  1921
sl@0
  1922
sl@0
  1923
#include "sf_ops.h"
sl@0
  1924
#include "sf_std.inl"
sl@0
  1925
sl@0
  1926
sl@0
  1927
#endif //SF_STD_H