kerneltest/f32test/shostmassstorage/testclient/usbtestmsclient/cmassstoragemountcb.cpp
changeset 297 b2826f67641f
parent 90 947f0dc9f7a8
equal deleted inserted replaced
296:94f2adf59133 297:b2826f67641f
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 // CMassStorageMountCB implementation.
    14 // CMassStorageMountCB implementation.
    15 // 
    15 //
    16 //
    16 //
    17 
    17 
    18 
    18 
    19 
    19 
    20 /**
    20 /**
    35 #include "cmassstoragemountcb.h"
    35 #include "cmassstoragemountcb.h"
    36 #include "debug.h"
    36 #include "debug.h"
    37 
    37 
    38 CMassStorageMountCB::CMassStorageMountCB(const TLunToDriveMap& aDriveMapping)
    38 CMassStorageMountCB::CMassStorageMountCB(const TLunToDriveMap& aDriveMapping)
    39 :   iDriveMapping(aDriveMapping)
    39 :   iDriveMapping(aDriveMapping)
    40 	{
    40     {
    41 	}
    41     }
    42 
    42 
    43 CMassStorageMountCB* CMassStorageMountCB::NewL(const TLunToDriveMap& aDriveMapping)
    43 CMassStorageMountCB* CMassStorageMountCB::NewL(const TLunToDriveMap& aDriveMapping)
    44 	{
    44     {
    45 	return new (ELeave) CMassStorageMountCB(aDriveMapping);
    45     return new (ELeave) CMassStorageMountCB(aDriveMapping);
    46 	}
    46     }
    47 
    47 
    48 /**
    48 /**
    49 Checks that the drive number is supported.
    49 Checks that the drive number is supported.
    50 
    50 
    51 @leave KErrNotReady The drive number is not supported.
    51 @leave KErrNotReady The drive number is not supported.
    52 */
    52 */
    53 TInt CMassStorageMountCB::CheckDriveNumberL()
    53 TInt CMassStorageMountCB::CheckDriveNumberL()
    54 	{
    54     {
    55 	__FNLOG("CMassStorageMountCB::CheckDriveNumberL");
    55     TInt driveNumber;
    56 	TInt driveNumber;
    56     driveNumber = Drive().DriveNumber();
    57 	driveNumber = Drive().DriveNumber();
    57     if (!IsValidLocalDriveMapping(driveNumber))
    58 	if (!IsValidLocalDriveMapping(driveNumber))
    58         {
    59 		{
    59         __PRINT1(_L("CMassStorageMountCB::CheckDriveNumberL: Drive number %d not supported"), driveNumber);
    60 		__PRINT1(_L("CMassStorageMountCB::CheckDriveNumberL: Drive number %d not supported"), driveNumber);
    60         User::Leave(KErrNotReady);
    61 		User::Leave(KErrNotReady);
    61         }
    62 		}
    62     __PRINT1(_L("CMassStorageMountCB::CheckDriveNumberL: Drive number = %d"), driveNumber);
    63 	__PRINT1(_L("CMassStorageMountCB::CheckDriveNumberL: Drive number = %d"), driveNumber);
    63     return driveNumber;
    64 	return driveNumber;
    64     }
    65 	}
       
    66 
    65 
    67 /**
    66 /**
    68 Registers the drive with the Mass Storage drive manager.
    67 Registers the drive with the Mass Storage drive manager.
    69 
    68 
    70 @leave KErrNotSupported The drive is not compatible with Mass Storage.
    69 @leave KErrNotSupported The drive is not compatible with Mass Storage.
    71 */
    70 */
    72 void CMassStorageMountCB::MountL(TBool /*aForceMount*/)
    71 void CMassStorageMountCB::MountL(TBool /*aForceMount*/)
    73 	{
    72     {
    74 	__FNLOG("CMassStorageMountCB::MountL");
    73     CheckDriveNumberL();
    75 
    74     CMassStorageFileSystem& msFsys = *reinterpret_cast<CMassStorageFileSystem*>(Drive().GetFSys());
    76 	CheckDriveNumberL();
    75 
    77 	CMassStorageFileSystem& msFsys = *reinterpret_cast<CMassStorageFileSystem*>(Drive().GetFSys());
    76     TInt lun = DriveNumberToLun(Drive().DriveNumber());
    78 
    77 
    79 	TInt lun = DriveNumberToLun(Drive().DriveNumber());
    78     if(lun < 0)
    80 
    79         {
    81 	if(lun < 0)
    80         // This is not a supported Mass Storage drive
    82 		{
    81         User::Leave(KErrNotSupported);
    83 		// This is not a supported Mass Storage drive
    82         }
    84 		User::Leave(KErrNotSupported);
    83 
    85 		}
    84     TBusLocalDrive& localDrive = msFsys.iMediaChangedStatusList[lun].iLocalDrive;
    86 
    85 
    87 	TBusLocalDrive& localDrive = msFsys.iMediaChangedStatusList[lun].iLocalDrive;
    86     TInt err = CreateLocalDrive(localDrive);
    88 
    87     User::LeaveIfError(err);
    89 	TInt err = CreateLocalDrive(localDrive);
    88 
    90 	User::LeaveIfError(err);
    89     CProxyDrive* proxyDrive = LocalDrive();
    91 
    90 
    92 	CProxyDrive* proxyDrive = LocalDrive();
    91     TLocalDriveCapsV2Buf caps;
    93 
    92     err = localDrive.Caps(caps);
    94 	TLocalDriveCapsV2Buf caps;
    93 
    95 	err = localDrive.Caps(caps);
    94     //Make sure file system is FAT and removable
    96 
    95     if (err == KErrNone)
    97 	//Make sure file system is FAT and removable
    96         {
    98 	if (err == KErrNone)
    97         err = KErrNotSupported;
    99 		{
    98         if ((caps().iDriveAtt & KDriveAttRemovable) == KDriveAttRemovable)
   100 		err = KErrNotSupported;
    99             {
   101 		if ((caps().iDriveAtt & KDriveAttRemovable) == KDriveAttRemovable)
   100             if (caps().iType != EMediaNotPresent)
   102 			{
   101                 {
   103 			if (caps().iType != EMediaNotPresent)
   102                 err = KErrNone;
   104 				{
   103                 }
   105 				err = KErrNone;
   104             }
   106 				}
   105         }
   107 			}
   106 
   108 		}
   107     if (err != KErrNone && err != KErrNotReady)
   109 
   108         {
   110 	if (err != KErrNone && err != KErrNotReady)
   109         __PRINT1(_L("CMassStorageMountCB::MountL: Drive is not compatible with Mass Storage, err=%d"), err);
   111 		{
   110         User::Leave(err);
   112 		__PRINT1(_L("CMassStorageMountCB::MountL: Drive is not compatible with Mass Storage, err=%d"), err);
   111         }
   113 		User::Leave(err);
   112 
   114 		}
   113     __PRINT(_L("CMassStorageMountCB::MountL: Registering drive"));
   115 
   114     // Set media changed to true so that Win2K doesn't used cached drive data
   116 	__PRINT(_L("CMassStorageMountCB::MountL: Registering drive"));
   115     TBool& mediaChanged = msFsys.iMediaChangedStatusList[lun].iMediaChanged;
   117 	// Set media changed to true so that Win2K doesn't used cached drive data
       
   118 	TBool& mediaChanged = msFsys.iMediaChangedStatusList[lun].iMediaChanged;
       
   119     mediaChanged = ETrue;
   116     mediaChanged = ETrue;
   120 	msFsys.Controller().DriveManager().RegisterDriveL(*proxyDrive, mediaChanged, lun);
   117     msFsys.Controller().DriveManager().RegisterDriveL(*proxyDrive, mediaChanged, lun);
   121 	SetVolumeName(_L("MassStorage").AllocL());
   118     SetVolumeName(_L("MassStorage").AllocL());
   122 	}
   119     }
   123 
   120 
   124 /**
   121 /**
   125 Returns the LUN that corresponds to the specified drive number.
   122 Returns the LUN that corresponds to the specified drive number.
   126 
   123 
   127 @param aDriveNumber The drive number.
   124 @param aDriveNumber The drive number.
   128 */
   125 */
   129 TInt CMassStorageMountCB::DriveNumberToLun(TInt aDriveNumber)
   126 TInt CMassStorageMountCB::DriveNumberToLun(TInt aDriveNumber)
   130 	{
   127     {
   131 	__FNLOG("CMassStorageMountCB::DriveNumberToLun");
   128     TInt lun = -1;
   132 	TInt lun = -1;
   129     for (TInt i = 0; i < iDriveMapping.Count(); i++)
   133 	for (TInt i = 0; i < iDriveMapping.Count(); i++)
   130         {
   134 		{
   131         if (iDriveMapping[i] == aDriveNumber)
   135 		if (iDriveMapping[i] == aDriveNumber)
   132             {
   136 			{
   133             lun = i;
   137 			lun = i;
   134             break;
   138 			break;
   135             }
   139 			}
   136         }
   140 		}
   137     __PRINT2(_L("CMassStorageMountCB::DriveNumberToLun: Drive %d maps to LUN %d"), aDriveNumber, lun);
   141 	__PRINT2(_L("CMassStorageMountCB::DriveNumberToLun: Drive %d maps to LUN %d"), aDriveNumber, lun);
   138     return lun;
   142 	return lun;
   139     }
   143 	}
       
   144 
   140 
   145 /**
   141 /**
   146 Deregisters the drive from the Drive Manager.
   142 Deregisters the drive from the Drive Manager.
   147 */
   143 */
   148 void CMassStorageMountCB::Dismounted()
   144 void CMassStorageMountCB::Dismounted()
   149 	{
   145     {
   150 	__FNLOG("CMassStorageMountCB::Dismounted");
   146     TInt driveNumber = -1;
   151 	TInt driveNumber = -1;
   147     TRAPD(err, driveNumber = CheckDriveNumberL());
   152 	TRAPD(err, driveNumber = CheckDriveNumberL());
   148     if (err != KErrNone)
   153 	if (err != KErrNone)
   149         {
   154 		{
   150         return;
   155 		return;
   151         }
   156 		}
   152     __PRINT(_L("CMassStorageMountCB::Dismounted: Deregistering drive"));
   157 	__PRINT(_L("CMassStorageMountCB::Dismounted: Deregistering drive"));
       
   158     CMassStorageFileSystem& msFsys = *reinterpret_cast<CMassStorageFileSystem*>(Drive().GetFSys());
   153     CMassStorageFileSystem& msFsys = *reinterpret_cast<CMassStorageFileSystem*>(Drive().GetFSys());
   159 	msFsys.Controller().DriveManager().DeregisterDrive(DriveNumberToLun(driveNumber));
   154     msFsys.Controller().DriveManager().DeregisterDrive(DriveNumberToLun(driveNumber));
   160 
   155 
   161 	DismountedLocalDrive();
   156     DismountedLocalDrive();
   162 	}
   157     }
   163 
   158 
   164 /**
   159 /**
   165 Unlocks the drive with the specified password, optionally storing the password for later use.
   160 Unlocks the drive with the specified password, optionally storing the password for later use.
   166 
   161 
   167 @param aPassword The password to use for unlocking the drive.
   162 @param aPassword The password to use for unlocking the drive.
   168 @param aStore True if the password is to be stored.
   163 @param aStore True if the password is to be stored.
   169 */
   164 */
   170 TInt CMassStorageMountCB::Unlock(TMediaPassword& aPassword, TBool aStore)
   165 TInt CMassStorageMountCB::Unlock(TMediaPassword& aPassword, TBool aStore)
   171 	{
   166     {
   172 	__FNLOG("CMassStorageMountCB::Unlock");
   167     TInt driveNumber = -1;
   173 	TInt driveNumber = -1;
   168     TRAPD(err, driveNumber = CheckDriveNumberL());
   174 	TRAPD(err, driveNumber = CheckDriveNumberL());
   169     if (err != KErrNone)
   175 	if (err != KErrNone)
   170         {
   176 		{
   171         return err;
   177 		return err;
   172         }
   178 		}
   173     TBusLocalDrive& localDrive=GetLocalDrive(driveNumber);
   179 	TBusLocalDrive& localDrive=GetLocalDrive(driveNumber);
   174     if(localDrive.Status() == KErrLocked)
   180 	if(localDrive.Status() == KErrLocked)
   175         {
   181 		{
   176         localDrive.Status() = KErrNotReady;
   182 		localDrive.Status() = KErrNotReady;
   177         }
   183 		}
   178     TInt r = localDrive.Unlock(aPassword, aStore);
   184 	TInt r = localDrive.Unlock(aPassword, aStore);
   179     if(r == KErrNone && aStore)
   185 	if(r == KErrNone && aStore)
   180         {
   186 		{
   181         WritePasswordData();
   187 		WritePasswordData();
   182         }
   188 		}
   183     return(r);
   189 	return(r);
   184     }
   190 	}
       
   191 
   185 
   192 /**
   186 /**
   193 Stores the password for the drive to the password file.
   187 Stores the password for the drive to the password file.
   194 */
   188 */
   195 void CMassStorageMountCB::WritePasswordData()
   189 void CMassStorageMountCB::WritePasswordData()
   196 	{
   190     {
   197 	__FNLOG("CMassStorageMountCB::WritePasswordData");
   191     TBusLocalDrive& local=GetLocalDrive(Drive().DriveNumber());
   198 	TBusLocalDrive& local=GetLocalDrive(Drive().DriveNumber());
   192     TInt length = local.PasswordStoreLengthInBytes();
   199 	TInt length = local.PasswordStoreLengthInBytes();
   193     if(length==0)
   200 	if(length==0)
   194         {
   201 		{
   195         TBuf<sizeof(KMediaPWrdFile)> mediaPWrdFile(KMediaPWrdFile);
   202 		TBuf<sizeof(KMediaPWrdFile)> mediaPWrdFile(KMediaPWrdFile);
   196         mediaPWrdFile[0] = (TUint8) RFs::GetSystemDriveChar();
   203 		mediaPWrdFile[0] = (TUint8) RFs::GetSystemDriveChar();
   197         WriteToDisk(mediaPWrdFile,_L8(""));
   204 		WriteToDisk(mediaPWrdFile,_L8(""));
   198         return;
   205 		return;
   199         }
   206 		}
   200     HBufC8* hDes=HBufC8::New(length);
   207 	HBufC8* hDes=HBufC8::New(length);
   201     if(hDes==NULL)
   208 	if(hDes==NULL)
   202         {
   209 		{
   203         return;
   210 		return;
   204         }
   211 		}
   205     TPtr8 pDes=hDes->Des();
   212 	TPtr8 pDes=hDes->Des();
   206     TInt r=local.ReadPasswordData(pDes);
   213 	TInt r=local.ReadPasswordData(pDes);
   207     if(r==KErrNone)
   214 	if(r==KErrNone)
   208         {
   215 		{
   209         TBuf<sizeof(KMediaPWrdFile)> mediaPWrdFile(KMediaPWrdFile);
   216 		TBuf<sizeof(KMediaPWrdFile)> mediaPWrdFile(KMediaPWrdFile);
   210         mediaPWrdFile[0] = (TUint8) RFs::GetSystemDriveChar();
   217 		mediaPWrdFile[0] = (TUint8) RFs::GetSystemDriveChar();
   211         WriteToDisk(mediaPWrdFile,pDes);
   218 		WriteToDisk(mediaPWrdFile,pDes);
   212         }
   219 		}
   213     delete hDes;
   220 	delete hDes;
   214     }
   221 	}
       
   222 
   215 
   223 
   216 
   224 TInt CMassStorageMountCB::ReMount()
   217 TInt CMassStorageMountCB::ReMount()
   225 	{
   218     {
   226     RDebug::Printf("CMassStorageMountCB::ReMount()");
   219     RDebug::Printf("CMassStorageMountCB::ReMount()");
   227 	return KErrNotReady;
   220     return KErrNotReady;
   228 	}
   221     }
   229 
   222 
   230 void CMassStorageMountCB::VolumeL(TVolumeInfo& /*aVolume*/) const
   223 void CMassStorageMountCB::VolumeL(TVolumeInfo& /*aVolume*/) const
   231 	{
   224     {
   232 	User::Leave(KErrNotReady);
   225     User::Leave(KErrNotReady);
   233 	}
   226     }
   234 
   227 
   235 void CMassStorageMountCB::SetVolumeL(TDes& /*aName*/)
   228 void CMassStorageMountCB::SetVolumeL(TDes& /*aName*/)
   236 	{
   229     {
   237 	User::Leave(KErrNotReady);
   230     User::Leave(KErrNotReady);
   238 	}
   231     }
   239 
   232 
   240 void CMassStorageMountCB::MkDirL(const TDesC& /*aName*/)
   233 void CMassStorageMountCB::MkDirL(const TDesC& /*aName*/)
   241 	{
   234     {
   242 	User::Leave(KErrNotReady);
   235     User::Leave(KErrNotReady);
   243 	}
   236     }
   244 
   237 
   245 void CMassStorageMountCB::RmDirL(const TDesC& /*aName*/)
   238 void CMassStorageMountCB::RmDirL(const TDesC& /*aName*/)
   246 	{
   239     {
   247 	User::Leave(KErrNotReady);
   240     User::Leave(KErrNotReady);
   248 	}
   241     }
   249 
   242 
   250 void CMassStorageMountCB::DeleteL(const TDesC& /*aName*/)
   243 void CMassStorageMountCB::DeleteL(const TDesC& /*aName*/)
   251 	{
   244     {
   252 	User::Leave(KErrNotReady);
   245     User::Leave(KErrNotReady);
   253 	}
   246     }
   254 
   247 
   255 void CMassStorageMountCB::RenameL(const TDesC& /*anOldName*/,const TDesC& /*anNewName*/)
   248 void CMassStorageMountCB::RenameL(const TDesC& /*anOldName*/,const TDesC& /*anNewName*/)
   256 	{
   249     {
   257 	User::Leave(KErrNotReady);
   250     User::Leave(KErrNotReady);
   258 	}
   251     }
   259 
   252 
   260 void CMassStorageMountCB::ReplaceL(const TDesC& /*anOldName*/,const TDesC& /*anNewName*/)
   253 void CMassStorageMountCB::ReplaceL(const TDesC& /*anOldName*/,const TDesC& /*anNewName*/)
   261 	{
   254     {
   262 	User::Leave(KErrNotReady);
   255     User::Leave(KErrNotReady);
   263 	}
   256     }
   264 
   257 
   265 void CMassStorageMountCB::EntryL(const TDesC& /*aName*/,TEntry& /*anEntry*/) const
   258 void CMassStorageMountCB::EntryL(const TDesC& /*aName*/,TEntry& /*anEntry*/) const
   266 	{
   259     {
   267 	User::Leave(KErrNotReady);
   260     User::Leave(KErrNotReady);
   268 	}
   261     }
   269 
   262 
   270 void CMassStorageMountCB::SetEntryL(const TDesC& /*aName*/,const TTime& /*aTime*/,TUint /*aSetAttMask*/,TUint /*aClearAttMask*/)
   263 void CMassStorageMountCB::SetEntryL(const TDesC& /*aName*/,const TTime& /*aTime*/,TUint /*aSetAttMask*/,TUint /*aClearAttMask*/)
   271 	{
   264     {
   272 	User::Leave(KErrNotReady);
   265     User::Leave(KErrNotReady);
   273 	}
   266     }
   274 
   267 
   275 void CMassStorageMountCB::FileOpenL(const TDesC& /*aName*/,TUint /*aMode*/,TFileOpen /*anOpen*/,CFileCB* /*aFile*/)
   268 void CMassStorageMountCB::FileOpenL(const TDesC& /*aName*/,TUint /*aMode*/,TFileOpen /*anOpen*/,CFileCB* /*aFile*/)
   276 	{
   269     {
   277 	User::Leave(KErrNotReady);
   270     User::Leave(KErrNotReady);
   278 	}
   271     }
   279 
   272 
   280 void CMassStorageMountCB::DirOpenL(const TDesC& /*aName*/,CDirCB* /*aDir*/)
   273 void CMassStorageMountCB::DirOpenL(const TDesC& /*aName*/,CDirCB* /*aDir*/)
   281 	{
   274     {
   282 	User::Leave(KErrNotReady);
   275     User::Leave(KErrNotReady);
   283 	}
   276     }
   284 
   277 
   285 
   278 
   286 void CMassStorageMountCB::RawReadL(TInt64 /*aPos*/,TInt /*aLength*/,const TAny* /*aTrg*/,TInt /*anOffset*/,const RMessagePtr2& /*aMessage*/) const
   279 void CMassStorageMountCB::RawReadL(TInt64 /*aPos*/,TInt /*aLength*/,const TAny* /*aTrg*/,TInt /*anOffset*/,const RMessagePtr2& /*aMessage*/) const
   287 	{
   280     {
   288 	User::Leave(KErrNotReady);
   281     User::Leave(KErrNotReady);
   289 	}
   282     }
   290 
   283 
   291 void CMassStorageMountCB::RawWriteL(TInt64 /*aPos*/,TInt /*aLength*/,const TAny* /*aSrc*/,TInt /*anOffset*/,const RMessagePtr2& /*aMessage*/)
   284 void CMassStorageMountCB::RawWriteL(TInt64 /*aPos*/,TInt /*aLength*/,const TAny* /*aSrc*/,TInt /*anOffset*/,const RMessagePtr2& /*aMessage*/)
   292 	{
   285     {
   293 	User::Leave(KErrNotReady);
   286     User::Leave(KErrNotReady);
   294 	}
   287     }
   295 
   288 
   296 
   289 
   297 void CMassStorageMountCB::GetShortNameL(const TDesC& /*aLongName*/,TDes& /*aShortName*/)
   290 void CMassStorageMountCB::GetShortNameL(const TDesC& /*aLongName*/,TDes& /*aShortName*/)
   298 	{
   291     {
   299 	User::Leave(KErrNotReady);
   292     User::Leave(KErrNotReady);
   300 	}
   293     }
   301 
   294 
   302 void CMassStorageMountCB::GetLongNameL(const TDesC& /*aShorName*/,TDes& /*aLongName*/)
   295 void CMassStorageMountCB::GetLongNameL(const TDesC& /*aShorName*/,TDes& /*aLongName*/)
   303 	{
   296     {
   304 	User::Leave(KErrNotReady);
   297     User::Leave(KErrNotReady);
   305 	}
   298     }
   306 
   299 
   307 #if defined(_DEBUG)
   300 #if defined(_DEBUG)
   308 TInt CMassStorageMountCB::ControlIO(const RMessagePtr2& aMessage,TInt aCommand,TAny* aParam1,TAny* aParam2)
   301 TInt CMassStorageMountCB::ControlIO(const RMessagePtr2& aMessage,TInt aCommand,TAny* aParam1,TAny* aParam2)
   309 //
   302 //
   310 // Debug function
   303 // Debug function
   311 //
   304 //
   312 	{
   305     {
   313 	if(aCommand>=(KMaxTInt/2))
   306     if(aCommand>=(KMaxTInt/2))
   314 		return LocalDrive()->ControlIO(aMessage,aCommand-(KMaxTInt/2),aParam1,aParam2);
   307         return LocalDrive()->ControlIO(aMessage,aCommand-(KMaxTInt/2),aParam1,aParam2);
   315 	else
   308     else
   316 		return KErrNotSupported;
   309         return KErrNotSupported;
   317 	}
   310     }
   318 #else
   311 #else
   319 TInt CMassStorageMountCB::ControlIO(const RMessagePtr2& /*aMessage*/,TInt /*aCommand*/,TAny* /*aParam1*/,TAny* /*aParam2*/)
   312 TInt CMassStorageMountCB::ControlIO(const RMessagePtr2& /*aMessage*/,TInt /*aCommand*/,TAny* /*aParam1*/,TAny* /*aParam2*/)
   320 	{return(KErrNotSupported);}
   313     {return(KErrNotSupported);}
   321 #endif
   314 #endif
   322 
   315 
   323 void CMassStorageMountCB::ReadSectionL(const TDesC& /*aName*/,TInt /*aPos*/,TAny* /*aTrg*/,TInt /*aLength*/,const RMessagePtr2& /*aMessage*/)
   316 void CMassStorageMountCB::ReadSectionL(const TDesC& /*aName*/,TInt /*aPos*/,TAny* /*aTrg*/,TInt /*aLength*/,const RMessagePtr2& /*aMessage*/)
   324 	{
   317     {
   325 	User::Leave(KErrNotReady);
   318     User::Leave(KErrNotReady);
   326 	}
   319     }
   327 
   320 
   328 /**
   321 /**
   329 Returns ETrue if aNum is a power of two
   322 Returns ETrue if aNum is a power of two
   330 */
   323 */
   331 TBool CMassStorageMountCB::IsPowerOfTwo(TInt aNum)
   324 TBool CMassStorageMountCB::IsPowerOfTwo(TInt aNum)
   332 	{
   325     {
   333 
   326 
   334 	if (aNum==0)
   327     if (aNum==0)
   335 		return(EFalse);
   328         return(EFalse);
   336 
   329 
   337 	while(aNum)
   330     while(aNum)
   338 		{
   331         {
   339 		if (aNum & 0x01)
   332         if (aNum & 0x01)
   340 			{
   333             {
   341 			if (aNum>>1)
   334             if (aNum>>1)
   342 				return EFalse;
   335                 return EFalse;
   343 			break;
   336             break;
   344 			}
   337             }
   345 		aNum>>=1;
   338         aNum>>=1;
   346 		}
   339         }
   347 	return ETrue;
   340     return ETrue;
   348 	}
   341     }
   349 
   342 
   350 /**
   343 /**
   351 Returns the position of the highest bit in aNum or -1 if aNum == 0
   344 Returns the position of the highest bit in aNum or -1 if aNum == 0
   352 */
   345 */
   353 TInt CMassStorageMountCB::Log2(TInt aNum)
   346 TInt CMassStorageMountCB::Log2(TInt aNum)
   354 	{
   347     {
   355 
   348 
   356 	TInt res=-1;
   349     TInt res=-1;
   357 	while(aNum)
   350     while(aNum)
   358 		{
   351         {
   359 		res++;
   352         res++;
   360 		aNum>>=1;
   353         aNum>>=1;
   361 		}
   354         }
   362 	return(res);
   355     return(res);
   363 	}
   356     }