os/kernelhwsrv/kerneltest/f32test/fsstress/t_remmnt.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// f32test\fsstress\t_remmnt.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#if defined(_UNICODE)
sl@0
    19
#if !defined(UNICODE)
sl@0
    20
#define UNICODE
sl@0
    21
#endif
sl@0
    22
#endif
sl@0
    23
sl@0
    24
/*
sl@0
    25
#define WIN32_LEAN_AND_MEAN
sl@0
    26
#pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union
sl@0
    27
 #include <windows.h>
sl@0
    28
#pragma warning( default : 4201 ) // nonstandard extension used : nameless struct/union
sl@0
    29
#include <stdlib.h>
sl@0
    30
*/
sl@0
    31
#include <f32file.h>
sl@0
    32
#include <f32fsys.h>
sl@0
    33
#include <f32ver.h>
sl@0
    34
#include <e32twin.h>
sl@0
    35
#include <e32uid.h>
sl@0
    36
sl@0
    37
#include "t_remfsy.h"
sl@0
    38
sl@0
    39
sl@0
    40
sl@0
    41
LOCAL_C TInt GetMediaSize(TInt /*aDriveNumber*/,TInt64& /*aSize*/,TInt64& /*aFree*/)
sl@0
    42
//
sl@0
    43
// Return the size and free space on a drive.
sl@0
    44
//
sl@0
    45
	{
sl@0
    46
	return(KErrNone);
sl@0
    47
	}
sl@0
    48
sl@0
    49
LOCAL_C TInt GetVolume(TInt /*aDriveNumber*/,TDes& aName,TUint& aUniqueID)
sl@0
    50
//
sl@0
    51
// Return the volume name and uniqueID.
sl@0
    52
//
sl@0
    53
	{
sl@0
    54
	aUniqueID=1234;
sl@0
    55
	aName=(_L("REMOTDRV"));
sl@0
    56
	return(KErrNone);	
sl@0
    57
	}
sl@0
    58
sl@0
    59
sl@0
    60
//////////////////////////////////////////////////////////////////////////
sl@0
    61
//								CRemoteMountCB							//
sl@0
    62
//////////////////////////////////////////////////////////////////////////	
sl@0
    63
sl@0
    64
sl@0
    65
CRemoteMountCB::CRemoteMountCB()
sl@0
    66
//
sl@0
    67
// Constructor
sl@0
    68
//
sl@0
    69
	{
sl@0
    70
	__DECLARE_NAME(_S("CRemoteMountCB"));
sl@0
    71
	}
sl@0
    72
sl@0
    73
CRemoteMountCB::~CRemoteMountCB()
sl@0
    74
//
sl@0
    75
// Destructor
sl@0
    76
//
sl@0
    77
	{}
sl@0
    78
sl@0
    79
void CRemoteMountCB::MountL(TBool /*aForceMount*/)
sl@0
    80
//
sl@0
    81
// Mount a media. Only allowed to leave with KErrNoMemory,KErrNotReady,KErrCorrupt,KErrUnknown.
sl@0
    82
//
sl@0
    83
	{
sl@0
    84
//	TInt64 s,f;
sl@0
    85
	TFileName driveName;
sl@0
    86
	TInt d=Drive().DriveNumber();
sl@0
    87
//	TInt driveNum=d;
sl@0
    88
	if (MapDrive(driveName,d))
sl@0
    89
		RFs::CharToDrive(driveName[0],d);
sl@0
    90
	//User::LeaveIfError(GetMediaSize(d,s,f));
sl@0
    91
	//if (driveNum==EDriveZ)
sl@0
    92
//		iSize=4*1048576;
sl@0
    93
//	else
sl@0
    94
		//iSize=s;
sl@0
    95
	iSize=4*1024*16;
sl@0
    96
	User::LeaveIfError(GetVolume(d,driveName,iUniqueID));
sl@0
    97
	HBufC* pN=driveName.AllocL();
sl@0
    98
	SetVolumeName(pN);
sl@0
    99
	}
sl@0
   100
sl@0
   101
TInt CRemoteMountCB::ReMount()
sl@0
   102
//
sl@0
   103
// Try and remount this media.
sl@0
   104
//
sl@0
   105
	{
sl@0
   106
sl@0
   107
	TFileName n;
sl@0
   108
	TInt d=Drive().DriveNumber();
sl@0
   109
	if (MapDrive(n,d))
sl@0
   110
		RFs::CharToDrive(n[0],d);
sl@0
   111
	TUint uniqueID;
sl@0
   112
	TInt r=GetVolume(d,n,uniqueID);
sl@0
   113
	if (r!=KErrNone)
sl@0
   114
		return(r);
sl@0
   115
	if (n==VolumeName() && uniqueID==iUniqueID)
sl@0
   116
		return(KErrNone);
sl@0
   117
	return(KErrGeneral);
sl@0
   118
	}
