author | Mike Kinghan <mikek@symbian.org> |
Thu, 25 Nov 2010 14:35:45 +0000 | |
branch | GCC_SURGE |
changeset 305 | 1ba12ef4ef89 |
parent 152 | 657f875b013e |
child 257 | 3e88ff8f41d5 |
child 273 | 6a75fa55495f |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// f32\sfile\sf_main.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include "sf_std.h" |
|
19 |
#include "sf_plugin.h" |
|
20 |
#include "sf_file_cache.h" // for TClosedFileUtils |
|
21 |
#include "sf_memory_man.h" |
|
22 |
||
23 |
#ifdef __WINS__ |
|
24 |
#include <emulator.h> |
|
25 |
#include <e32wins.h> |
|
26 |
#endif |
|
27 |
#include "d32btrace.h" |
|
28 |
||
29 |
#ifdef __EPOC32__ |
|
30 |
_LIT(KStartupExeSysBinName,"Z:\\Sys\\Bin\\ESTART.EXE"); |
|
31 |
#else |
|
32 |
_LIT(KStartupExeName,"E32STRT.EXE"); |
|
33 |
_LIT(KStartupExeSysBinName,"E32STRT.EXE"); |
|
34 |
#endif |
|
35 |
||
36 |
//const TInt KSessionNotifyListGranularity=16; //-- not used anywhere |
|
37 |
||
38 |
// patch ldds should specify this as their third uid |
|
39 |
//const TInt KPatchLddUidValue=0x100000cc; //-- not used anywhere |
|
40 |
||
41 |
_LIT(KFileServerName,"!FileServer"); |
|
42 |
||
43 |
void CServerFs::New() |
|
44 |
// |
|
45 |
// Create a new CServerFs. |
|
46 |
// |
|
47 |
{ |
|
48 |
TheFileServer=new CServerFs(EPriority); |
|
49 |
__ASSERT_ALWAYS(TheFileServer!=NULL,Fault(EMainCreateServer)); |
|
50 |
TInt r = TheFileServer->iSessionQueueLock.CreateLocal(); |
|
51 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EMainCreateServer)); |
|
52 |
r=TheFileServer->Start(KFileServerName); |
|
53 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EMainStartServer)); |
|
54 |
} |
|
55 |
||
56 |
||
57 |
CServerFs::CServerFs(TInt aPriority) |
|
58 |
// |
|
59 |
//Constructor. |
|
60 |
// |
|
61 |
: CServer2(aPriority,EGlobalSharableSessions) |
|
62 |
{ |
|
63 |
} |
|
64 |
||
65 |
CServerFs::~CServerFs() |
|
66 |
// |
|
67 |
//Destructor. |
|
68 |
// |
|
69 |
{ |
|
70 |
iSessionQueueLock.Close(); |
|
71 |
} |
|
72 |
||
73 |
void CServerFs::RunL() |
|
74 |
// |
|
75 |
// calls CServer2::RunL |
|
76 |
// |
|
77 |
{ |
|
78 |
TInt fn = Message().Function(); |
|
79 |
||
80 |
// CServer2::DoConnectL() manipulates iSessionQ & so does CSession2::~CSession2(). |
|
81 |
// Unfortunately the session is deleted from a seperate thread (the disconnect |
|
82 |
// thread) so we need a lock to protect it. |
|
83 |
if (fn == RMessage2::EConnect) |
|
84 |
{ |
|
85 |
SessionQueueLockWait(); // lock |
|
86 |
CServer2::RunL(); |
|
87 |
SessionQueueLockSignal(); // unlock |
|
88 |
} |
|
89 |
else |
|
90 |
{ |
|
91 |
CServer2::RunL(); |
|
92 |
} |
|
93 |
} |
|
94 |
||
95 |
CSessionFs* CServerFs::operator[](TInt anIndex) |
|
96 |
// |
|
97 |
// Indexing operator used by DoFsListOpenFiles |
|
98 |
// |
|
99 |
{ |
|
100 |
__ASSERT_DEBUG(anIndex>=0,Fault(ESvrBadSessionIndex)); |
|
101 |
iSessionIter.SetToFirst(); |
|
102 |
while (anIndex--) |
|
103 |
iSessionIter++; |
|
104 |
CSessionFs* ses=(CSessionFs*)&(*iSessionIter); |
|
105 |
return(ses); |
|
106 |
} |
|
107 |
||
108 |
_LIT(KPrivatePath,"?:\\Private\\"); |
|
109 |
CSession2* CServerFs::NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const |
|
110 |
// |
|
111 |
// Create a new client session for this server. |
|
112 |
// |
|
113 |
{ |
|
114 |
TVersion v(KF32MajorVersionNumber,KF32MinorVersionNumber,KF32BuildVersionNumber); |
|
115 |
TBool r=User::QueryVersionSupported(v,aVersion); |
|
116 |
if (!r) |
|
117 |
User::Leave(KErrNotSupported); |
|
118 |
__CALL(if(UserHeapAllocFailCount>=0){__UHEAP_FAILNEXT(10);}); // Create session must succeed |
|
119 |
CSessionFs* ses=CSessionFs::NewL(); |
|
120 |
CleanupStack::PushL(ses); |
|
121 |
TUid aUid = aMessage.SecureId(); |
|
122 |
TBuf<30> thePath = KPrivatePath(); |
|
123 |
thePath[0] = (TUint8) RFs::GetSystemDriveChar(); |
|
124 |
thePath.AppendNumFixedWidth(aUid.iUid, EHex, 8); |
|
125 |
thePath.Append(KSlash); |
|
126 |
HBufC* pP=thePath.AllocL(); |
|
127 |
ses->SetPath(pP); |
|
128 |
__CALL(if (UserHeapAllocFailCount>=0){__UHEAP_FAILNEXT(UserHeapAllocFailCount);}); |
|
129 |
||
130 |
||
131 |
RThread idClient; |
|
132 |
User::LeaveIfError(aMessage.Client(idClient, EOwnerThread)); |
|
133 |
ses->SetThreadId(idClient.Id()); |
|
134 |
idClient.Close(); |
|
135 |
||
136 |
CleanupStack::Pop(); //ses |
|
137 |
||
138 |
return(ses); |
|
139 |
} |
|
140 |
||
141 |
void CSessionFs::ServiceL(const RMessage2& aMessage) |
|
142 |
// |
|
143 |
// Service this message for the server |
|
144 |
// |
|
145 |
{ |
|
146 |
__CALL( if (SimulateError(&aMessage)) { aMessage.Complete(ErrorCondition); return; } ); |
|
147 |
const TInt ipcFunction = aMessage.Function() & KIpcFunctionMask; |
|
148 |
||
149 |
if((ipcFunction) >= EMaxClientOperations) |
|
150 |
{ |
|
151 |
__THRD_PRINT1(_L("CSessionFs::DoServiceL() - func 0x%x KErrNotSupported"), ipcFunction); |
|
152 |
aMessage.Complete(KErrNotSupported); |
|
153 |
return; |
|
154 |
} |
|
155 |
||
156 |
const TOperation& oP = OperationArray[ipcFunction]; |
|
157 |
CFsClientMessageRequest* pR = NULL; |
|
158 |
TInt r = RequestAllocator::GetMessageRequest(oP, aMessage, pR); |
|
159 |
if(r != KErrNone) |
|
160 |
{ |
|
161 |
if(r == KErrBadHandle) |
|
162 |
{ |
|
163 |
_LIT(KPanic,"Panic"); |
|
164 |
aMessage.Panic(KPanic, r); |
|
165 |
return; |
|
166 |
} |
|
167 |
aMessage.Complete(r); |
|
168 |
return; |
|
169 |
} |
|
170 |
pR->Set(aMessage, oP, this); |
|
171 |
__PRINT4TEMP(_L("***** Received Message sess %08x req %08x func 0x%x - %S"), this, pR, ipcFunction, GetFunctionName(ipcFunction)); |
|
172 |
pR->Dispatch(); |
|
173 |
} |
|
174 |
||
175 |
void CActiveSchedulerFs::New() |
|
176 |
// |
|
177 |
// Create and install the active scheduler. |
|
178 |
// |
|
179 |
{ |
|
180 |
||
181 |
CActiveSchedulerFs* pA=new CActiveSchedulerFs; |
|
182 |
__ASSERT_ALWAYS(pA!=NULL,Fault(EMainCreateScheduler)); |
|
183 |
CActiveScheduler::Install(pA); |
|
184 |
} |
|
185 |
||
186 |
void CActiveSchedulerFs::Error(TInt anError) const |
|
187 |
// |
|
188 |
// Called if any Run() method leaves, which should never happen. |
|
189 |
// |
|
190 |
{ |
|
191 |
||
192 |
__PRINT1(_L("FileSystemActiveScheduler Error %d"),anError); |
|
193 |
User::Panic(_L("FSRV-ERR"),anError); |
|
194 |
} |
|
195 |
||
196 |
||
197 |
void createAllL() |
|
198 |
// |
|
199 |
// Create the initial objects |
|
200 |
// |
|
201 |
{ |
|
202 |
// |
|
203 |
// First we need to create all the containers. |
|
204 |
// |
|
205 |
TheContainer=CFsObjectConIx::NewL(); |
|
206 |
FileSystems=TheContainer->CreateL(); |
|
207 |
Extensions=TheContainer->CreateL(); |
|
208 |
ProxyDrives=TheContainer->CreateL(); |
|
209 |
Files=TheContainer->CreateL(); |
|
210 |
FileShares=TheContainer->CreateL(); |
|
211 |
Dirs=TheContainer->CreateL(); |
|
212 |
Formats=TheContainer->CreateL(); |
|
213 |
RawDisks=TheContainer->CreateL(); |
|
214 |
TClosedFileUtils::InitL(); |
|
215 |
||
216 |
// |
|
217 |
// Initialize the drives |
|
218 |
// |
|
219 |
for (TInt i=0;i<KMaxDrives;i++) |
|
220 |
TheDrives[i].CreateL(i); |
|
221 |
||
222 |
// |
|
223 |
// Next we need to create the ROM file system. |
|
224 |
// |
|
225 |
#if defined(__EPOC32__) |
|
226 |
InstallRomFileSystemL(); |
|
227 |
CFileSystem* romFs=GetFileSystem(_L("Rom")); |
|
228 |
//#ifndef __DATA_CAGING__ |
|
229 |
TheDefaultPath=_L("Z:\\"); // Temporarily set the default path to the ROM |
|
230 |
//#endif |
|
231 |
TheDrives[EDriveZ].SetAtt(KDriveAttRom|KDriveAttInternal); |
|
232 |
TheDrives[EDriveZ].GetFSys()=romFs; |
|
233 |
TInt r=FsThreadManager::InitDrive(EDriveZ,ETrue); |
|
234 |
User::LeaveIfError(r); |
|
235 |
#endif |
|
236 |
} |
|
237 |
||
238 |
||
239 |
TInt InitializeLocalFileSystem(const TDesC& aName) |
|
240 |
// |
|
241 |
// Initialize the local file system |
|
242 |
// |
|
243 |
{ |
|
244 |
||
245 |
__PRINT(_L("InitializeLocalFileSystem")); |
|
246 |
CFileSystem* localFileSystem=GetFileSystem(aName); |
|
247 |
__ASSERT_DEBUG(localFileSystem!=NULL,Fault(EMainGetLocalFileSystem)); |
|
248 |
if(localFileSystem == NULL) |
|
249 |
return KErrNotFound; |
|
250 |
#if defined(__WINS__) |
|
251 |
TheDrives[EDriveZ].GetFSys()=localFileSystem; |
|
252 |
TheDrives[EDriveZ].SetAtt(KDriveAttRom|KDriveAttInternal); |
|
253 |
TInt r=FsThreadManager::InitDrive(EDriveZ,ETrue); |
|
254 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EMainInitialiseRomFs)); |
|
255 |
#endif |
|
256 |
||
257 |
// |
|
258 |
// Initialize the default path |
|
259 |
// |
|
260 |
//#ifndef __DATA_CAGING__ |
|
261 |
#if !defined(__WINS__) |
|
262 |
TInt r; |
|
263 |
#endif |
|
264 |
r=localFileSystem->DefaultPath(TheDefaultPath); |
|
265 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EMainGetLocalDefaultPath)); |
|
266 |
//#endif |
|
267 |
||
268 |
LocalFileSystemInitialized=ETrue; |
|
269 |
||
270 |
return KErrNone; |
|
271 |
||
272 |
} |
|
273 |
||
274 |
_LIT(KMediaLddName, "ELOCD"); |
|
275 |
||
276 |
TInt StartupThread(TAny*) |
|
277 |
// |
|
278 |
// The startup thread. |
|
279 |
// |
|
280 |
{ |
|
281 |
||
282 |
__PRINT(_L("StartupThread")); |
|
283 |
User::SetCritical(User::ESystemCritical); |
|
284 |
||
285 |
TInt r; |
|
286 |
||
287 |
// |
|
288 |
// Load the file system's device driver |
|
289 |
// |
|
290 |
r=User::LoadLogicalDevice(KMediaLddName); |
|
291 |
__PRINT1(_L("User::LoadLogicalDevice(KMediaLddName) returns %d"),r); |
|
292 |
||
293 |
__ASSERT_ALWAYS(r==KErrNone || r==KErrAlreadyExists || r==KErrNotFound,Fault(EMainCreateResources6)); |
|
294 |
#ifdef __WINS__ |
|
295 |
// Load media drivers using Win32 functions. It is not possible to directly |
|
296 |
// read the \epoc32\release\wins\udeb directory, and ELOCAL must be mounted |
|
297 |
// to access Win32 anyway. |
|
298 |
||
299 |
_LIT(KMDW1, "MED*.PDD"); |
|
300 |
TBuf<9> KMDW(KMDW1); // reserve space for \0 |
|
301 |
||
302 |
TFileName *pfn = new TFileName; |
|
303 |
__ASSERT_ALWAYS(pfn != NULL, Fault(EMainScanMediaDriversMem1)); |
|
304 |
TFileName &fn = *pfn; |
|
305 |
||
306 |
MapEmulatedFileName(fn, KMDW); |
|
307 |
__ASSERT_ALWAYS(fn.Length() < KMaxFileName, Fault(EMainScanMediaDriversLocation)); |
|
308 |
||
309 |
WIN32_FIND_DATA ffd; |
|
310 |
HANDLE h = Emulator::FindFirstFile(fn.PtrZ(), &ffd); |
|
311 |
BOOL fF = (h != INVALID_HANDLE_VALUE); |
|
312 |
while (fF) |
|
313 |
{ |
|
314 |
TPtrC mdNm(ffd.cFileName); // null terminated wchar_t array |
|
315 |
||
316 |
// NB: parse Win32 file path with EPOC32 functionality. |
|
317 |
TParse *pprs = new TParse; |
|
318 |
__ASSERT_ALWAYS(pprs != NULL, Fault(EMainScanMediaDriversMem2)); |
|
319 |
TParse &prs = *pprs; |
|
320 |
prs.Set(mdNm, NULL, NULL); |
|
321 |
r = User::LoadPhysicalDevice(prs.NameAndExt()); |
|
322 |
__ASSERT_ALWAYS(r==KErrNone || r==KErrAlreadyExists || r==KErrNotFound,Fault(EMainLoadMediaDriver)); |
|
323 |
fF = Emulator::FindNextFile(h, &ffd); |
|
324 |
delete pprs; |
|
325 |
} |
|
326 |
FindClose(h); // Win32 direct |
|
327 |
||
328 |
delete pfn; |
|
329 |
#else |
|
330 |
// Load media drivers for EPOC32 using built-in rom file system. |
|
331 |
{ |
|
332 |
RFs fsM; |
|
333 |
r = fsM.Connect(); |
|
334 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EMainScanMediaDriverConnect)); |
|
335 |
||
336 |
//#ifdef __EPOC32__ |
|
337 |
_LIT(KMDSysBinHome, "Z:\\Sys\\Bin\\med*.pdd"); |
|
338 |
//#else |
|
339 |
// _LIT(KMDHome, "med*.pdd"); |
|
340 |
//#endif |
|
341 |
RDir d; |
|
342 |
r = d.Open(fsM, KMDSysBinHome, KEntryAttMaskSupported); |
|
343 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EMainScanMediaDriverDirOpen)); |
|
344 |
||
345 |
TBool done = EFalse; |
|
346 |
do |
|
347 |
{ |
|
348 |
TEntryArray ea; |
|
349 |
r = d.Read(ea); |
|
350 |
__ASSERT_ALWAYS(r == KErrNone || r == KErrEof, Fault(EMainScanMediaDriverDirRead)); |
|
351 |
done = (r == KErrEof); |
|
352 |
||
353 |
for (TInt i = 0; i < ea.Count(); ++i) |
|
354 |
{ |
|
355 |
const TEntry &e = ea[i]; |
|
356 |
if (!e.IsDir()) |
|
357 |
{ |
|
358 |
TParse *pprs = new TParse; |
|
359 |
__ASSERT_ALWAYS(pprs != NULL, Fault(EMainScanMediaDriversMem1)); |
|
360 |
TParse &prs = *pprs; |
|
361 |
prs.Set(e.iName, NULL, NULL); |
|
362 |
TPtrC mdName(prs.NameAndExt()); |
|
363 |
r = User::LoadPhysicalDevice(mdName); |
|
364 |
__PRINT1(_L("User::LoadPhysicalDevice(mdName) returns %d"),r); |
|
365 |
__ASSERT_ALWAYS(r==KErrNone || r==KErrAlreadyExists || r==KErrNotFound,Fault(EMainLoadMediaDriver)); |
|
366 |
delete pprs; |
|
367 |
} |
|
368 |
} |
|
369 |
} while (! done); |
|
370 |
d.Close(); |
|
371 |
||
372 |
fsM.Close(); |
|
373 |
} |
|
374 |
#endif // else __WINS__ |
|
375 |
||
376 |
#if defined(__WINS__) |
|
377 |
//#ifndef __DATA_CAGING__ |
|
378 |
TheDefaultPath=_L("?:\\"); |
|
379 |
TheDefaultPath[0] = (TUint8) RFs::GetSystemDriveChar(); |
|
380 |
//#endif |
|
381 |
#endif |
|
382 |
||
383 |
#if defined(__EPOC32__) |
|
384 |
TMachineStartupType reason; |
|
385 |
UserHal::StartupReason(reason); |
|
386 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
387 |
PrintStartUpReason(reason); |
|
388 |
#endif |
|
389 |
OpenOnDriveZOnly = (reason==EStartupSafeReset); |
|
390 |
#endif |
|
391 |
||
392 |
// |
|
393 |
// Now we must load estart from z: |
|
394 |
// |
|
395 |
RProcess eStart; |
|
396 |
#if defined(__WINS__) |
|
397 |
const char* eStartPath = NULL; |
|
398 |
UserSvr::HalFunction(EHalGroupEmulator,EEmulatorHalStringProperty,(TAny*)"EStart",&eStartPath); |
|
399 |
if (eStartPath == NULL) |
|
400 |
{ |
|
401 |
r=eStart.Create(KStartupExeSysBinName,KNullDesC); |
|
402 |
} |
|
403 |
else |
|
404 |
{ |
|
405 |
TPtrC8 temp((unsigned char *)eStartPath); |
|
406 |
TBuf16<KMaxFileName> buf; |
|
407 |
buf.Copy(temp); |
|
408 |
r=eStart.Create(buf,KNullDesC); |
|
409 |
} |
|
410 |
#else |
|
411 |
r=eStart.Create(KStartupExeSysBinName,KNullDesC); |
|
412 |
#endif |
|
413 |
||
414 |
if (r!=KErrNone) // Whoops! |
|
415 |
Fault(EMainStartupNoEStart); |
|
416 |
eStart.Resume(); // Start the process going |
|
417 |
eStart.Close(); // Get rid of our handle |
|
418 |
#if defined(_LOCKABLE_MEDIA) |
|
419 |
// Create a global semaphore for the asynchronous WriteToDisk() threads. |
|
420 |
RSemaphore s; |
|
421 |
r = s.CreateGlobal(_L("dwsem"), 1); // only supp 1 thd at a time |
|
422 |
__ASSERT_ALWAYS(r == KErrNone, Fault(EMainStartupWriteToDiskSemaphore)); |
|
423 |
#endif |
|
424 |
||
425 |
// |
|
426 |
// Now we can just exit the startup thread as its no longer needed. |
|
427 |
// |
|
428 |
return(KErrNone); |
|
429 |
} |
|
430 |
||
431 |
void commonInitialize() |
|
432 |
// |
|
433 |
// Initialization common to all platforms. |
|
434 |
// |
|
435 |
{ |
|
436 |
||
437 |
__PRINT(_L("commonInitialize")); |
|
438 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
439 |
ErrorCondition=KErrNone; |
|
440 |
ErrorCount=0; |
|
441 |
UserHeapAllocFailCount=-1; |
|
442 |
KernHeapAllocFailCount=-1; |
|
443 |
#endif |
|
444 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
445 |
TInt r = RequestAllocator::Initialise(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
446 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EFsCacheLockFailure)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
447 |
r = OperationAllocator::Initialise(); |
0 | 448 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EFsCacheLockFailure)); |
449 |
||
450 |
// initialise the TParse pool lock object |
|
451 |
r = TParsePool::Init(); |
|
452 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EFsParsePoolLockFailure)); |
|
453 |
||
454 |
// Get local copies of capability sets |
|
455 |
TCapabilitySet caps; |
|
456 |
caps.SetAllSupported(); |
|
457 |
AllCapabilities=*(SCapabilitySet*)∩︀ |
|
458 |
caps.SetDisabled(); |
|
459 |
DisabledCapabilities=*(SCapabilitySet*)∩︀ |
|
460 |
||
461 |
FsThreadManager::SetMainThreadId(); |
|
462 |
r=FsThreadManager::CreateDisconnectThread(); |
|
463 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EMainDisconnectThread)); |
|
464 |
||
465 |
||
466 |
// |
|
467 |
// Install a trap handler |
|
468 |
// |
|
469 |
CTrapCleanup* trapHandler=CTrapCleanup::New(); |
|
470 |
__ASSERT_ALWAYS(trapHandler!=NULL,Fault(EMainCreateResources1)); |
|
471 |
||
472 |
TRAP(r,createAllL()) |
|
473 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EMainCreateResources1)); |
|
474 |
CActiveSchedulerFs::New(); |
|
475 |
CServerFs::New(); |
|
476 |
TheKernEventNotifier = CKernEventNotifier::New(); |
|
477 |
__ASSERT_ALWAYS(TheKernEventNotifier,Fault(EMainCreateResources5)); |
|
478 |
CActiveSchedulerFs::Add(TheKernEventNotifier); |
|
479 |
TheKernEventNotifier->Start(); |
|
480 |
// |
|
481 |
__ASSERT_ALWAYS(InitLoader()==KErrNone,Fault(ELdrRestartInit)); |
|
482 |
// |
|
483 |
LocalFileSystemInitialized=EFalse; |
|
484 |
StartupInitCompleted=EFalse; |
|
485 |
RefreshZDriveCache=EFalse; |
|
486 |
CompFsMounted=EFalse; |
|
487 |
CompFsSync=ETrue; |
|
488 |
||
489 |
// initialise notification information |
|
490 |
FsNotify::Initialise(); |
|
491 |
// initialise local drive specific information |
|
492 |
LocalDrives::Initialise(); |
|
493 |
||
494 |
TRAP(r, FsPluginManager::InitialiseL()); |
|
495 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EMainCreateStartupThread0)); |
|
496 |
||
497 |
RThread t; |
|
498 |
r=t.Create(_L("StartupThread"),StartupThread,KDefaultStackSize,KHeapMinSize,KHeapMinSize,NULL); |
|
499 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EMainCreateStartupThread1)); |
|
500 |
t.SetPriority(EPriorityLess); |
|
501 |
||
502 |
CLogon* pL=NULL; |
|
503 |
TRAP(r,pL=CLogon::NewL()); |
|
504 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EMainCreateStartupThread2)); |
|
505 |
||
506 |
// NOTE: This function only returns after the startup thread has exited |
|
507 |
r=pL->Logon(t); |
|
508 |
||
509 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EMainCreateStartupThread3)); |
|
510 |
delete pL; |
|
511 |
||
512 |
// Make a proper process relative handle to the server |
|
513 |
r=TheServerThread.Duplicate(TheServerThread); |
|
514 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EMainCreateStartupThread4)); |
|
515 |
ServerThreadAllocator = &User::Heap(); |
|
516 |
} |
|
517 |
||
518 |
TBool ServerIsRunning() |
|
519 |
// |
|
520 |
// Check whether or not the server already exists |
|
521 |
// |
|
522 |
{ |
|
523 |
||
524 |
TFullName serverName; |
|
525 |
TFindServer fileServer(KFileServerName); |
|
526 |
TInt result=fileServer.Next(serverName); |
|
527 |
if (result!=KErrNotFound) |
|
528 |
return(ETrue); |
|
529 |
return(EFalse); |
|
530 |
} |
|
531 |
||
532 |
TInt E32Main() |
|
533 |
// |
|
534 |
// The file server. |
|
535 |
// |
|
536 |
{ |
|
537 |
if (ServerIsRunning()) |
|
538 |
return(KErrNone); |
|
539 |
||
540 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
541 |
if (UserSvr::DebugMask() & 0x402) // KBOOT | KDLL |
|
542 |
//DebugReg=KFLDR; |
|
543 |
//DebugReg=KFSERV|KFLDR; |
|
544 |
DebugReg=KFSERV|KFLDR|KLFFS|KTHRD|KROFS; |
|
545 |
||
546 |
// DebugReg=KFSYS|KFSERV|KFLDR|KLFFS|KTHRD|KCACHE|KROFS|KCOMPFS|KCACHE; |
|
547 |
// User::SetDebugMask(0x80004000); |
|
548 |
||
549 |
#endif |
|
550 |
__PRINT(_L("FileServer E32Main")); |
|
551 |
||
552 |
UserSvr::FsRegisterThread(); |
|
553 |
RThread().SetPriority(EPriorityMore); |
|
554 |
commonInitialize(); |
|
555 |
CActiveSchedulerFs::Start(); |
|
556 |
return(KErrNone); |
|
557 |
} |
|
558 |