baseapitest/basesvs/validation/f32/sfsrv/src/T_FsDataMounts.cpp
changeset 0 a41df078684a
child 15 4122176ea935
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 /*
       
     2 * Copyright (c) 2005-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 /**
       
    19 @test
       
    20 @internalComponent
       
    21 
       
    22 This contains CT_FsData
       
    23 */
       
    24 
       
    25 //	User includes
       
    26 #include "T_FsData.h"
       
    27 
       
    28 //	EPOC includes
       
    29 #include <f32fsys.h>
       
    30 
       
    31 /*@{*/
       
    32 /// Enumerations
       
    33 _LIT(KDriveA,							"EDriveA");
       
    34 _LIT(KDriveB,							"EDriveB");
       
    35 _LIT(KDriveC,							"EDriveC");
       
    36 _LIT(KDriveD,							"EDriveD");
       
    37 _LIT(KDriveE,							"EDriveE");
       
    38 _LIT(KDriveF,							"EDriveF");
       
    39 _LIT(KDriveG,							"EDriveG");
       
    40 _LIT(KDriveH,							"EDriveH");
       
    41 _LIT(KDriveI,							"EDriveI");
       
    42 _LIT(KDriveJ,							"EDriveJ");
       
    43 _LIT(KDriveK,							"EDriveK");
       
    44 _LIT(KDriveL,							"EDriveL");
       
    45 _LIT(KDriveM,							"EDriveM");
       
    46 _LIT(KDriveN,							"EDriveN");
       
    47 _LIT(KDriveO,							"EDriveO");
       
    48 _LIT(KDriveP,							"EDriveP");
       
    49 _LIT(KDriveQ,							"EDriveQ");
       
    50 _LIT(KDriveR,							"EDriveR");
       
    51 _LIT(KDriveS,							"EDriveS");
       
    52 _LIT(KDriveT,							"EDriveT");
       
    53 _LIT(KDriveU,							"EDriveU");
       
    54 _LIT(KDriveV,							"EDriveV");
       
    55 _LIT(KDriveW,							"EDriveW");
       
    56 _LIT(KDriveX,							"EDriveX");
       
    57 _LIT(KDriveY,							"EDriveY");
       
    58 _LIT(KDriveZ,							"EDriveZ");
       
    59 
       
    60 _LIT(KWriteMappingsAndSet,				"EWriteMappingsAndSet");
       
    61 _LIT(KWriteMappingsNoSet,				"EWriteMappingsNoSet");
       
    62 _LIT(KSwapIntMappingAndSet,				"ESwapIntMappingAndSet");
       
    63 
       
    64 
       
    65 ///	Parameters
       
    66 _LIT(KDrive,							"drive");
       
    67 _LIT(KDriveMappingElement,				"drive_mapping_element_");
       
    68 _LIT(KDriveMappingSize,					"drive_mapping_size");
       
    69 _LIT(KDriveMappingOperation,			"drive_mapping_operation");
       
    70 _LIT(KFileName,							"file_name");
       
    71 _LIT(KFileSystemName,					"file_system_name");
       
    72 _LIT(KNewFileSystemName,				"new_file_system_name");
       
    73 _LIT(KFlags,							"flags");
       
    74 _LIT(KIsSync,							"is_sync");
       
    75 _LIT(KExtensionName,					"extension_name");
       
    76 _LIT(KPosition,							"position");
       
    77 _LIT(KMode,								"mode");
       
    78 _LIT(KAll,								"all");
       
    79 _LIT(KCommandNum,						"command_num");
       
    80 _LIT(KSaveInInstance,					"save_in_instance");
       
    81 _LIT(KLocalDrive,						"local_drive");
       
    82 _LIT(KCompositeDrive,					"composite_drive");
       
    83 _LIT(KIsMountSuccess,					"is_mount_success");
       
    84 _LIT(KParam1,							"param1");
       
    85 _LIT(KParam2,							"param2");
       
    86 _LIT(KIndex,							"index");
       
    87 _LIT(KSubTypeName,						"sub_type_name");
       
    88 
       
    89 
       
    90 ///	Commands
       
    91 _LIT(KCmdAddFileSystem,					"AddFileSystem");
       
    92 _LIT(KCmdDismountFileSystem,			"DismountFileSystem");
       
    93 _LIT(KCmdFileSystemName,				"FileSystemName");
       
    94 _LIT(KCmdMountFileSystem,				"MountFileSystem");
       
    95 _LIT(KCmdMountFileSystemAndScan,		"MountFileSystemAndScan");
       
    96 _LIT(KCmdRemountDrive,					"RemountDrive");
       
    97 _LIT(KCmdRemoveFileSystem,				"RemoveFileSystem");
       
    98 _LIT(KCmdAddExtension,					"AddExtension");
       
    99 _LIT(KCmdMountExtension,				"MountExtension");
       
   100 _LIT(KCmdRemoveExtension,				"RemoveExtension");
       
   101 _LIT(KCmdExtensionName,					"ExtensionName");
       
   102 _LIT(KCmdAddCompositeMount,				"AddCompositeMount");
       
   103 _LIT(KCmdAllowDismount,					"AllowDismount");
       
   104 _LIT(KCmdNotifyDismount,				"NotifyDismount");
       
   105 _LIT(KCmdNotifyDismountCancel,			"NotifyDismountCancel");
       
   106 _LIT(KCmdStartupInitComplete,			"StartupInitComplete");
       
   107 _LIT(KCmdSwapFileSystem,				"SwapFileSystem");
       
   108 _LIT(KCmdSetStartupConfiguration,		"SetStartupConfiguration");
       
   109 _LIT(KCmdDismountExtension,				"DismountExtension");
       
   110 _LIT(KCmdSetLocalDriveMapping,			"SetLocalDriveMapping");
       
   111 _LIT(KCmdFinaliseDrives,				"FinaliseDrives");
       
   112 _LIT(KCmdFileSystemSubType,				"FileSystemSubType");
       
   113 /*@}*/
       
   114 
       
   115 
       
   116 TBool CT_FsData::DoCommandMountsL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
   117 /**
       
   118  * Process a mounts related command read from the ini file
       
   119  *
       
   120  * @param aCommand	the command to process
       
   121  * @param aSection		the entry in the ini file requiring the command to be processed
       
   122  *
       
   123  * @return ETrue if the command is processed
       
   124  */
       
   125 	{
       
   126 	TBool retVal = ETrue;
       
   127 	
       
   128 	if (aCommand == KCmdAddFileSystem)
       
   129 		{
       
   130 		DoCmdAddFileSystem(aSection);
       
   131 		}
       
   132 	else if (aCommand == KCmdDismountFileSystem)
       
   133 		{
       
   134 		DoCmdDismountFileSystem(aSection);
       
   135 		}
       
   136 	else if (aCommand == KCmdFileSystemName)
       
   137 		{
       
   138 		DoCmdFileSystemName(aSection);
       
   139 		}
       
   140 	else if (aCommand == KCmdMountFileSystem)
       
   141 		{
       
   142 		DoCmdMountFileSystem(aSection);
       
   143 		}
       
   144 	else if (aCommand == KCmdMountFileSystemAndScan)
       
   145 		{
       
   146 		DoCmdMountFileSystemAndScan(aSection);
       
   147 		}
       
   148 	else if (aCommand == KCmdRemoveFileSystem)
       
   149 		{
       
   150 		DoCmdRemoveFileSystem(aSection);
       
   151 		}
       
   152 	else if (aCommand == KCmdRemountDrive)
       
   153 		{
       
   154 		DoCmdRemountDriveL(aSection);
       
   155 		}
       
   156 	else if (aCommand == KCmdAddExtension)
       
   157 		{
       
   158 		DoCmdAddExtension(aSection);
       
   159 		}
       
   160 	else if (aCommand == KCmdRemoveExtension)
       
   161 		{
       
   162 		DoCmdRemoveExtension(aSection);
       
   163 		}
       
   164 	else if (aCommand == KCmdExtensionName)
       
   165 		{
       
   166 		DoCmdExtensionName(aSection);
       
   167 		}
       
   168 	else if (aCommand == KCmdMountExtension)
       
   169 		{
       
   170 		DoCmdMountExtension(aSection);
       
   171 		}
       
   172 	else if (aCommand == KCmdAllowDismount)
       
   173 		{
       
   174 		DoCmdAllowDismount(aSection);
       
   175 		}
       
   176 	else if (aCommand == KCmdNotifyDismount)
       
   177 		{
       
   178 		DoCmdNotifyDismountL(aSection, aAsyncErrorIndex);
       
   179 		}
       
   180 	else if (aCommand == KCmdNotifyDismountCancel)
       
   181 		{
       
   182 		DoCmdNotifyDismountCancel(aSection);
       
   183 		}
       
   184 	else if (aCommand == KCmdStartupInitComplete)
       
   185 		{
       
   186 		DoCmdStartupInitCompleteL(aAsyncErrorIndex);
       
   187 		}
       
   188 	else if (aCommand == KCmdSwapFileSystem)
       
   189 		{
       
   190 		DoCmdSwapFileSystem(aSection);
       
   191 		}
       
   192 	else if (aCommand == KCmdSetStartupConfiguration)
       
   193 		{
       
   194 		DoCmdSetStartupConfigurationL(aSection);
       
   195 		}
       
   196 	else if (aCommand == KCmdFinaliseDrives)
       
   197 		{
       
   198 		DoCmdFinaliseDrives();
       
   199 		}
       
   200     else if (aCommand == KCmdAddCompositeMount)
       
   201 		{
       
   202 		DoCmdAddCompositeMount(aSection);
       
   203 		}
       
   204     else if (aCommand == KCmdDismountExtension)
       
   205 		{
       
   206 		DoCmdDismountExtension(aSection);
       
   207 		}
       
   208 	else if (aCommand == KCmdSetLocalDriveMapping)
       
   209 		{
       
   210 		DoCmdSetLocalDriveMappingL(aSection);
       
   211 		}
       
   212     else if (aCommand == KCmdFileSystemSubType)
       
   213 		{
       
   214 		DoCmdFileSystemSubType(aSection);
       
   215 		}
       
   216  	else
       
   217 		{
       
   218 		retVal = EFalse;
       
   219 		}
       
   220 
       
   221 	return retVal;
       
   222 	}
       
   223 
       
   224 
       
   225 void CT_FsData::DoCmdAddFileSystem(const TDesC& aSection)
       
   226 /** Calls RFs::AddFileSystem() */
       
   227 	{
       
   228 	INFO_PRINTF1(_L("Calls RFs::AddFileSystem()"));
       
   229 
       
   230 	// get file name from parameters
       
   231 	TPtrC	fileName;
       
   232 	if ( GET_MANDATORY_STRING_PARAMETER(KFileName(), aSection, fileName))
       
   233 		{
       
   234 		// call AddFileSystem()
       
   235 		TInt	err = iFs->AddFileSystem(fileName);
       
   236 
       
   237 		// check error code
       
   238 		if (err != KErrNone)
       
   239 			{
       
   240 			ERR_PRINTF2(_L("AddFileSystem error: %d"), err);
       
   241 			SetError(err);
       
   242 			}
       
   243 		}
       
   244 	}
       
   245 
       
   246 void CT_FsData::DoCmdMountFileSystem(const TDesC& aSection)
       
   247 /** Calls RFs::MountFileSystem() */
       
   248 	{
       
   249 	INFO_PRINTF1(_L("Calls RFs::MountFileSystem()"));
       
   250 
       
   251 	TBool dataOk = ETrue;
       
   252 
       
   253 	// get drive number from parameters
       
   254 	TDriveNumber	driveNumber = EDriveA;
       
   255 	if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
       
   256 		{
       
   257 		ERR_PRINTF2(_L("No %S"), &KDrive());
       
   258 		SetBlockResult(EFail);
       
   259 		dataOk = EFalse;
       
   260 		}
       
   261 
       
   262 	// get file system name from parameters
       
   263 	TPtrC	fileSystemName;
       
   264 	if ( !GET_OPTIONAL_STRING_PARAMETER(KFileSystemName(), aSection, fileSystemName) )
       
   265 		{
       
   266 		fileSystemName.Set(iFileSystemName);
       
   267 		}
       
   268 
       
   269 	if(dataOk)
       
   270 		{
       
   271 		// get file system name from parameters
       
   272 		TBool	isSync = EFalse;
       
   273 		TInt	err = KErrNone;
       
   274 
       
   275 		TPtrC	extensionName;
       
   276 		TBool	hasExtensionName=GET_OPTIONAL_STRING_PARAMETER(KExtensionName(), aSection, extensionName);
       
   277 		if (GET_OPTIONAL_BOOL_PARAMETER(KIsSync(), aSection, isSync))
       
   278 			{
       
   279 			if ( hasExtensionName )
       
   280 				{
       
   281 				// call MountFileSystem()
       
   282 				INFO_PRINTF5(_L("MountFileSystem(%S, %S, %d, %d)"), &fileSystemName, &extensionName, driveNumber, isSync);
       
   283 				err = iFs->MountFileSystem(fileSystemName, extensionName, driveNumber, isSync);
       
   284 				}
       
   285 			else
       
   286 				{
       
   287 				// call MountFileSystem()
       
   288 				INFO_PRINTF4(_L("MountFileSystem(%S, %d, %d)"), &fileSystemName, driveNumber, isSync);
       
   289 				err = iFs->MountFileSystem(fileSystemName, driveNumber, isSync);
       
   290 				}
       
   291 			}
       
   292 		else
       
   293 			{
       
   294 			if ( hasExtensionName )
       
   295 				{
       
   296 				// call MountFileSystem()
       
   297 				INFO_PRINTF4(_L("MountFileSystem(%S, %S, %d)"), &fileSystemName, &extensionName, driveNumber);
       
   298 				err = iFs->MountFileSystem(fileSystemName, extensionName, driveNumber);
       
   299 				}
       
   300 			else
       
   301 				{
       
   302 				// call MountFileSystem()
       
   303 				INFO_PRINTF3(_L("MountFileSystem(%S, %d)"), &fileSystemName, driveNumber);
       
   304 				err = iFs->MountFileSystem(fileSystemName, driveNumber);
       
   305 				}
       
   306 			}
       
   307 		// check error code
       
   308 		if (err != KErrNone)
       
   309 			{
       
   310 			ERR_PRINTF2(_L("MountFileSystem error: %d"), err);
       
   311 			SetError(err);
       
   312 			}
       
   313 		}
       
   314 	}
       
   315 
       
   316 
       
   317 void CT_FsData::DoCmdMountFileSystemAndScan(const TDesC& aSection)
       
   318 /** Calls RFs::MountFileSystemAndScan() */
       
   319 	{
       
   320 	INFO_PRINTF1(_L("Calls RFs::MountFileSystemAndScan()"));
       
   321 
       
   322 	TBool dataOk = ETrue;
       
   323 
       
   324 	// get drive number from parameters
       
   325 	TDriveNumber	driveNumber = EDriveA;
       
   326 	if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
       
   327 		{
       
   328 		ERR_PRINTF2(_L("No %S"), &KDrive());
       
   329 		SetBlockResult(EFail);
       
   330 		dataOk = EFalse;
       
   331 		}
       
   332 
       
   333 	// get file system name from parameters
       
   334 	TPtrC	fileSystemName;
       
   335 	if ( !GET_OPTIONAL_STRING_PARAMETER(KFileSystemName(), aSection, fileSystemName) )
       
   336 		{
       
   337 		fileSystemName.Set(iFileSystemName);
       
   338 		}
       
   339 
       
   340 	if(dataOk)
       
   341 		{
       
   342 		TInt	err=KErrNone;
       
   343 		TBool	isMountSuccess = EFalse;
       
   344 		// get extension name from parameters
       
   345 		TPtrC	extensionName;
       
   346 		if (GET_OPTIONAL_STRING_PARAMETER(KExtensionName(), aSection, extensionName))
       
   347 			{
       
   348 			//call MountFileSystemAndScan
       
   349 			INFO_PRINTF4(_L("MountFileSystemAndScan(%S, %S, %d, isMountSuccess)"), &fileSystemName, &extensionName, driveNumber);
       
   350 			err = iFs->MountFileSystemAndScan(fileSystemName, extensionName, driveNumber, isMountSuccess);
       
   351 			}
       
   352 		else
       
   353 			{
       
   354 			//call MountFileSystemAndScan
       
   355 			INFO_PRINTF3(_L("MountFileSystemAndScan(%S, %d, isMountSuccess)"), &fileSystemName, driveNumber);
       
   356 			err = iFs->MountFileSystemAndScan(fileSystemName, driveNumber, isMountSuccess);
       
   357 			}
       
   358 
       
   359 		// check error code
       
   360 		if (err != KErrNone)
       
   361 			{
       
   362 			ERR_PRINTF2(_L("MountFileSystemAndScan error: %d"), err);
       
   363 			SetError(err);
       
   364 			}
       
   365 
       
   366 		//Only for info
       
   367 		if(isMountSuccess)
       
   368 			{
       
   369 			INFO_PRINTF1(_L("MountFileSystemAndScan() successfully mounted"));
       
   370 			}
       
   371 		else
       
   372 			{
       
   373 			INFO_PRINTF1(_L("MountFileSystemAndScan() not mounted"));
       
   374 			}
       
   375 
       
   376 		//check if mount was successful
       
   377 		TBool	expected = EFalse;
       
   378 		if ( GET_OPTIONAL_BOOL_PARAMETER(KIsMountSuccess(), aSection, expected) )
       
   379 			{
       
   380 			if ( isMountSuccess!=expected )
       
   381 				{
       
   382 				ERR_PRINTF1(_L("MountFileSystemAndScan() does not match expected value"));
       
   383 				SetBlockResult(EFail);
       
   384 				}
       
   385 			}
       
   386 		}
       
   387 	}
       
   388 
       
   389 
       
   390 void CT_FsData::DoCmdDismountFileSystem(const TDesC& aSection)
       
   391 /** Calls RFs::DismountFileSystem() */
       
   392 	{
       
   393 	INFO_PRINTF1(_L("Calls RFs::DismountFileSystem()"));
       
   394 
       
   395 	TBool dataOk = ETrue;
       
   396 
       
   397 	// get drive number from parameters
       
   398 	TDriveNumber	driveNumber = EDriveA;
       
   399 	if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
       
   400 		{
       
   401 		ERR_PRINTF2(_L("No %S"), &KDrive());
       
   402 		SetBlockResult(EFail);
       
   403 		dataOk = EFalse;
       
   404 		}
       
   405 	// get file system name from parameters
       
   406 	TPtrC	fileSystemName;
       
   407 	if (!GET_OPTIONAL_STRING_PARAMETER(KFileSystemName(), aSection, fileSystemName))
       
   408 		{
       
   409 		fileSystemName.Set(iFileSystemName);
       
   410 		}
       
   411 
       
   412 	if(dataOk)
       
   413 		{
       
   414 		// call DismountFileSystem()
       
   415 		TInt err = iFs->DismountFileSystem(fileSystemName, driveNumber);
       
   416 
       
   417 		// check error code
       
   418 		if (err != KErrNone)
       
   419 			{
       
   420 			ERR_PRINTF2(_L("DismountFileSystem error: %d"), err);
       
   421 			SetError(err);
       
   422 			}
       
   423 		}
       
   424 	}
       
   425 
       
   426 
       
   427 void CT_FsData::DoCmdRemoveFileSystem(const TDesC& aSection)
       
   428 /** Calls RFs::RemoveFileSystem() */
       
   429 	{
       
   430 	INFO_PRINTF1(_L("Calls RFs::RemoveFileSystem()"));
       
   431 
       
   432 	// get file name from parameters
       
   433 	TPtrC	fileSystemName;
       
   434 	if ( !GET_OPTIONAL_STRING_PARAMETER(KFileSystemName(), aSection, fileSystemName) )
       
   435 		{
       
   436 		fileSystemName.Set(iFileSystemName);
       
   437 		}
       
   438 
       
   439 	// call RemoveFileSystem()
       
   440 	TInt err = iFs->RemoveFileSystem(fileSystemName);
       
   441 
       
   442 	// check error code
       
   443 	if (err != KErrNone)
       
   444 		{
       
   445 		ERR_PRINTF2(_L("RemoveFileSystem error: %d"), err);
       
   446 		SetError(err);
       
   447 		}
       
   448 	}
       
   449 
       
   450 
       
   451 void CT_FsData::DoCmdFileSystemName(const TDesC& aSection)
       
   452 /** Calls RFs::FileSystemName() */
       
   453 	{
       
   454 	INFO_PRINTF1(_L("Calls RFs::FileSystemName()"));
       
   455 
       
   456 	// get a flag if we need to remember the file system name in an instance variable
       
   457 	TBool	save=ETrue;
       
   458 	GET_OPTIONAL_BOOL_PARAMETER(KSaveInInstance(), aSection, save);
       
   459 
       
   460 	// get drive number from parameters
       
   461 	TDriveNumber	driveNumber = EDriveA;
       
   462 	if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
       
   463 		{
       
   464 		ERR_PRINTF2(_L("No %S"), &KDrive());
       
   465 		SetBlockResult(EFail);
       
   466 		}
       
   467 	else
       
   468 		{
       
   469 		// call FileSystemName()
       
   470 		TFullName	fileSystemName;
       
   471 		TInt		err = iFs->FileSystemName(fileSystemName, driveNumber);
       
   472 		INFO_PRINTF2(_L("File system name: %S"), &fileSystemName);
       
   473 
       
   474 		// check error code
       
   475 		if (err == KErrNone)
       
   476 			{
       
   477 			if ( save )
       
   478 				{
       
   479 				iFileSystemName=fileSystemName;
       
   480 				}
       
   481 			}
       
   482 		else
       
   483 			{
       
   484 			ERR_PRINTF2(_L("FileSystemName error: %d"), err);
       
   485 			SetError(err);
       
   486 			}
       
   487 
       
   488 		//Check expected result
       
   489 		TPtrC	fsNameExpect;
       
   490 		if (GET_OPTIONAL_STRING_PARAMETER(KFileSystemName(), aSection, fsNameExpect))
       
   491 			{
       
   492 			if ( fsNameExpect != fileSystemName)
       
   493 				{
       
   494 				ERR_PRINTF1(_L("File system name != expected name"));
       
   495 				SetBlockResult(EFail);
       
   496 				}
       
   497 			}
       
   498 		}
       
   499 	}
       
   500 
       
   501 
       
   502 void CT_FsData::DoCmdAddExtension(const TDesC& aSection)
       
   503 /** Calls RFs::AddExtension() */
       
   504 	{
       
   505 	INFO_PRINTF1(_L("Calls RFs::AddExtension()"));
       
   506 	TPtrC fileName;
       
   507 	if ( GET_MANDATORY_STRING_PARAMETER(KFileName(), aSection, fileName) )
       
   508 		{
       
   509 		//call AddExtension
       
   510 		TInt err = iFs->AddExtension(fileName);
       
   511 
       
   512 		// check error code
       
   513 		if (err != KErrNone)
       
   514 			{
       
   515 			ERR_PRINTF2(_L("AddExtension error: %d"), err);
       
   516 			SetError(err);
       
   517 			}
       
   518 		}
       
   519 	}
       
   520 
       
   521 
       
   522 void CT_FsData::DoCmdMountExtension(const TDesC& aSection)
       
   523 /** Calls RFs::MountExtension() */
       
   524 	{
       
   525 	INFO_PRINTF1(_L("Calls RFs::MountExtension()"));
       
   526 
       
   527 	TBool dataOk = ETrue;
       
   528 
       
   529 	// get drive number from parameters
       
   530 	TDriveNumber	driveNumber = EDriveA;
       
   531 	if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
       
   532 		{
       
   533 		ERR_PRINTF2(_L("No %S"), &KDrive());
       
   534 		SetBlockResult(EFail);
       
   535 		dataOk = EFalse;
       
   536 		}
       
   537 
       
   538 	// get extension name from parameters
       
   539 	TPtrC extensionName;
       
   540 	if (!GET_MANDATORY_STRING_PARAMETER(KExtensionName(), aSection, extensionName))
       
   541 		{
       
   542 		dataOk = EFalse;
       
   543 		}
       
   544 
       
   545 	if(dataOk)
       
   546 		{
       
   547 		TInt	err = iFs->MountExtension(extensionName, driveNumber);
       
   548 		if (err != KErrNone)
       
   549 			{
       
   550 			ERR_PRINTF2(_L("MountExtension error: %d"), err);
       
   551 			SetError(err);
       
   552 			}
       
   553 		}
       
   554 	}
       
   555 
       
   556 void CT_FsData::DoCmdDismountExtension(const TDesC& aSection)
       
   557 /** Calls RFs::DismountExtension() */
       
   558 	{
       
   559 	INFO_PRINTF1(_L("Calls RFs::DismountExtension()"));
       
   560 
       
   561 	TBool dataOk = ETrue;
       
   562 
       
   563 	// get drive number from parameters
       
   564 	TDriveNumber	driveNumber = EDriveA;
       
   565 	if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
       
   566 		{
       
   567 		ERR_PRINTF2(_L("No %S"), &KDrive());
       
   568 		SetBlockResult(EFail);
       
   569 		dataOk = EFalse;
       
   570 		}
       
   571 
       
   572 	TPtrC extensionName;
       
   573 	if (!GET_MANDATORY_STRING_PARAMETER(KExtensionName(), aSection, extensionName))
       
   574 		{
       
   575 		dataOk = EFalse;
       
   576 		}
       
   577 	if(dataOk)
       
   578 		{
       
   579 		//call DismountExtension
       
   580 		TInt err = iFs->DismountExtension(extensionName, driveNumber);
       
   581 
       
   582 		//check error code
       
   583 		if (err != KErrNone)
       
   584 			{
       
   585 			ERR_PRINTF2(_L("DismountExtension error: %d"), err);
       
   586 			SetError(err);
       
   587 			}
       
   588 		}
       
   589 
       
   590 	}
       
   591 
       
   592 
       
   593 void CT_FsData::DoCmdRemoveExtension(const TDesC& aSection)
       
   594 /** Calls RFs::RemoveExtension() */
       
   595 	{
       
   596 	INFO_PRINTF1(_L("Calls RFs::RemoveExtension()"));
       
   597 
       
   598 	TPtrC extensionName;
       
   599 	if (GET_MANDATORY_STRING_PARAMETER(KExtensionName(), aSection, extensionName))
       
   600 		{
       
   601 		//call RemoveExtension
       
   602 		TInt err = iFs->RemoveExtension(extensionName);
       
   603 
       
   604 		// check error code
       
   605 		if (err != KErrNone)
       
   606 			{
       
   607 			ERR_PRINTF2(_L("RemoveExtension error: %d"), err);
       
   608 			SetError(err);
       
   609 			}
       
   610 		}
       
   611 	}
       
   612 
       
   613 
       
   614 void CT_FsData::DoCmdExtensionName(const TDesC& aSection)
       
   615 /** Calls RFs::ExtensionName() */
       
   616 	{
       
   617 	INFO_PRINTF1(_L("Calls RFs::ExtensionName()"));
       
   618 
       
   619 	TBool dataOk = ETrue;
       
   620 
       
   621 	// get drive number from parameters
       
   622 	TDriveNumber	driveNumber = EDriveA;
       
   623 	if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
       
   624 		{
       
   625 		ERR_PRINTF2(_L("No %S"), &KDrive());
       
   626 		SetBlockResult(EFail);
       
   627 		dataOk = EFalse;
       
   628 		}
       
   629 	//get position of the extension in the extension hierarchy.
       
   630 	TInt pos = 0;
       
   631 	if (!GET_MANDATORY_INT_PARAMETER(KPosition(), aSection, pos))
       
   632 		{
       
   633 		dataOk = EFalse;
       
   634 		}
       
   635 
       
   636 	if(dataOk)
       
   637 		{
       
   638 
       
   639 		TInt err = iFs->ExtensionName(iExtensionName, driveNumber, pos);
       
   640 
       
   641 		if(err == KErrNone)
       
   642 			{
       
   643 			TPtrC extNameExpect;
       
   644 			if (GET_OPTIONAL_STRING_PARAMETER(KExtensionName(), aSection, extNameExpect))
       
   645 				{
       
   646 				if(extNameExpect != iExtensionName)
       
   647 					{
       
   648 					ERR_PRINTF3(_L("ExtensionName: %S != %S expected name"), &iExtensionName, &extNameExpect);
       
   649 					SetBlockResult(EFail);
       
   650 					}
       
   651 				else
       
   652 					{
       
   653 					INFO_PRINTF2(_L("ExtensionName: %S"), &iExtensionName);
       
   654 					}
       
   655 				}
       
   656 			else
       
   657 				{
       
   658 				INFO_PRINTF2(_L("ExtensionName: %S"), &iExtensionName);
       
   659 				}
       
   660 			}
       
   661 		// check error code
       
   662 		else
       
   663 			{
       
   664 			ERR_PRINTF2(_L("ExtensionName error: %d"), err);
       
   665 			SetError(err);
       
   666 			}
       
   667 		}
       
   668 	}
       
   669 
       
   670 
       
   671 void CT_FsData::DoCmdRemountDriveL(const TDesC& aSection)
       
   672 /** Calls RFs::RemountDrive() */
       
   673 	{
       
   674 	INFO_PRINTF1(_L("Calls RFs::RemountDrive()"));
       
   675 	TBool	dataOk = ETrue;
       
   676 
       
   677 	// get drive number from parameters
       
   678 	TDriveNumber	driveNumber = EDriveA;
       
   679 	if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
       
   680 		{
       
   681 		ERR_PRINTF2(_L("No %S"), &KDrive());
       
   682 		SetBlockResult(EFail);
       
   683 		dataOk = EFalse;
       
   684 		}
       
   685 
       
   686 	// get flags from parameters can be in hex(0x00000001) or in decimal(1)
       
   687 	TUint	flags = 0;
       
   688 	TInt	tempVal = 0;
       
   689 	
       
   690 	if(GetHexFromConfig(aSection, KFlags, tempVal))
       
   691 		{
       
   692 		flags = tempVal;
       
   693 		}
       
   694 	else if(GET_OPTIONAL_INT_PARAMETER(KFlags(), aSection, tempVal))
       
   695 		{
       
   696 		flags = tempVal;
       
   697 		}
       
   698 	else
       
   699 		{
       
   700 		ERR_PRINTF2(_L("No parameter %S"), &KFlags());
       
   701 		SetBlockResult(EFail);
       
   702 		dataOk = EFalse;
       
   703 		}
       
   704 
       
   705 	RFile	file;
       
   706 	HBufC8*	fileDataBuff = NULL;
       
   707 
       
   708 	// get file name from parameters
       
   709 	TPtrC	fileName;
       
   710 	TBool	useMountInfo = GET_OPTIONAL_STRING_PARAMETER(KFileName(), aSection, fileName);
       
   711 	if ( useMountInfo )
       
   712 		{
       
   713 		// open file
       
   714 		TInt error = file.Open(FileServer(), fileName, EFileRead | EFileShareAny);
       
   715 		if(error == KErrNone)
       
   716 			{
       
   717 			CleanupClosePushL(file);
       
   718 			INFO_PRINTF1(_L("File Opened."));
       
   719 			// get size
       
   720 			TInt	size = 0;
       
   721 			error = file.Size(size);
       
   722 			INFO_PRINTF2(_L("File Size=%d."), size);
       
   723 			if(error == KErrNone)
       
   724 				{
       
   725 				// read file
       
   726 				fileDataBuff = HBufC8::NewL(size);
       
   727 				INFO_PRINTF1(_L("Buffer created."));
       
   728 
       
   729 				CleanupStack::PushL(fileDataBuff);
       
   730 				TPtr8	fileData = fileDataBuff->Des();
       
   731 				error = file.Read(fileData);
       
   732 				if(error != KErrNone)
       
   733 					{
       
   734 					ERR_PRINTF2(_L("Reading File, Error: %d"), error);
       
   735 					dataOk = EFalse;
       
   736 					SetBlockResult(EFail);
       
   737 					}
       
   738 				}
       
   739 			else
       
   740 				{
       
   741 				ERR_PRINTF2(_L("File Size, Error: %d."), error);
       
   742 				dataOk = EFalse;
       
   743 				SetBlockResult(EFail);
       
   744 				}
       
   745 			}
       
   746 		else
       
   747 			{
       
   748 			ERR_PRINTF2(_L("File Open, Error: %d"), error);
       
   749 			dataOk = EFalse;
       
   750 			SetBlockResult(EFail);
       
   751 			}
       
   752 		}
       
   753 
       
   754 	if ( dataOk )
       
   755 		{
       
   756 		// call RemountDrive()
       
   757 		TInt err = iFs->RemountDrive(driveNumber, fileDataBuff, flags);
       
   758 		INFO_PRINTF2(_L("RemountDrive Flags: %u"), flags);
       
   759 
       
   760 		// check error code
       
   761 		if (err != KErrNone)
       
   762 			{
       
   763 			ERR_PRINTF2(_L("RemountDrive error: %d"), err);
       
   764 			SetError(err);
       
   765 			}
       
   766 		}
       
   767 
       
   768 	// cleanup if mountInfo was used
       
   769 	if (useMountInfo)
       
   770 		{
       
   771 		CleanupStack::PopAndDestroy(2, &file); // file, fileDataBuff
       
   772 		}
       
   773 
       
   774 	}
       
   775 
       
   776 
       
   777 void CT_FsData::DoCmdNotifyDismountL(const TDesC& aSection, const TInt aAsyncErrorIndex)
       
   778 /** Calls RFs::NotifyDismount() */
       
   779 	{
       
   780 	INFO_PRINTF1(_L("Calls RFs::NotifyDismount()"));
       
   781 
       
   782 	TNotifyDismountMode mode = EFsDismountRegisterClient;
       
   783 	TPtrC modeStr;
       
   784 	//get NotifyDismountMode from parameters
       
   785 	if(GET_MANDATORY_STRING_PARAMETER(KMode(), aSection, modeStr))
       
   786 		{
       
   787 		if(modeStr == _L("EFsDismountRegisterClient"))
       
   788 			{
       
   789 			mode = EFsDismountRegisterClient;
       
   790 			}
       
   791 		else if(modeStr == _L("EFsDismountNotifyClients"))
       
   792 			{
       
   793 			mode = EFsDismountNotifyClients;
       
   794 			}
       
   795 		else if(modeStr == _L("EFsDismountForceDismount"))
       
   796 			{
       
   797 			mode = EFsDismountForceDismount;
       
   798 			}
       
   799 		else
       
   800 			{
       
   801 			TInt modeNumber;
       
   802 			if(GET_OPTIONAL_INT_PARAMETER(KMode, aSection, modeNumber))
       
   803 				{
       
   804 				mode = (TNotifyDismountMode)modeNumber;
       
   805 				}
       
   806 			else
       
   807 				{
       
   808 				ERR_PRINTF3(_L("NotifyDismount() incorrect parameter %S in %S"), &modeStr, &KMode());
       
   809 				SetBlockResult(EFail);
       
   810 				}
       
   811 			}
       
   812 		}
       
   813 
       
   814 	TDriveNumber	driveNumber = EDriveA;
       
   815 	if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
       
   816 		{
       
   817 		ERR_PRINTF2(_L("No %S"), &KDrive());
       
   818 		SetBlockResult(EFail);
       
   819 		}
       
   820 	else
       
   821 		{
       
   822 		// call NotifyDismount()
       
   823 		CActiveCallback*	active = CActiveCallback::NewLC(*this);
       
   824 		iNotifyDismount.AppendL(active);
       
   825 		CleanupStack::Pop(active);
       
   826 		
       
   827 		iFs->NotifyDismount(driveNumber, active->iStatus, mode);
       
   828 		active->Activate(aAsyncErrorIndex);
       
   829 		IncOutstanding();
       
   830 		}
       
   831 	}
       
   832 
       
   833 
       
   834 void CT_FsData::DoCmdNotifyDismountCancel(const TDesC& aSection)
       
   835 /** Calls RFs::NotifyDismountCancel() */
       
   836 	{
       
   837 	INFO_PRINTF1(_L("Calls RFs::NotifyDismountCancel()"));
       
   838 
       
   839 	TBool all = ETrue;
       
   840 
       
   841 	if(GET_MANDATORY_BOOL_PARAMETER(KAll(), aSection, all))
       
   842 		{
       
   843 		if(all)
       
   844 			{
       
   845 			//Cancels all outstanding requests.
       
   846 			iFs->NotifyDismountCancel();
       
   847 			INFO_PRINTF1(_L("NotifyDismountCancel()"));
       
   848 			}
       
   849 		else
       
   850 			{
       
   851 			// Cancels a specific outstanding request
       
   852 			TInt	index=0;
       
   853 			GET_OPTIONAL_INT_PARAMETER(KIndex, aSection, index);
       
   854 
       
   855 			//Cancels a specific outstanding request
       
   856 			iFs->NotifyDismountCancel(iNotifyDismount[index]->iStatus);
       
   857 			INFO_PRINTF1(_L("NotifyDismountCancel(TRequestStatus)"));
       
   858 			}
       
   859 		}
       
   860 	}
       
   861 
       
   862 
       
   863 void CT_FsData::DoCmdAllowDismount(const TDesC& aSection)
       
   864 /** Calls RFs::AllowDismount() */
       
   865 	{
       
   866 	INFO_PRINTF1(_L("Calls RFs::AllowDismount()"));
       
   867 
       
   868 	// get drive number from parameters
       
   869 	TDriveNumber	driveNumber = EDriveA;
       
   870 	if(!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
       
   871 		{
       
   872 		ERR_PRINTF2(_L("No %S"), &KDrive());
       
   873 		SetBlockResult(EFail);
       
   874 		}
       
   875 	else
       
   876 		{
       
   877 		//call AllowDismount
       
   878 		TInt err = iFs->AllowDismount(driveNumber);
       
   879 		// check error code
       
   880 		if (err != KErrNone)
       
   881 			{
       
   882 			ERR_PRINTF2(_L("AllowDismount error: %d"), err);
       
   883 			SetError(err);
       
   884 			}
       
   885 		}
       
   886 	}
       
   887 
       
   888 
       
   889 void CT_FsData::DoCmdSetStartupConfigurationL(const TDesC& aSection)
       
   890 /** Calls RFs::SetStartupConfiguration() */
       
   891 	{
       
   892 	INFO_PRINTF1(_L("Calls RFs::SetStartupConfiguration()"));
       
   893 
       
   894 	//get Command from parameters
       
   895 	TPtrC commandNum;
       
   896 	TStartupConfigurationCmd configCommand = ELoaderPriority;
       
   897 	if(GET_MANDATORY_STRING_PARAMETER(KCommandNum(), aSection, commandNum))
       
   898 		{
       
   899 		//Converting from string to TStartupConfigurationCmd
       
   900 		if(commandNum == _L("ELoaderPriority"))
       
   901 			{
       
   902 			configCommand = ELoaderPriority;
       
   903 			}
       
   904         else if(commandNum == _L("ESetRugged"))
       
   905 			{
       
   906 			configCommand = ESetRugged;
       
   907 			}
       
   908 		else if(commandNum == _L("EMaxStartupConfigurationCmd"))
       
   909 			{
       
   910 			configCommand = EMaxStartupConfigurationCmd;
       
   911 			}
       
   912 		TAny* param1 = NULL;
       
   913 		TPtrC name;
       
   914 		if(GET_OPTIONAL_STRING_PARAMETER(KParam1(), aSection, name))
       
   915 			{
       
   916 			param1 = GetDataObjectL(name);
       
   917 			}
       
   918 		TAny* param2 = NULL;
       
   919 
       
   920 		if(GET_OPTIONAL_STRING_PARAMETER(KParam2(), aSection, name))
       
   921 			{		
       
   922 			param2 = GetDataObjectL(name);
       
   923 			}
       
   924 		//call SetStartupConfiguration
       
   925 		TInt err = iFs->SetStartupConfiguration(configCommand, param1, param2);
       
   926 		INFO_PRINTF2(_L("RFs::SetStartupConfiguration() %S"), &commandNum);
       
   927 		// check error code
       
   928 		if (err != KErrNone)
       
   929 			{
       
   930 			ERR_PRINTF2(_L("SetStartupConfiguration() error: %d"), err);
       
   931 			SetError(err);
       
   932 			}
       
   933 		}
       
   934 	}
       
   935 
       
   936 void CT_FsData::DoCmdAddCompositeMount(const TDesC& aSection)
       
   937 	{
       
   938 	INFO_PRINTF1(_L("Calls RFs::AddCompositeMount()"));
       
   939 
       
   940 	TBool dataOk = ETrue;
       
   941 
       
   942 	// get drive number from parameters
       
   943 	TDriveNumber	localDriveToMount = EDriveA;
       
   944 	if (!GetDriveNumberFromConfig(aSection, KLocalDrive(), localDriveToMount))
       
   945 		{
       
   946 		ERR_PRINTF2(_L("No %S"), &KLocalDrive());
       
   947 		SetBlockResult(EFail);
       
   948 		dataOk = EFalse;
       
   949 		}
       
   950 
       
   951 	// get composite drive number from parameters
       
   952 	TDriveNumber	compositeDrive = EDriveA;
       
   953 	if (!GetDriveNumberFromConfig(aSection, KCompositeDrive(), compositeDrive))
       
   954 		{
       
   955 		ERR_PRINTF2(_L("No %S"), &KCompositeDrive());
       
   956 		SetBlockResult(EFail);
       
   957 		dataOk = EFalse;
       
   958 		}
       
   959 
       
   960 	// 	get Sync from parameters
       
   961 	TBool	sync = EFalse;
       
   962 	if(!GET_MANDATORY_BOOL_PARAMETER(KIsSync(), aSection, sync))
       
   963 		{
       
   964 		dataOk = EFalse;
       
   965 		}
       
   966 
       
   967 	// get fileSystemName from parameters
       
   968 	TPtrC	fileSystemName;
       
   969 	if ( !GET_OPTIONAL_STRING_PARAMETER(KFileSystemName(), aSection, fileSystemName) )
       
   970 		{
       
   971 		fileSystemName.Set(iFileSystemName);
       
   972 		}
       
   973 
       
   974 	if(dataOk)
       
   975 		{
       
   976 		TInt	err = iFs->AddCompositeMount(fileSystemName, localDriveToMount, compositeDrive, sync);
       
   977 		INFO_PRINTF1(_L("Calls RFs::AddCompositeMount()"));
       
   978 		// check error code
       
   979 		if (err != KErrNone)
       
   980 			{
       
   981 			ERR_PRINTF2(_L("AddCompositeMount() error: %d"), err);
       
   982 			SetError(err);
       
   983 			}
       
   984 		}
       
   985 	}
       
   986 void CT_FsData::DoCmdStartupInitCompleteL(TInt aAsyncErrorIndex)
       
   987 /** Calls RFs::StartupInitComplete() */
       
   988 	{
       
   989 	INFO_PRINTF1(_L("Calls RFs::StartupInitComplete()"));
       
   990 
       
   991 	// call StartupInitComplete()
       
   992 	CActiveCallback*	active = CActiveCallback::NewLC(*this);
       
   993 	iStartupInitComplete.AppendL(active);
       
   994 	CleanupStack::Pop(active);
       
   995 		
       
   996 	iFs->StartupInitComplete(active->iStatus);
       
   997 	active->Activate(aAsyncErrorIndex);
       
   998 	IncOutstanding();
       
   999 	}
       
  1000 
       
  1001 
       
  1002 void CT_FsData::DoCmdFinaliseDrives()
       
  1003 /** Calls RFs::FinaliseDrives() */
       
  1004 	{
       
  1005 	INFO_PRINTF1(_L("Calls RFs::FinaliseDrives()"));
       
  1006 
       
  1007 	TInt err = iFs->FinaliseDrives();
       
  1008 
       
  1009 	// check error code
       
  1010 	if (err != KErrNone)
       
  1011 		{
       
  1012 		ERR_PRINTF2(_L("FinaliseDrives() error: %d"), err);
       
  1013 		SetError(err);
       
  1014 		}
       
  1015 	}
       
  1016 
       
  1017 
       
  1018 void CT_FsData::DoCmdSetLocalDriveMappingL(const TDesC& aSection)
       
  1019 /** Calls RFs::SetLocalDriveMapping() */
       
  1020 	{
       
  1021 	INFO_PRINTF1(_L("Calls RFs::SetLocalDriveMapping()"));
       
  1022 
       
  1023 	// get operation from config	
       
  1024 	TLocalDriveMappingInfo::TDrvMapOperation operation = TLocalDriveMappingInfo::EWriteMappingsAndSet;
       
  1025 	if (!GetDrvMapOperationFromConfig(aSection, KDriveMappingOperation(), operation))
       
  1026 		{
       
  1027 		ERR_PRINTF2(_L("No %S"), &KDriveMappingOperation());
       
  1028 		SetBlockResult(EFail);
       
  1029 		}
       
  1030 		
       
  1031 	// create an info buffer and set the operation
       
  1032 	TLocalDriveMappingInfoBuf infoBuf;
       
  1033 	TLocalDriveMappingInfo& info = infoBuf();
       
  1034 	info.iOperation = operation;
       
  1035 
       
  1036 	// get drive mapping array from config
       
  1037 	TInt driveMappingSize = 0;
       
  1038 	if (GET_MANDATORY_INT_PARAMETER(KDriveMappingSize(), aSection, driveMappingSize))
       
  1039 		{
       
  1040 		for(TInt i = 0; i < driveMappingSize; i++)
       
  1041 			{
       
  1042 			TBuf<KBufferStringLength> tmpBuff;
       
  1043 
       
  1044 			tmpBuff.Append(KDriveMappingElement);
       
  1045 			tmpBuff.AppendNum(i);
       
  1046 
       
  1047 			TDriveNumber driveNumber;
       
  1048 			if (GetDriveNumberFromConfig(aSection, tmpBuff, driveNumber))
       
  1049 				{
       
  1050 				info.iDriveMapping[i] = driveNumber;
       
  1051 				INFO_PRINTF3(_L("Drive mapping element[%d] = %d"), i, driveNumber);
       
  1052 				}
       
  1053 			else
       
  1054 				{
       
  1055 				ERR_PRINTF2(_L("No %S"), &tmpBuff);
       
  1056 				SetBlockResult(EFail);
       
  1057 				}
       
  1058 			}
       
  1059 		}
       
  1060 
       
  1061 	// call SetLocalDriveMapping()
       
  1062 	TInt err = iFs->SetLocalDriveMapping(infoBuf);
       
  1063 
       
  1064 	// check error code
       
  1065 	if (err != KErrNone)
       
  1066 		{
       
  1067 		ERR_PRINTF2(_L("SetLocalDriveMapping() error: %d"), err);
       
  1068 		SetError(err);
       
  1069 		}
       
  1070 	}
       
  1071 
       
  1072 
       
  1073 void CT_FsData::DoCmdSwapFileSystem(const TDesC& aSection)
       
  1074 /** Calls RFs::SwapFileSystem() */
       
  1075 	{
       
  1076 	INFO_PRINTF1(_L("Calls RFs::SwapFileSystem()"));
       
  1077 
       
  1078 	//get OldFileSystemName
       
  1079 	// get fileSystemName from parameters
       
  1080 	TPtrC	fileSystemName;
       
  1081 	if ( !GET_OPTIONAL_STRING_PARAMETER(KFileSystemName(), aSection, fileSystemName) )
       
  1082 		{
       
  1083 		fileSystemName.Set(iFileSystemName);
       
  1084 		}
       
  1085 
       
  1086 	//get NewFileSystemName
       
  1087 	TPtrC newFsName;
       
  1088 	if(!GET_OPTIONAL_STRING_PARAMETER(KNewFileSystemName(), aSection, newFsName))
       
  1089 		{
       
  1090 		newFsName.Set(iFileSystemName);
       
  1091 		}
       
  1092 
       
  1093 	// get drive number from parameters
       
  1094 	TBool dataOk = ETrue;
       
  1095 	TDriveNumber	driveNumber = EDriveA;
       
  1096 	if (!GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
       
  1097 		{
       
  1098 		ERR_PRINTF2(_L("No %S"), &KDrive());
       
  1099 		SetBlockResult(EFail);
       
  1100 		dataOk = EFalse;
       
  1101 		}
       
  1102 
       
  1103 	if(dataOk)
       
  1104 		{
       
  1105 		TInt err = iFs->SwapFileSystem(fileSystemName, newFsName, driveNumber);
       
  1106 		// check error code
       
  1107 		if (err != KErrNone)
       
  1108 			{
       
  1109 			ERR_PRINTF2(_L("SwapFileSystem() error: %d"), err);
       
  1110 			SetError(err);
       
  1111 			}
       
  1112 		}
       
  1113 
       
  1114 	}
       
  1115 
       
  1116 void CT_FsData::DoCmdFileSystemSubType(const TDesC& aSection)
       
  1117 	{
       
  1118 	INFO_PRINTF1(_L("Calls RFs::FileSystemSubType()"));
       
  1119 
       
  1120 	// get drive number from parameters
       
  1121 	TDriveNumber	driveNumber = EDriveA;
       
  1122 	if (GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
       
  1123 		{
       
  1124 		TFSName subTypeName;
       
  1125 		TInt err = iFs->FileSystemSubType(driveNumber, subTypeName);
       
  1126 		// check error code
       
  1127 		if (err != KErrNone)
       
  1128 			{
       
  1129 			ERR_PRINTF2(_L("FileSystemSubType() error: %d"), err);
       
  1130 			SetError(err);
       
  1131 			}
       
  1132 		else
       
  1133 			{
       
  1134 			INFO_PRINTF2(_L("FileSystemSubType() subTypeName = %S"), &subTypeName);
       
  1135 			//Check expected result
       
  1136 			TPtrC	subTypeNameExpect;
       
  1137 			if (GET_OPTIONAL_STRING_PARAMETER(KSubTypeName(), aSection, subTypeNameExpect))
       
  1138 				{
       
  1139 				if ( subTypeNameExpect != subTypeName)
       
  1140 					{
       
  1141 					ERR_PRINTF1(_L("File system name != expected name"));
       
  1142 					SetBlockResult(EFail);
       
  1143 					}
       
  1144 				}
       
  1145 			}
       
  1146 		}
       
  1147 	else
       
  1148 		{
       
  1149 		ERR_PRINTF2(_L("No %S"), &KDrive());
       
  1150 		SetBlockResult(EFail);
       
  1151 		}
       
  1152 	}
       
  1153 
       
  1154 TBool CT_FsData::GetDriveNumberFromConfig(const TDesC& aSection, const TDesC& aParameterName, TDriveNumber& aDriveNumber)
       
  1155 /** Reads drive number from INI-file */
       
  1156 	{
       
  1157 	// Read drive number from INI file
       
  1158 	TPtrC	driveNumberStr;
       
  1159 	TBool	ret = GET_OPTIONAL_STRING_PARAMETER(aParameterName, aSection, driveNumberStr);
       
  1160 	if (ret)
       
  1161 		{
       
  1162 		if (driveNumberStr == KDriveA)
       
  1163 			{
       
  1164 			aDriveNumber = EDriveA;
       
  1165 			}
       
  1166 		else if (driveNumberStr == KDriveB)
       
  1167 			{
       
  1168 			aDriveNumber = EDriveB;
       
  1169 			}
       
  1170 		else if (driveNumberStr == KDriveC)
       
  1171 			{
       
  1172 			aDriveNumber = EDriveC;
       
  1173 			}
       
  1174 		else if (driveNumberStr == KDriveD)
       
  1175 			{
       
  1176 			aDriveNumber = EDriveD;
       
  1177 			}
       
  1178 		else if (driveNumberStr == KDriveE)
       
  1179 			{
       
  1180 			aDriveNumber = EDriveE;
       
  1181 			}
       
  1182 		else if (driveNumberStr == KDriveF)
       
  1183 			{
       
  1184 			aDriveNumber = EDriveF;
       
  1185 			}
       
  1186 		else if (driveNumberStr == KDriveG)
       
  1187 			{
       
  1188 			aDriveNumber = EDriveG;
       
  1189 			}
       
  1190 		else if (driveNumberStr == KDriveH)
       
  1191 			{
       
  1192 			aDriveNumber = EDriveH;
       
  1193 			}
       
  1194 		else if (driveNumberStr == KDriveI)
       
  1195 			{
       
  1196 			aDriveNumber = EDriveI;
       
  1197 			}
       
  1198 		else if (driveNumberStr == KDriveJ)
       
  1199 			{
       
  1200 			aDriveNumber = EDriveJ;
       
  1201 			}
       
  1202 		else if (driveNumberStr == KDriveK)
       
  1203 			{
       
  1204 			aDriveNumber = EDriveK;
       
  1205 			}
       
  1206 		else if (driveNumberStr == KDriveL)
       
  1207 			{
       
  1208 			aDriveNumber = EDriveL;
       
  1209 			}
       
  1210 		else if (driveNumberStr == KDriveM)
       
  1211 			{
       
  1212 			aDriveNumber = EDriveM;
       
  1213 			}
       
  1214 		else if (driveNumberStr == KDriveN)
       
  1215 			{
       
  1216 			aDriveNumber = EDriveN;
       
  1217 			}
       
  1218 		else if (driveNumberStr == KDriveO)
       
  1219 			{
       
  1220 			aDriveNumber = EDriveO;
       
  1221 			}
       
  1222 		else if (driveNumberStr == KDriveP) // Sorry, it's a bit long. But looks nice!
       
  1223 			{
       
  1224 			aDriveNumber = EDriveP;
       
  1225 			}
       
  1226 		else if (driveNumberStr == KDriveQ)
       
  1227 			{
       
  1228 			aDriveNumber = EDriveQ;
       
  1229 			}
       
  1230 		else if (driveNumberStr == KDriveR)
       
  1231 			{
       
  1232 			aDriveNumber = EDriveR;
       
  1233 			}
       
  1234 		else if (driveNumberStr == KDriveS)
       
  1235 			{
       
  1236 			aDriveNumber = EDriveS;
       
  1237 			}
       
  1238 		else if (driveNumberStr == KDriveT)
       
  1239 			{
       
  1240 			aDriveNumber = EDriveT;
       
  1241 			}
       
  1242 		else if (driveNumberStr == KDriveU)
       
  1243 			{
       
  1244 			aDriveNumber = EDriveU;
       
  1245 			}
       
  1246 		else if (driveNumberStr == KDriveV)
       
  1247 			{
       
  1248 			aDriveNumber = EDriveV;
       
  1249 			}
       
  1250 		else if (driveNumberStr == KDriveW)
       
  1251 			{
       
  1252 			aDriveNumber = EDriveW;
       
  1253 			}
       
  1254 		else if (driveNumberStr == KDriveX)
       
  1255 			{
       
  1256 			aDriveNumber = EDriveX;
       
  1257 			}
       
  1258 		else if (driveNumberStr == KDriveY)
       
  1259 			{
       
  1260 			aDriveNumber = EDriveY;
       
  1261 			}
       
  1262 		else if (driveNumberStr == KDriveZ)
       
  1263 			{
       
  1264 			aDriveNumber = EDriveZ;
       
  1265 			}
       
  1266 		else
       
  1267 			{
       
  1268 			TInt driveNumber = 0;
       
  1269 			ret = GET_OPTIONAL_INT_PARAMETER(aParameterName, aSection, driveNumber);
       
  1270 			if (ret)
       
  1271 				{
       
  1272 				aDriveNumber = (TDriveNumber) driveNumber;
       
  1273 				}
       
  1274 			}
       
  1275 		}
       
  1276 
       
  1277 	return ret;
       
  1278 	}
       
  1279 
       
  1280 
       
  1281 TBool CT_FsData::GetDrvMapOperationFromConfig(const TDesC& aSection, const TDesC& aParameterName, TLocalDriveMappingInfo::TDrvMapOperation& aOperation)
       
  1282 /** Reads drive mapping operation name from INI-file */
       
  1283 	{
       
  1284 	// Read drives mapping operation name from INI file
       
  1285 	TPtrC operationStr;
       
  1286 	TBool ret = GET_OPTIONAL_STRING_PARAMETER(aParameterName, aSection, operationStr);
       
  1287 	if (ret)
       
  1288 		{
       
  1289 		if (operationStr == KWriteMappingsAndSet)
       
  1290 			{
       
  1291 			aOperation = TLocalDriveMappingInfo::EWriteMappingsAndSet;
       
  1292 			}
       
  1293 		else if (operationStr == KWriteMappingsNoSet)
       
  1294 			{
       
  1295 			aOperation = TLocalDriveMappingInfo::EWriteMappingsNoSet;
       
  1296 			}
       
  1297 		else if (operationStr == KSwapIntMappingAndSet)
       
  1298 			{
       
  1299 			aOperation = TLocalDriveMappingInfo::ESwapIntMappingAndSet;
       
  1300 			}
       
  1301 		else
       
  1302 			{
       
  1303 			TInt operation = 0;
       
  1304 			ret = GET_OPTIONAL_INT_PARAMETER(aParameterName, aSection, operation);
       
  1305 			if (ret)
       
  1306 				{
       
  1307 				aOperation = (TLocalDriveMappingInfo::TDrvMapOperation) operation;
       
  1308 				}
       
  1309 			}
       
  1310 		}
       
  1311 
       
  1312 	return ret;
       
  1313 	}
       
  1314