sl@0
   119
sl@0
   120
void CRemoteMountCB::Dismounted()
sl@0
   121
//
sl@0
   122
//	Dummy implementation of a pure virtual function
sl@0
   123
//
sl@0
   124
	{}
sl@0
   125
sl@0
   126
void CRemoteMountCB::VolumeL(TVolumeInfo& aVolume) const
sl@0
   127
//
sl@0
   128
// Return the volume info.
sl@0
   129
//
sl@0
   130
	{
sl@0
   131
	TInt64 s,f(0);
sl@0
   132
	TFileName n;
sl@0
   133
	TInt d=Drive().DriveNumber();
sl@0
   134
	TInt driveNum=d;
sl@0
   135
	if (MapDrive(n,d))
sl@0
   136
		RFs::CharToDrive(n[0],d);
sl@0
   137
	User::LeaveIfError(GetMediaSize(d,s,f));
sl@0
   138
	if (driveNum==EDriveZ)
sl@0
   139
		aVolume.iFree=0;
sl@0
   140
	else
sl@0
   141
		aVolume.iFree=f;
sl@0
   142
	}
sl@0
   143
sl@0
   144
sl@0
   145
void CRemoteMountCB::SetVolumeL(TDes& /*aName*/)
sl@0
   146
//
sl@0
   147
//	Set the volume label
sl@0
   148
//	Dummy implementation of a pure virtual function
sl@0
   149
//
sl@0
   150
	{}
sl@0
   151
sl@0
   152
sl@0
   153
void CRemoteMountCB::IsFileInRom(const TDesC& /*aName*/,TUint8*& /*aFileStart*/)
sl@0
   154
//
sl@0
   155
// Return the address of the file if it is in rom
sl@0
   156
//
sl@0
   157
	{}
sl@0
   158
sl@0
   159
sl@0
   160
sl@0
   161
sl@0
   162
void CRemoteMountCB::MkDirL(const TDesC& /*aName*/)
sl@0
   163
//
sl@0
   164
//	Make a directory
sl@0
   165
//	Dummy implementation of a pure virtual function
sl@0
   166
//
sl@0
   167
	{
sl@0
   168
	User::After(200000);	//	Wait 0.2 seconds
sl@0
   169
	}
sl@0
   170
sl@0
   171
sl@0
   172
void CRemoteMountCB::RmDirL(const TDesC& /*aName*/)
sl@0
   173
//
sl@0
   174
//	Remove a directory
sl@0
   175
//	Dummy implementation of a pure virtual function
sl@0
   176
//
sl@0
   177
	{
sl@0
   178
	User::After(200000);	//	Wait 0.2 seconds
sl@0
   179
	}
sl@0
   180
sl@0
   181
void CRemoteMountCB::DeleteL(const TDesC& /*aName*/)
sl@0
   182
//
sl@0
   183
//	Delete a file
sl@0
   184
//	Dummy implementation of a pure virtual function
sl@0
   185
//
sl@0
   186
	{
sl@0
   187
	User::After(200000);	//  Wait 0.2 seconds
sl@0
   188
	}
sl@0
   189
sl@0
   190
void CRemoteMountCB::RenameL(const TDesC& /*anOldName*/,const TDesC& /*aNewName*/)
sl@0
   191
//
sl@0
   192
//	Rename a file or directory
sl@0
   193
//	Dummy implementation of a pure virtual function
sl@0
   194
//
sl@0
   195
	{
sl@0
   196
	User::After(200000);	//  Wait 0.2 seconds
sl@0
   197
	}
sl@0
   198
sl@0
   199
void CRemoteMountCB::ReplaceL(const TDesC& /*anOldName*/,const TDesC& /*aNewName*/)
sl@0
   200
//
sl@0
   201
//	Delete aNewName if it exists and rename anOldName
sl@0
   202
//	Dummy implementation of a pure virtual function
sl@0
   203
//
sl@0
   204
	{
sl@0
   205
	User::After(200000);	//  Wait 0.2 seconds
sl@0
   206
	}
sl@0
   207
sl@0
   208
void CRemoteMountCB::ReadUidL(const TDesC& /*aName*/,TEntry& /*anEntry*/) const
sl@0
   209
//
sl@0
   210
//	Read the entry uid if present
sl@0
   211
//
sl@0
   212
	{
sl@0
   213
	User::After(200000);	//  Wait 0.2 seconds
sl@0
   214
	}
