os/kernelhwsrv/kerneltest/f32test/fsstress/t_remmnt.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/fsstress/t_remmnt.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,305 @@
     1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// f32test\fsstress\t_remmnt.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#if defined(_UNICODE)
    1.22 +#if !defined(UNICODE)
    1.23 +#define UNICODE
    1.24 +#endif
    1.25 +#endif
    1.26 +
    1.27 +/*
    1.28 +#define WIN32_LEAN_AND_MEAN
    1.29 +#pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union
    1.30 + #include <windows.h>
    1.31 +#pragma warning( default : 4201 ) // nonstandard extension used : nameless struct/union
    1.32 +#include <stdlib.h>
    1.33 +*/
    1.34 +#include <f32file.h>
    1.35 +#include <f32fsys.h>
    1.36 +#include <f32ver.h>
    1.37 +#include <e32twin.h>
    1.38 +#include <e32uid.h>
    1.39 +
    1.40 +#include "t_remfsy.h"
    1.41 +
    1.42 +
    1.43 +
    1.44 +LOCAL_C TInt GetMediaSize(TInt /*aDriveNumber*/,TInt64& /*aSize*/,TInt64& /*aFree*/)
    1.45 +//
    1.46 +// Return the size and free space on a drive.
    1.47 +//
    1.48 +	{
    1.49 +	return(KErrNone);
    1.50 +	}
    1.51 +
    1.52 +LOCAL_C TInt GetVolume(TInt /*aDriveNumber*/,TDes& aName,TUint& aUniqueID)
    1.53 +//
    1.54 +// Return the volume name and uniqueID.
    1.55 +//
    1.56 +	{
    1.57 +	aUniqueID=1234;
    1.58 +	aName=(_L("REMOTDRV"));
    1.59 +	return(KErrNone);	
    1.60 +	}
    1.61 +
    1.62 +
    1.63 +//////////////////////////////////////////////////////////////////////////
    1.64 +//								CRemoteMountCB							//
    1.65 +//////////////////////////////////////////////////////////////////////////	
    1.66 +
    1.67 +
    1.68 +CRemoteMountCB::CRemoteMountCB()
    1.69 +//
    1.70 +// Constructor
    1.71 +//
    1.72 +	{
    1.73 +	__DECLARE_NAME(_S("CRemoteMountCB"));
    1.74 +	}
    1.75 +
    1.76 +CRemoteMountCB::~CRemoteMountCB()
    1.77 +//
    1.78 +// Destructor
    1.79 +//
    1.80 +	{}
    1.81 +
    1.82 +void CRemoteMountCB::MountL(TBool /*aForceMount*/)
    1.83 +//
    1.84 +// Mount a media. Only allowed to leave with KErrNoMemory,KErrNotReady,KErrCorrupt,KErrUnknown.
    1.85 +//
    1.86 +	{
    1.87 +//	TInt64 s,f;
    1.88 +	TFileName driveName;
    1.89 +	TInt d=Drive().DriveNumber();
    1.90 +//	TInt driveNum=d;
    1.91 +	if (MapDrive(driveName,d))
    1.92 +		RFs::CharToDrive(driveName[0],d);
    1.93 +	//User::LeaveIfError(GetMediaSize(d,s,f));
    1.94 +	//if (driveNum==EDriveZ)
    1.95 +//		iSize=4*1048576;
    1.96 +//	else
    1.97 +		//iSize=s;
    1.98 +	iSize=4*1024*16;
    1.99 +	User::LeaveIfError(GetVolume(d,driveName,iUniqueID));
   1.100 +	HBufC* pN=driveName.AllocL();
   1.101 +	SetVolumeName(pN);
   1.102 +	}
   1.103 +
   1.104 +TInt CRemoteMountCB::ReMount()
   1.105 +//
   1.106 +// Try and remount this media.
   1.107 +//
   1.108 +	{
   1.109 +
   1.110 +	TFileName n;
   1.111 +	TInt d=Drive().DriveNumber();
   1.112 +	if (MapDrive(n,d))
   1.113 +		RFs::CharToDrive(n[0],d);
   1.114 +	TUint uniqueID;
   1.115 +	TInt r=GetVolume(d,n,uniqueID);
   1.116 +	if (r!=KErrNone)
   1.117 +		return(r);
   1.118 +	if (n==VolumeName() && uniqueID==iUniqueID)
   1.119 +		return(KErrNone);
   1.120 +	return(KErrGeneral);
   1.121 +	}
   1.122 +
   1.123 +void CRemoteMountCB::Dismounted()
   1.124 +//
   1.125 +//	Dummy implementation of a pure virtual function
   1.126 +//
   1.127 +	{}
   1.128 +
   1.129 +void CRemoteMountCB::VolumeL(TVolumeInfo& aVolume) const
   1.130 +//
   1.131 +// Return the volume info.
   1.132 +//
   1.133 +	{
   1.134 +	TInt64 s,f(0);
   1.135 +	TFileName n;
   1.136 +	TInt d=Drive().DriveNumber();
   1.137 +	TInt driveNum=d;
   1.138 +	if (MapDrive(n,d))
   1.139 +		RFs::CharToDrive(n[0],d);
   1.140 +	User::LeaveIfError(GetMediaSize(d,s,f));
   1.141 +	if (driveNum==EDriveZ)
   1.142 +		aVolume.iFree=0;
   1.143 +	else
   1.144 +		aVolume.iFree=f;
   1.145 +	}
   1.146 +
   1.147 +
   1.148 +void CRemoteMountCB::SetVolumeL(TDes& /*aName*/)
   1.149 +//
   1.150 +//	Set the volume label
   1.151 +//	Dummy implementation of a pure virtual function
   1.152 +//
   1.153 +	{}
   1.154 +
   1.155 +
   1.156 +void CRemoteMountCB::IsFileInRom(const TDesC& /*aName*/,TUint8*& /*aFileStart*/)
   1.157 +//
   1.158 +// Return the address of the file if it is in rom
   1.159 +//
   1.160 +	{}
   1.161 +
   1.162 +
   1.163 +
   1.164 +
   1.165 +void CRemoteMountCB::MkDirL(const TDesC& /*aName*/)
   1.166 +//
   1.167 +//	Make a directory
   1.168 +//	Dummy implementation of a pure virtual function
   1.169 +//
   1.170 +	{
   1.171 +	User::After(200000);	//	Wait 0.2 seconds
   1.172 +	}
   1.173 +
   1.174 +
   1.175 +void CRemoteMountCB::RmDirL(const TDesC& /*aName*/)
   1.176 +//
   1.177 +//	Remove a directory
   1.178 +//	Dummy implementation of a pure virtual function
   1.179 +//
   1.180 +	{
   1.181 +	User::After(200000);	//	Wait 0.2 seconds
   1.182 +	}
   1.183 +
   1.184 +void CRemoteMountCB::DeleteL(const TDesC& /*aName*/)
   1.185 +//
   1.186 +//	Delete a file
   1.187 +//	Dummy implementation of a pure virtual function
   1.188 +//
   1.189 +	{
   1.190 +	User::After(200000);	//  Wait 0.2 seconds
   1.191 +	}
   1.192 +
   1.193 +void CRemoteMountCB::RenameL(const TDesC& /*anOldName*/,const TDesC& /*aNewName*/)
   1.194 +//
   1.195 +//	Rename a file or directory
   1.196 +//	Dummy implementation of a pure virtual function
   1.197 +//
   1.198 +	{
   1.199 +	User::After(200000);	//  Wait 0.2 seconds
   1.200 +	}
   1.201 +
   1.202 +void CRemoteMountCB::ReplaceL(const TDesC& /*anOldName*/,const TDesC& /*aNewName*/)
   1.203 +//
   1.204 +//	Delete aNewName if it exists and rename anOldName
   1.205 +//	Dummy implementation of a pure virtual function
   1.206 +//
   1.207 +	{
   1.208 +	User::After(200000);	//  Wait 0.2 seconds
   1.209 +	}
   1.210 +
   1.211 +void CRemoteMountCB::ReadUidL(const TDesC& /*aName*/,TEntry& /*anEntry*/) const
   1.212 +//
   1.213 +//	Read the entry uid if present
   1.214 +//
   1.215 +	{
   1.216 +	User::After(200000);	//  Wait 0.2 seconds
   1.217 +	}
   1.218 +
   1.219 +
   1.220 +void CRemoteMountCB::EntryL(const TDesC& /*aName*/,TEntry& /*anEntry*/) const
   1.221 +//
   1.222 +//	Get entry details
   1.223 +//	Dummy implementation of a pure virtual function
   1.224 +//
   1.225 +	{
   1.226 +	User::After(200000);	//  Wait 0.2 seconds
   1.227 +	}
   1.228 +
   1.229 +void CRemoteMountCB::SetEntryL(const TDesC& /*aName*/,const TTime& /*aTime*/,TUint /*aSetAttMask*/,TUint /*aClearAttMask*/)
   1.230 +//
   1.231 +//	Set entry details
   1.232 +//	Dummy implementation of a pure virtual function
   1.233 +//
   1.234 +	{
   1.235 +	User::After(200000);	//  Wait 0.2 seconds
   1.236 +	}
   1.237 +
   1.238 +
   1.239 +void CRemoteMountCB::FileOpenL(const TDesC& /*aName*/,TUint /*aMode*/,TFileOpen /*anOpen*/,CFileCB* /*aFile*/)
   1.240 +//
   1.241 +//	Open a File
   1.242 +//	Dummy implementation of a pure virtual function
   1.243 +//
   1.244 +	{
   1.245 +	User::After(200000);	//  Wait 0.2 seconds
   1.246 +	}
   1.247 +
   1.248 +void CRemoteMountCB::DirOpenL(const TDesC& /*aName*/,CDirCB* /*aDir*/)
   1.249 +//
   1.250 +//	Open a directory on the current mount
   1.251 +//	Dummy implementation of a pure virtual function
   1.252 +//
   1.253 +	{
   1.254 +	User::After(200000);	//  Wait 0.2 seconds
   1.255 +	}
   1.256 +
   1.257 +
   1.258 +void CRemoteMountCB::RawReadL(TInt64 /*aPos*/,TInt /*aLength*/,const TAny* /*aTrg*/,TInt /*anOffset*/,const RMessagePtr2& /*aMessage*/) const
   1.259 +//
   1.260 +//	Read directly from disk
   1.261 +//
   1.262 +	{
   1.263 +	User::Leave(KErrNotSupported);
   1.264 +	}
   1.265 +
   1.266 +void CRemoteMountCB::RawWriteL(TInt64 /*aPos*/,TInt /*aLength*/,const TAny* /*aSrc*/,TInt /*anOffset*/,const RMessagePtr2& /*aMessage*/)
   1.267 +//
   1.268 +//	Write directly to disk
   1.269 +//
   1.270 +	{
   1.271 +	User::Leave(KErrNotSupported);
   1.272 +	}
   1.273 +
   1.274 +void CRemoteMountCB::GetShortNameL(const TDesC& /*aLongName*/,TDes& /*aShortName*/)
   1.275 +//
   1.276 +//	Get the short name associated with aLongName
   1.277 +//	Dummy implementation of a pure virtual function
   1.278 +//
   1.279 +	{}
   1.280 +
   1.281 +
   1.282 +void CRemoteMountCB::GetLongNameL(const TDesC& /*aShortName*/,TDes& /*aLongName*/)
   1.283 +//
   1.284 +//	Get the short name associated with aLongName
   1.285 +//	Dummy implementation of a pure virtual function
   1.286 +//
   1.287 +	{}
   1.288 +
   1.289 +
   1.290 +void CRemoteMountCB::ReadSectionL(const TDesC& /*aName*/,TInt /*aPos*/,TAny* /*aTrg*/,TInt /*aLength*/,const RMessagePtr2& /*aMessage*/)
   1.291 +//
   1.292 +//	Get the short name associated with aLongName
   1.293 +//	Dummy implementation of a pure virtual function
   1.294 +//
   1.295 +	{}
   1.296 +
   1.297 +
   1.298 +
   1.299 +TBool CRemoteMountCB::IsRomDrive() const
   1.300 +//
   1.301 +// Returns ETrue if the drive == EDriveZ
   1.302 +//
   1.303 +	{
   1.304 +	return(Drive().DriveNumber()==EDriveZ);
   1.305 +	}
   1.306 +
   1.307 +
   1.308 +