diff -r 5b5d147c7838 -r bbf8bed59bcb kerneltest/f32test/server/t_proxydrive1.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kerneltest/f32test/server/t_proxydrive1.cpp Wed Jun 09 11:10:19 2010 +0300 @@ -0,0 +1,166 @@ +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// f32test\ext\t_ext1.cpp +// +// + +#include +#include +#include +#include "t_server.h" +#include "f32_test_utils.h" + +using namespace F32_Test_Utils; + + +GLDEF_D RTest test(_L("T_PROXYDRIVE1")); + + +TInt GetRemovableDrive(TInt aDriveNumber) + { + RLocalDrive d; + TBool flag=EFalse; + + //Find the local drive number corresponding to aDriveNumber + TMediaSerialNumber serialNum; + TInt r = TheFs.GetMediaSerialNumber(serialNum, aDriveNumber); + if(r!= KErrNone) + return r; + + TInt len = serialNum.Length(); + test.Printf(_L("Serial number (len %d) :\n"), len); + + for (TInt n=0; n p1; p1() = localDriveNumber; + TBuf<1> p2; + TInt driveNumber = EDriveM; + + r = TheFs.MountProxyDrive(driveNumber, KBitProxyDrive, &p1, &p2); + test.Printf(_L("MountProxyDrive(%d, %S) r %d\n"), driveNumber, &KBitProxyDrive, r); + test (r >= 0); + + _LIT(KFileSystem, "FAT"); + r = TheFs.MountFileSystem(KFileSystem, driveNumber); + test.Printf(_L("MountFileSystem(%S) r %d\n"), &KFileSystem, r); + test(r == KErrNone); + + + RFs fs; + r = fs.Connect(); + test(r == KErrNone); + + + TPath dirPath = _L("?:\\*"); + dirPath[0] = (TUint8) ('A' + driveNumber); + RDir dir; + r = dir.Open(fs, dirPath, KEntryAttNormal); + test.Printf(_L("RDir::Open(%S) r %d\n"), &dirPath, r); + + + r = TheFs.DismountFileSystem(KFileSystem, driveNumber); + test.Printf(_L("DismountFileSystem(%S) r %d\n"), &KFileSystem, r); + test (r == KErrInUse); + + // dismount failed - attempt a forced dismount + TRequestStatus stat; + TheFs.NotifyDismount(driveNumber, stat, EFsDismountForceDismount); + User::WaitForRequest(stat); + r = stat.Int(); + test.Printf(_L("DismountFileSystem(%S, EFsDismountForceDismount) r %d\n"), &KFileSystem, r); + test (r == KErrNone); + + r = TheFs.DismountProxyDrive(driveNumber); + test.Printf(_L("DismountProxyDrive(%d) r %d\n"), driveNumber, r); + test (r == KErrNone); + + + test.Printf(_L("closing dir (%S)....\n"), &dirPath, r); + dir.Close(); + + test.Printf(_L("closing file session()....\n")); + fs.Close(); + + r = TheFs.RemoveProxyDrive(KBitProxyDrive); + test (r == KErrNone); + + test.End(); + test.Close(); + }