sl@0
   215
sl@0
   216
sl@0
   217
void CRemoteMountCB::EntryL(const TDesC& /*aName*/,TEntry& /*anEntry*/) const
sl@0
   218
//
sl@0
   219
//	Get entry details
sl@0
   220
//	Dummy implementation of a pure virtual function
sl@0
   221
//
sl@0
   222
	{
sl@0
   223
	User::After(200000);	//  Wait 0.2 seconds
sl@0
   224
	}
sl@0
   225
sl@0
   226
void CRemoteMountCB::SetEntryL(const TDesC& /*aName*/,const TTime& /*aTime*/,TUint /*aSetAttMask*/,TUint /*aClearAttMask*/)
sl@0
   227
//
sl@0
   228
//	Set entry details
sl@0
   229
//	Dummy implementation of a pure virtual function
sl@0
   230
//
sl@0
   231
	{
sl@0
   232
	User::After(200000);	//  Wait 0.2 seconds
sl@0
   233
	}
sl@0
   234
sl@0
   235
sl@0
   236
void CRemoteMountCB::FileOpenL(const TDesC& /*aName*/,TUint /*aMode*/,TFileOpen /*anOpen*/,CFileCB* /*aFile*/)
sl@0
   237
//
sl@0
   238
//	Open a File
sl@0
   239
//	Dummy implementation of a pure virtual function
sl@0
   240
//
sl@0
   241
	{
sl@0
   242
	User::After(200000);	//  Wait 0.2 seconds
sl@0
   243
	}
sl@0
   244
sl@0
   245
void CRemoteMountCB::DirOpenL(const TDesC& /*aName*/,CDirCB* /*aDir*/)
sl@0
   246
//
sl@0
   247
//	Open a directory on the current mount
sl@0
   248
//	Dummy implementation of a pure virtual function
sl@0
   249
//
sl@0
   250
	{
sl@0
   251
	User::After(200000);	//  Wait 0.2 seconds
sl@0
   252
	}
sl@0
   253
sl@0
   254
sl@0
   255
void CRemoteMountCB::RawReadL(TInt64 /*aPos*/,TInt /*aLength*/,const TAny* /*aTrg*/,TInt /*anOffset*/,const RMessagePtr2& /*aMessage*/) const
sl@0
   256
//
sl@0
   257
//	Read directly from disk
sl@0
   258
//
sl@0
   259
	{
sl@0
   260
	User::Leave(KErrNotSupported);
sl@0
   261
	}
sl@0
   262
sl@0
   263
void CRemoteMountCB::RawWriteL(TInt64 /*aPos*/,TInt /*aLength*/,const TAny* /*aSrc*/,TInt /*anOffset*/,const RMessagePtr2& /*aMessage*/)
sl@0
   264
//
sl@0
   265
//	Write directly to disk
sl@0
   266
//
sl@0
   267
	{
sl@0
   268
	User::Leave(KErrNotSupported);
sl@0
   269
	}
sl@0
   270
sl@0
   271
void CRemoteMountCB::GetShortNameL(const TDesC& /*aLongName*/,TDes& /*aShortName*/)
sl@0
   272
//
sl@0
   273
//	Get the short name associated with aLongName
sl@0
   274
//	Dummy implementation of a pure virtual function
sl@0
   275
//
sl@0
   276
	{}
sl@0
   277
sl@0
   278
sl@0
   279
void CRemoteMountCB::GetLongNameL(const TDesC& /*aShortName*/,TDes& /*aLongName*/)
sl@0
   280
//
sl@0
   281
//	Get the short name associated with aLongName
sl@0
   282
//	Dummy implementation of a pure virtual function
sl@0
   283
//
sl@0
   284
	{}
sl@0
   285
sl@0
   286
sl@0
   287
void CRemoteMountCB::ReadSectionL(const TDesC& /*aName*/,TInt /*aPos*/,TAny* /*aTrg*/,TInt /*aLength*/,const RMessagePtr2& /*aMessage*/)
sl@0
   288
//
sl@0
   289
//	Get the short name associated with aLongName
sl@0
   290
//	Dummy implementation of a pure virtual function
sl@0
   291
//
sl@0
   292
	{}
sl@0
   293
sl@0
   294
sl@0
   295
sl@0
   296
TBool CRemoteMountCB::IsRomDrive() const
sl@0
   297
//
sl@0
   298
// Returns ETrue if the drive == EDriveZ
sl@0
   299
//
sl@0
   300
	{
sl@0
   301
	return(Drive().DriveNumber()==EDriveZ);
sl@0
   302
	}
sl@0
   303
sl@0
   304
sl@0
   305