author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 07 Jan 2010 13:38:45 +0200 | |
changeset 6 | 0173bcd7697c |
parent 0 | a41df078684a |
permissions | -rw-r--r-- |
0 | 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". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
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 |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
#include <e32std.h> |
|
20 |
#include <e32std_private.h> |
|
21 |
#include <e32svr.h> |
|
22 |
#include <e32test.h> |
|
23 |
#include <f32file.h> |
|
24 |
||
25 |
||
26 |
||
27 |
LOCAL_C void ScanPhysicalDeviceDrivers() |
|
28 |
/** |
|
29 |
* Displays list of loaded PDDs |
|
30 |
*/ |
|
31 |
{ |
|
32 |
RDebug::Print( _L("Scanning loaded media drivers...") ); |
|
33 |
||
34 |
_LIT( KSearchName, "Media.*" ); |
|
35 |
TFindPhysicalDevice findHb; |
|
36 |
findHb.Find(KSearchName); |
|
37 |
TFullName name; |
|
38 |
while (findHb.Next(name)==KErrNone) |
|
39 |
{ |
|
40 |
_LIT( KFormatStr, " %S" ); |
|
41 |
RDebug::Print( KFormatStr, &name ); |
|
42 |
} |
|
43 |
||
44 |
RDebug::Print( _L("\r\n") ); |
|
45 |
} |
|
46 |
||
47 |
||
48 |
LOCAL_C void ShowDriveCaps( const TLocalDriveCaps& aCaps ) |
|
49 |
{ |
|
50 |
RDebug::Print( _L(" size=%ld"), aCaps.iSize ); |
|
51 |
RDebug::Print( _L(" media type=%d"), aCaps.iType ); |
|
6
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
52 |
RDebug::Print( _L(" connection bus=%d"), aCaps.iConnectionBusType ); |
0 | 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 ); |
|
56 |
||
57 |
_LIT( KFsysUnknown, "Unknown" ); |
|
58 |
_LIT( KFsysRom, "ROM" ); |
|
59 |
_LIT( KFsysFat, "FAT" ); |
|
60 |
_LIT( KFsysLffs, "LFFS" ); |
|
61 |
const TDesC* fsType; |
|
62 |
switch( aCaps.iFileSystemId ) |
|
63 |
{ |
|
64 |
case KDriveFileSysFAT: |
|
65 |
fsType = &KFsysFat; |
|
66 |
break; |
|
67 |
case KDriveFileSysROM: |
|
68 |
fsType = &KFsysRom; |
|
69 |
break; |
|
70 |
case KDriveFileSysLFFS: |
|
71 |
fsType = &KFsysLffs; |
|
72 |
break; |
|
73 |
default: |
|
74 |
fsType = &KFsysUnknown; |
|
75 |
break; |
|
76 |
} |
|
77 |
||
78 |
RDebug::Print( _L(" filesystem id=%S (%d)\r\n"), fsType, aCaps.iFileSystemId ); |
|
79 |
} |
|
80 |
||
81 |
LOCAL_C void ShowVariantDriveInfo() |
|
82 |
/** |
|
83 |
* Display drive mapping info from variant/ASSP layers |
|
84 |
*/ |
|
85 |
{ |
|
86 |
RDebug::Print( _L("Variant drive info...") ); |
|
87 |
||
88 |
||
89 |
// Drive info |
|
90 |
TDriveInfoV1Buf driveInfo; |
|
91 |
TInt r=UserHal::DriveInfo(driveInfo); |
|
92 |
if( KErrNone == r ) |
|
93 |
{ |
|
94 |
RDebug::Print( _L("Total supported drives = %d"), driveInfo().iTotalSupportedDrives ); |
|
95 |
} |
|
96 |
else |
|
97 |
{ |
|
98 |
RDebug::Print( _L("!! Failed to get drive info (e=%d)"), r ); |
|
99 |
} |
|
100 |
||
101 |
// Attempt to open local drives |
|
102 |
for( TInt i = 0; i < KMaxLocalDrives; i++ ) |
|
103 |
{ |
|
104 |
TBusLocalDrive drive; |
|
105 |
TBool changedFlag = EFalse; |
|
106 |
TInt r = drive.Connect( i, changedFlag ); |
|
107 |
if( KErrNone == r ) |
|
108 |
{ |
|
109 |
RDebug::Print( _L("LocDrive %d: connected"), i ); |
|
110 |
TLocalDriveCapsV2Buf caps; |
|
111 |
TInt rv = drive.Caps( caps ); |
|
112 |
if( KErrNone == rv ) |
|
113 |
{ |
|
114 |
ShowDriveCaps( caps() ); |
|
115 |
} |
|
116 |
else |
|
117 |
{ |
|
118 |
RDebug::Print( _L(" failed to get caps(%d)"), rv ); |
|
119 |
} |
|
120 |
} |
|
121 |
else |
|
122 |
{ |
|
123 |
RDebug::Print( _L("LocDrive %d: not available(%d)"), r ); |
|
124 |
} |
|
125 |
drive.Disconnect(); |
|
126 |
} |
|
127 |
||
128 |
RDebug::Print( _L("\r\n") ); |
|
129 |
} |
|
130 |
||
131 |
||
132 |
||
133 |
LOCAL_C void ShowVolumeInfo( const TVolumeInfo& aInfo ) |
|
134 |
{ |
|
135 |
||
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 ); |
|
6
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
139 |
RDebug::Print( _L(" connection bus=%d"), aInfo.iDrive.iConnectionBusType ); |
0 | 140 |
|
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 ); |
|
145 |
} |
|
146 |
||
147 |
||
148 |
LOCAL_C void ShowDriveMountInfo() |
|
149 |
/** |
|
150 |
* Show mounted filesystems |
|
151 |
*/ |
|
152 |
{ |
|
153 |
RDebug::Print( _L("Scanning drives") ); |
|
154 |
||
155 |
RFs fs; |
|
156 |
TInt rv = fs.Connect(); |
|
157 |
if( KErrNone != rv ) |
|
158 |
{ |
|
159 |
RDebug::Print( _L("!! Failed to connect to F32(%d)"), rv ); |
|
160 |
return; |
|
161 |
} |
|
162 |
||
163 |
for( TInt i = EDriveA; i <= EDriveZ; i++ ) |
|
164 |
{ |
|
165 |
RDebug::Print( _L("Drive %c:"), i+'A' ); |
|
166 |
||
167 |
TFullName name; |
|
168 |
rv = fs.FileSystemName(name, i); |
|
169 |
if( KErrNone != rv && KErrNotFound != rv) |
|
170 |
{ |
|
171 |
RDebug::Print( _L(" !! failed to read filesystem name(%d)"), rv ); |
|
172 |
} |
|
173 |
else |
|
174 |
{ |
|
175 |
if (name.Length() != 0) |
|
176 |
{ |
|
177 |
RDebug::Print( _L(" FS=%S"), &name ); |
|
178 |
} |
|
179 |
else |
|
180 |
{ |
|
181 |
RDebug::Print( _L(" no filesystem") ); |
|
182 |
} |
|
183 |
||
184 |
TVolumeInfo volInfo; |
|
185 |
rv = fs.Volume( volInfo, i ); |
|
186 |
if( KErrNone == rv ) |
|
187 |
{ |
|
188 |
ShowVolumeInfo( volInfo ); |
|
189 |
} |
|
190 |
else |
|
191 |
{ |
|
192 |
RDebug::Print( _L(" !! failed to get volume info(%d)"), rv ); |
|
193 |
} |
|
194 |
RDebug::Print( _L("\r\n") ); |
|
195 |
} |
|
196 |
||
197 |
||
198 |
} |
|
199 |
||
200 |
fs.Close(); |
|
201 |
} |
|
202 |
||
203 |
||
204 |
||
205 |
void E32Main() |
|
206 |
{ |
|
207 |
RDebug::Print( _L("TF_FSSCAN") ); |
|
208 |
||
209 |
ScanPhysicalDeviceDrivers(); |
|
210 |
ShowVariantDriveInfo(); |
|
211 |
ShowDriveMountInfo(); |
|
212 |
||
213 |
RDebug::Print( _L("TF_FSSCAN done") ); |
|
214 |
} |
|
215 |