Update contrib.
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // this isn't actually a test of the media driver.It scans all loaded media
15 // drivers a filesystems and prints information about them
20 #include <e32std_private.h>
27 LOCAL_C void ScanPhysicalDeviceDrivers()
29 * Displays list of loaded PDDs
32 RDebug::Print( _L("Scanning loaded media drivers...") );
34 _LIT( KSearchName, "Media.*" );
35 TFindPhysicalDevice findHb;
36 findHb.Find(KSearchName);
38 while (findHb.Next(name)==KErrNone)
40 _LIT( KFormatStr, " %S" );
41 RDebug::Print( KFormatStr, &name );
44 RDebug::Print( _L("\r\n") );
48 LOCAL_C void ShowDriveCaps( const TLocalDriveCaps& aCaps )
50 RDebug::Print( _L(" size=%ld"), aCaps.iSize );
51 RDebug::Print( _L(" media type=%d"), aCaps.iType );
52 RDebug::Print( _L(" connection bus=%d"), aCaps.iConnectionBusType );
53 RDebug::Print( _L(" drive attributes=0x%x"), aCaps.iDriveAtt );
54 RDebug::Print( _L(" media attributes=0x%x"), aCaps.iMediaAtt );
55 RDebug::Print( _L(" base address=0x%x"), aCaps.iBaseAddress );
57 _LIT( KFsysUnknown, "Unknown" );
58 _LIT( KFsysRom, "ROM" );
59 _LIT( KFsysFat, "FAT" );
60 _LIT( KFsysLffs, "LFFS" );
62 switch( aCaps.iFileSystemId )
64 case KDriveFileSysFAT:
67 case KDriveFileSysROM:
70 case KDriveFileSysLFFS:
74 fsType = &KFsysUnknown;
78 RDebug::Print( _L(" filesystem id=%S (%d)\r\n"), fsType, aCaps.iFileSystemId );
81 LOCAL_C void ShowVariantDriveInfo()
83 * Display drive mapping info from variant/ASSP layers
86 RDebug::Print( _L("Variant drive info...") );
90 TDriveInfoV1Buf driveInfo;
91 TInt r=UserHal::DriveInfo(driveInfo);
94 RDebug::Print( _L("Total supported drives = %d"), driveInfo().iTotalSupportedDrives );
98 RDebug::Print( _L("!! Failed to get drive info (e=%d)"), r );
101 // Attempt to open local drives
102 for( TInt i = 0; i < KMaxLocalDrives; i++ )
104 TBusLocalDrive drive;
105 TBool changedFlag = EFalse;
106 TInt r = drive.Connect( i, changedFlag );
109 RDebug::Print( _L("LocDrive %d: connected"), i );
110 TLocalDriveCapsV2Buf caps;
111 TInt rv = drive.Caps( caps );
114 ShowDriveCaps( caps() );
118 RDebug::Print( _L(" failed to get caps(%d)"), rv );
123 RDebug::Print( _L("LocDrive %d: not available(%d)"), r );
128 RDebug::Print( _L("\r\n") );
133 LOCAL_C void ShowVolumeInfo( const TVolumeInfo& aInfo )
136 RDebug::Print( _L(" media type=%d"), aInfo.iDrive.iType );
137 RDebug::Print( _L(" drive attributes=0x%x"), aInfo.iDrive.iDriveAtt );
138 RDebug::Print( _L(" media attributes=0x%x"), aInfo.iDrive.iMediaAtt );
139 RDebug::Print( _L(" connection bus=%d"), aInfo.iDrive.iConnectionBusType );
141 RDebug::Print( _L(" UID=0x%x"), aInfo.iUniqueID );
142 RDebug::Print( _L(" size=0x%lx"), aInfo.iSize );
143 RDebug::Print( _L(" free=0x%lx"), aInfo.iFree );
144 RDebug::Print( _L(" name=%S"), &aInfo.iName );
148 LOCAL_C void ShowDriveMountInfo()
150 * Show mounted filesystems
153 RDebug::Print( _L("Scanning drives") );
156 TInt rv = fs.Connect();
159 RDebug::Print( _L("!! Failed to connect to F32(%d)"), rv );
163 for( TInt i = EDriveA; i <= EDriveZ; i++ )
165 RDebug::Print( _L("Drive %c:"), i+'A' );
168 rv = fs.FileSystemName(name, i);
169 if( KErrNone != rv && KErrNotFound != rv)
171 RDebug::Print( _L(" !! failed to read filesystem name(%d)"), rv );
175 if (name.Length() != 0)
177 RDebug::Print( _L(" FS=%S"), &name );
181 RDebug::Print( _L(" no filesystem") );
185 rv = fs.Volume( volInfo, i );
188 ShowVolumeInfo( volInfo );
192 RDebug::Print( _L(" !! failed to get volume info(%d)"), rv );
194 RDebug::Print( _L("\r\n") );
207 RDebug::Print( _L("TF_FSSCAN") );
209 ScanPhysicalDeviceDrivers();
210 ShowVariantDriveInfo();
211 ShowDriveMountInfo();
213 RDebug::Print( _L("TF_FSSCAN done") );