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