baseport/src/cedar/generic/base/syborg/svphostfs/fs/svphostfsstart.cpp
changeset 0 ffa851df0825
equal deleted inserted replaced
-1:000000000000 0:ffa851df0825
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <e32std.h>
       
    19 #include <f32fsys.h>
       
    20 
       
    21 _LIT(KEStartPanicCatagory, "SVP_HOSTFS_SYSSTART");
       
    22 
       
    23 enum TEStartPanic
       
    24     {
       
    25     ELitNoDM = 1,                           // No Domain Manager
       
    26     ELitDMInitFail,                         // Domain Manager init fail
       
    27     ELitHALFail,                            // HAL init fail
       
    28     ELitConnectFsFail1,                     // Connect fs 1 fail
       
    29     ELitInitLocalPwStoreFail,               // Init PwStore fail
       
    30     ELitLocaleInitialisationFail,           // Initialisation of locale properties failed
       
    31     ELitFSInitDriveInfoFail,                // FS Init DriveInfo fail
       
    32     ELitCreateTrapHandlerFail,              // Create trap handler fail
       
    33     ELitLoadSysLddsFail,                    // Load sys ldds fail
       
    34     ELitLocalDriveMappingFail,              // Local drive mapping fail
       
    35     ELitDriveMappingFileFail,               // Drive mapping file not found
       
    36     ELitSwapMappingFailArrayInconsistent,   // Swap mappings fail - array inconsistent
       
    37     ELitFsSwapMappingFail,                  // Swap mappings fail - Fs request failed
       
    38     EPropertyError,                         // RProperty return error
       
    39     ECompMountFsFail,                       // Failed comp fs mount
       
    40     EFsNameFail,                            // File system name on Z: failed
       
    41     ELitNoWS,                               // No WSERV
       
    42     EStartupModeFail,                       // Get startup mode failed
       
    43     ESysAgentFail,                          // Fail to launch system agent
       
    44     ESetSystemDriveFail                     // Fail to set System Drive
       
    45     };
       
    46 
       
    47 inline void Panic(TEStartPanic aPanic, TInt aReason)
       
    48     {
       
    49     TBuf<10> panic(KEStartPanicCatagory);
       
    50     panic.AppendFormat(_L("_%d"), aPanic);
       
    51     User::Panic(panic, aReason);
       
    52     }
       
    53 
       
    54 _LIT(KServerPathSysBin, "0:\\Sys\\Bin\\");
       
    55 _LIT(KWindowServerRootName1,"EWSRV.EXE");	
       
    56 _LIT(KHostFSMounter, "z:\\sys\\bin\\SVPHOSTFS.EXE");
       
    57 
       
    58 TBool CreateServer(const TDriveList& aDrives, const TDesC& aRootName)
       
    59 	{
       
    60 	RProcess ws;
       
    61 	TInt r=ws.Create(aRootName, KNullDesC);
       
    62 	if (r!=KErrNone)
       
    63 		{
       
    64 		TFileName name;
       
    65 		name = KServerPathSysBin();
       
    66 		name+=aRootName;
       
    67 		TInt i=EDriveZ;
       
    68 		FOREVER
       
    69 			{
       
    70 			i= (i==0) ? EDriveZ : i-1;
       
    71 			if (aDrives[i]!=KDriveAbsent) // Got a valid drive
       
    72 				{
       
    73 				name[0]=(TUint32)('A'+i); // Set the drive letter
       
    74 				r=ws.Create(name,KNullDesC);
       
    75 				if (r==KErrNone)
       
    76 					break;
       
    77 				}
       
    78 			if (i==EDriveZ)
       
    79 				return EFalse;
       
    80 			}
       
    81 		}
       
    82 	ws.Resume();
       
    83 	ws.Close();
       
    84 	return ETrue;
       
    85 	}
       
    86 
       
    87 GLDEF_C TInt E32Main()
       
    88         {
       
    89 	RProcess ws;
       
    90 	TInt r=ws.Create(KHostFSMounter, KNullDesC);
       
    91 	if (r == KErrNone)
       
    92 	        {
       
    93 		TRequestStatus stat;
       
    94 		ws.Rendezvous(stat);
       
    95 		ws.Resume();
       
    96 		User::WaitForRequest(stat);		// wait for start or death
       
    97 		ws.Close();
       
    98 		}
       
    99 	// Start the window server 
       
   100 	RFs aFs;
       
   101 	r = aFs.Connect();
       
   102 
       
   103 	if (r != KErrNone)
       
   104 	        Panic(ELitConnectFsFail1, r);
       
   105 	TDriveList list;
       
   106 	aFs.DriveList(list);
       
   107 	aFs.Close();
       
   108 
       
   109 	if (!CreateServer(list,KWindowServerRootName1))
       
   110 	        Panic(ELitNoWS,KErrNotFound);
       
   111 
       
   112 	return(KErrNone);
       
   113 	}