author | Mike Kinghan <mikek@symbian.org> |
Thu, 25 Nov 2010 14:35:45 +0000 | |
branch | GCC_SURGE |
changeset 305 | 1ba12ef4ef89 |
parent 109 | b3a1d9898418 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2006-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 test tests reading and writing to the protected & unprotected area of an SD card |
|
15 |
// & verifies that mounting & dismounting the protected area does not disrupt reads and/or |
|
16 |
// writes to the unprotected area. |
|
17 |
// NB For test to work, a valid key which matches the SD card under test needs to be put |
|
18 |
// into the byte array testDeviceKeyRawData[]. |
|
19 |
// ********* IMPORTANT NOTE TO SYMBIAN ENGINEERS WORKING WITH THIS TEST ********* |
|
20 |
// The key MUST NOT BE CHECKED INTO PERFORCE as this would contravene the license agreement |
|
21 |
// we have with the SD Card Association. |
|
22 |
// ********* IMPORTANT NOTE TO SYMBIAN ENGINEERS WORKING WITH THIS TEST ********* |
|
23 |
// |
|
24 |
// |
|
25 |
||
26 |
#include <e32std.h> |
|
27 |
#include <e32std_private.h> |
|
28 |
#include <e32cons.h> |
|
29 |
#include <f32file.h> |
|
30 |
#include <e32test.h> |
|
31 |
||
32 |
const TUint32 KDriveNumProt = EDriveG; |
|
33 |
const TUint32 KDriveNumUnprot = EDriveF; |
|
34 |
TChar gDriveLetterProt; |
|
35 |
TChar gDriveLetterUnprot; |
|
36 |
TBool gMountProtectedArea = EFalse; |
|
37 |
||
38 |
GLDEF_D RTest test(_L("T_SETKEY")); |
|
39 |
||
40 |
// flags stolen from locmedia.h |
|
41 |
//const TInt KForceMediaChangeReOpenAllMediaDrivers = 0; |
|
42 |
const TUint KForceMediaChangeReOpenMediaDriver = 0x80000000UL; |
|
43 |
const TUint KMediaRemountForceMediaChange = 0x00000001UL; |
|
44 |
||
45 |
class TSDCardSecureMountInfo |
|
46 |
{ |
|
47 |
public: |
|
48 |
TUid iUid; |
|
49 |
const TDesC8* iEncryptedDeviceKey; |
|
50 |
const TDesC8* iRamMKBData; |
|
51 |
TInt iMKBNumber; |
|
52 |
}; |
|
53 |
typedef TPckgBuf<TSDCardSecureMountInfo> TSDCardSecureMountInfoPckg; |
|
54 |
||
55 |
typedef enum |
|
56 |
{ |
|
57 |
EClearMountInfo=0, |
|
58 |
ESetMountInfo=1 |
|
59 |
} TMountInfoAction; |
|
60 |
||
61 |
||
62 |
// Standard boilerplate for creating a console window //////////////////////// |
|
63 |
void StartAppL(); |
|
64 |
void SetupConsoleL(); |
|
65 |
||
66 |
GLDEF_C TInt E32Main() // main function called by E32 |
|
67 |
{ |
|
68 |
CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
69 |
#if defined(_DEBUG) |
0 | 70 |
TRAPD(error,SetupConsoleL()); // more initialization, then do example |
71 |
__ASSERT_DEBUG(!error,User::Panic(_L("BossTextUi"),error)); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
#else |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
73 |
TRAP_IGNORE(SetupConsoleL()); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
74 |
#endif |
0 | 75 |
delete cleanup; // destroy clean-up stack |
76 |
return 0; // and return |
|
77 |
} |
|
78 |
||
79 |
// Determine whether we should run the full test or just mount the protected area |
|
80 |
void ParseCommandLine() |
|
81 |
{ |
|
82 |
TBuf<32> args; |
|
83 |
User::CommandLine(args); |
|
84 |
||
85 |
if (args == _L("-m")) |
|
86 |
{ |
|
87 |
gMountProtectedArea = ETrue; |
|
88 |
} |
|
89 |
else if (args == _L("-?")) |
|
90 |
{ |
|
91 |
test.Printf(_L("usage: t_setkey [-m]\n")); |
|
92 |
test.Printf(_L("-m => mount proteced area and exit\n")); |
|
93 |
} |
|
94 |
} |
|
95 |
||
96 |
void SetupConsoleL() // initialize and call example code under cleanup stack |
|
97 |
{ |
|
98 |
test.Title(); |
|
99 |
test.Start(_L("Starting tests...")); |
|
100 |
||
101 |
ParseCommandLine(); |
|
102 |
TRAPD(error,StartAppL()); // perform example function |
|
103 |
if (error) |
|
104 |
test.Printf(_L("failed: leave code=%d\n"), error); |
|
105 |
else |
|
106 |
test.Printf(_L("ok\n")); |
|
107 |
||
108 |
test.Printf(_L(" [press any key]\n")); |
|
109 |
test.Getch(); |
|
110 |
||
111 |
test.End(); |
|
112 |
test.Close(); |
|
113 |
||
114 |
} |
|
115 |
||
116 |
// End of standard boilerplate /////////////////////////////////////////////// |
|
117 |
||
118 |
||
119 |
static const TUint8 testDeviceKeyRawData[160] = |
|
120 |
{ |
|
121 |
||
122 |
// Symbian test key : |
|
123 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
|
124 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
|
125 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
|
126 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
|
127 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
|
128 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
|
129 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
|
130 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
|
131 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
|
132 |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
|
133 |
||
134 |
||
135 |
}; |
|
136 |
||
137 |
TInt WriteThreadEntryPoint( TAny* aParam ) |
|
138 |
{ |
|
139 |
(void)aParam; |
|
140 |
||
141 |
RTest test(_L("WriteThread")); |
|
142 |
||
143 |
test.Title(); |
|
144 |
||
145 |
test.Start(_L("Starting WriteThread ...")); |
|
146 |
||
147 |
TInt r; |
|
148 |
RFs fs; |
|
149 |
||
150 |
r = fs.Connect(); |
|
151 |
if(r != KErrNone) |
|
152 |
{ |
|
153 |
test.Printf(_L("WT Connect err %d\n"), r); |
|
154 |
} |
|
155 |
||
156 |
RFile file; |
|
157 |
||
158 |
TFileName fileNameUnprot = _L("?:\\TESTTHRD.TXT"); |
|
159 |
fileNameUnprot[0] = (TText) gDriveLetterUnprot; |
|
160 |
||
161 |
//Open file on the user area drive |
|
162 |
r = file.Replace(fs, fileNameUnprot, EFileWrite); |
|
163 |
if(r != KErrNone) |
|
164 |
{ |
|
165 |
test.Printf(_L("WT File Replace err %d\n\n"), r); |
|
166 |
test(0); |
|
167 |
} |
|
168 |
||
169 |
TPtrC8 data(testDeviceKeyRawData, 8); |
|
170 |
||
171 |
RThread().Rendezvous(KErrNone); |
|
172 |
||
173 |
for(TInt iter=0; iter < KMaxTInt;iter++) // keep sending write requests to the user area for ever |
|
174 |
{ |
|
175 |
||
176 |
r = file.Write(data); |
|
177 |
//test.Printf(_L("WT File Write err %d iter %d\r"), r, iter); |
|
178 |
||
179 |
if(r != KErrNone) |
|
180 |
{ |
|
181 |
test.Printf(_L("WT File Write err %d\n"), r); |
|
182 |
test(0); |
|
183 |
} |
|
184 |
} |
|
185 |
||
186 |
file.Close(); |
|
187 |
fs.Close(); |
|
188 |
||
189 |
test.End(); |
|
190 |
test.Close(); |
|
191 |
||
192 |
return 0; |
|
193 |
} |
|
194 |
||
195 |
||
196 |
||
197 |
GLDEF_C void StartAppL() |
|
198 |
{ |
|
199 |
||
200 |
// Exit if no key defined |
|
201 |
if (testDeviceKeyRawData[0] == 0 && testDeviceKeyRawData[1] == 0) |
|
202 |
{ |
|
203 |
test.Printf(_L("This test needs to be recompiled with a valid key\n")); |
|
204 |
test(0); |
|
205 |
} |
|
206 |
||
207 |
RFs fs; |
|
208 |
TInt r; |
|
209 |
||
210 |
||
211 |
test.Printf(_L("Starting Setkey\n")); |
|
212 |
if(fs.Connect()!=KErrNone) |
|
213 |
return; |
|
214 |
||
215 |
test.Printf(_L("Connected to fileserver OK\n")); |
|
216 |
TBuf8<160> mkBData; |
|
217 |
||
218 |
mkBData.SetLength(160); |
|
219 |
TInt i; |
|
220 |
for (i = 0; i < 160; i++) |
|
221 |
{ |
|
222 |
mkBData[i] = testDeviceKeyRawData[i]; |
|
223 |
} |
|
224 |
||
225 |
TSDCardSecureMountInfoPckg pckg; |
|
226 |
||
227 |
||
228 |
pckg().iRamMKBData=(const TDesC8*)0x01; //Unused for now. |
|
229 |
pckg().iMKBNumber = 0; |
|
230 |
// pckg().iMKBNumber = 11; // for SD Binding ? |
|
231 |
static TPtrC8 encryptedDeviceKey(testDeviceKeyRawData, sizeof(testDeviceKeyRawData)); |
|
232 |
pckg().iEncryptedDeviceKey = &encryptedDeviceKey; |
|
233 |
||
234 |
||
235 |
r = fs.DriveToChar(KDriveNumProt, gDriveLetterProt); |
|
236 |
r = fs.DriveToChar(KDriveNumUnprot, gDriveLetterUnprot); |
|
237 |
TFileName fileNameUnprot = _L("?:\\TEST.TXT"); |
|
238 |
TFileName fileNameProt = _L("?:\\TEST.TXT"); |
|
239 |
fileNameUnprot[0] = (TText) gDriveLetterUnprot; |
|
240 |
fileNameProt[0] = (TText) gDriveLetterProt; |
|
241 |
||
242 |
TVolumeInfo v; |
|
243 |
||
244 |
r = fs.Volume(v, KDriveNumProt); //Check |
|
245 |
test.Printf(_L("Volume() returned %d\n"), r); |
|
246 |
test(r == KErrNotReady || r == KErrNone); |
|
247 |
||
248 |
||
249 |
if (gMountProtectedArea) |
|
250 |
{ |
|
251 |
test.Next(_L("test remount with KForceMediaChangeReOpenMediaDriver flag")); |
|
252 |
// verify that the unprotected area does not get a change notification |
|
253 |
TFileName filePathUnprot = _L("?:\\"); |
|
254 |
filePathUnprot[0] = (TText) gDriveLetterUnprot; |
|
255 |
TRequestStatus changeStatus; |
|
256 |
fs.NotifyChange(ENotifyAll, changeStatus, filePathUnprot); |
|
257 |
||
258 |
r = fs.RemountDrive(KDriveNumProt, &pckg, (TUint) KForceMediaChangeReOpenMediaDriver); |
|
259 |
test(r == KErrNone); |
|
260 |
r = fs.Volume(v, KDriveNumProt); //Check |
|
261 |
test.Printf(_L("Volume() returned %d\n"), r); |
|
262 |
test(r == KErrNone || r == KErrCorrupt); |
|
263 |
||
264 |
test.Next(_L("test this causes no change to unprotected drive")); |
|
265 |
test.Printf(_L("changeStatus %d\n"), changeStatus.Int()); |
|
266 |
test (changeStatus.Int() == KRequestPending); |
|
267 |
fs.NotifyChangeCancel(changeStatus); |
|
268 |
||
269 |
test.Printf(_L("Remount Drive suceeded. Secure area is now unlocked\n")); |
|
270 |
fs.Close(); |
|
271 |
return; |
|
272 |
} |
|
273 |
||
274 |
// Set the mount info for the secure area using KMediaRemountForceMediaChange flag |
|
275 |
// This is asynchronous in behaviour i.e. we need to wait for (two) media change notifications |
|
276 |
// before the drive is ready for use |
|
277 |
test.Next(_L("test remount with KMediaRemountForceMediaChange flag")); |
|
278 |
TRequestStatus changeStatus; |
|
279 |
fs.NotifyChange(ENotifyAll, changeStatus); |
|
280 |
r = fs.RemountDrive(KDriveNumProt, &pckg, (TUint) KMediaRemountForceMediaChange); |
|
281 |
test.Printf(_L("RemountDrive() returned %d\n"), r); |
|
282 |
test(r == KErrNotReady || r == KErrNone); |
|
283 |
||
284 |
test.Printf(_L("Waiting for media change...\n")); |
|
285 |
User::WaitForRequest(changeStatus); |
|
286 |
||
287 |
do |
|
288 |
{ |
|
289 |
||
290 |
||
291 |
r = fs.Volume(v, KDriveNumProt); //Check |
|
292 |
test.Printf(_L("Volume() returned %d\n"), r); |
|
293 |
||
294 |
fs.NotifyChange(ENotifyAll, changeStatus); |
|
295 |
} |
|
296 |
while (r == KErrNotReady); |
|
297 |
fs.NotifyChangeCancel(changeStatus); |
|
298 |
||
299 |
||
300 |
||
301 |
// Set the mount info for the secure area using KForceMediaChangeReOpenMediaDriver flag |
|
302 |
// This should be synchronous in behaviour |
|
303 |
test.Next(_L("test remount with KForceMediaChangeReOpenMediaDriver flag")); |
|
304 |
r = fs.RemountDrive(KDriveNumProt, NULL, (TUint) KForceMediaChangeReOpenMediaDriver); |
|
305 |
test(r == KErrNone); |
|
306 |
r = fs.RemountDrive(KDriveNumProt, &pckg, (TUint) KForceMediaChangeReOpenMediaDriver); |
|
307 |
test(r == KErrNone); |
|
308 |
r = fs.Volume(v, KDriveNumProt); //Check |
|
309 |
test.Printf(_L("Volume() returned %d\n"), r); |
|
310 |
test(r == KErrNone); |
|
311 |
||
312 |
test.Printf(_L("Remount Drive suceeded. Secure area is now unlocked\n")); |
|
313 |
test.Printf(_L("Press any key to continue...\n")); |
|
314 |
||
315 |
||
316 |
test.Next(_L("test writing to protected & unprotected areas")); |
|
317 |
||
318 |
RFile f1,f2; |
|
319 |
TRequestStatus req1, req2, req3, req4; |
|
320 |
||
321 |
const TInt KBufSize = 32 * 1024; |
|
322 |
LOCAL_D TBuf8<KBufSize> gBuf; |
|
323 |
||
324 |
||
325 |
test.Printf(_L("Opening files...\n")); |
|
326 |
test.Printf(_L("Opening %S...\n"), &fileNameUnprot); |
|
327 |
r = f1.Replace(fs, fileNameUnprot,EFileStreamText|EFileWrite); |
|
328 |
test (r == KErrNone); |
|
329 |
||
330 |
test.Printf(_L("Opening %S...\n"), &fileNameProt); |
|
331 |
r = f2.Replace(fs, fileNameProt,EFileStreamText|EFileWrite); |
|
332 |
test (r == KErrNone); |
|
333 |
||
334 |
||
335 |
// test.Printf(_L("Wait 10 secs for stack to power down...\n")); |
|
336 |
// User::After(10 * 1000000); |
|
337 |
// test.Printf(_L("done\n")); |
|
338 |
||
339 |
gBuf.SetLength(KBufSize); |
|
340 |
||
341 |
test.Printf(_L("Writing files...\n")); |
|
342 |
||
343 |
req1 = KRequestPending; |
|
344 |
req2 = KRequestPending; |
|
345 |
req3 = KRequestPending; |
|
346 |
req4 = KRequestPending; |
|
347 |
||
348 |
f1.Write(gBuf, req1); |
|
349 |
r = fs.RemountDrive(KDriveNumProt, &pckg, (TUint) KForceMediaChangeReOpenMediaDriver); |
|
350 |
test (r == KErrNone); |
|
351 |
f2.Write(gBuf, req2); |
|
352 |
||
353 |
test.Printf(_L("req1 %d, req2 %d\n"), req1.Int(), req2.Int()); |
|
354 |
test (req1 == KRequestPending || req1 == KErrNone); |
|
355 |
test (req2 == KRequestPending || req2 == KErrNone); |
|
356 |
||
357 |
// force a remount to test whether a write to the unprotected area |
|
358 |
// is disrupted.... |
|
359 |
// NB Should set aFlags to KForceMediaChangeReOpenMediaDriver, otherwise a media change will occur which WILL |
|
360 |
// prematurely complete any pending writes |
|
361 |
r = fs.RemountDrive(KDriveNumProt, &pckg, (TUint) KForceMediaChangeReOpenMediaDriver); |
|
362 |
test (r == KErrNone); |
|
363 |
||
364 |
//r = fs.RemountDrive(KDriveNumProt, &pckg, 1); |
|
365 |
test.Printf(_L("RemountDrive() returned %d\n"), r); |
|
366 |
||
367 |
f1.Write(gBuf, req3); |
|
368 |
f2.Write(gBuf, req4); |
|
369 |
||
370 |
test.Printf(_L("WaitForRequests...\n")); |
|
371 |
User::WaitForRequest(req1); |
|
372 |
User::WaitForRequest(req2); |
|
373 |
User::WaitForRequest(req3); |
|
374 |
User::WaitForRequest(req4); |
|
375 |
||
376 |
test.Printf(_L("req1 %d, req2 %d req3 %d, req4 %d\n"), req1.Int(), req2.Int(), req3.Int(), req4.Int()); |
|
377 |
test (req1 == KErrNone); |
|
378 |
test (req2 == KErrNone); |
|
379 |
test (req3 == KErrNone); |
|
380 |
test (req4 == KErrNone); |
|
381 |
||
382 |
f1.Close(); |
|
383 |
f2.Close(); |
|
384 |
||
385 |
||
386 |
// create a thread which continuously writes to the unprotected area |
|
387 |
// whilst continually remounting protected area in this thread. |
|
388 |
||
389 |
test.Next(_L("test writing to protected & unprotected areas using different threads")); |
|
390 |
||
391 |
test.Printf(_L("Opening %S for read access...\n"), &fileNameUnprot); |
|
392 |
r = f2.Open(fs, fileNameProt, EFileShareReadersOnly); |
|
393 |
test (r == KErrNone); |
|
394 |
||
395 |
||
396 |
test (r == KErrNone); |
|
397 |
RThread thread; |
|
398 |
r = thread.Create( _L("Write Thread"), WriteThreadEntryPoint, KDefaultStackSize, NULL, NULL); |
|
399 |
if(r !=KErrNone) |
|
400 |
{ |
|
401 |
test.Printf(_L("MT Thread Create 1 ret = %d\n"),r); |
|
402 |
return; |
|
403 |
} |
|
404 |
TRequestStatus writeThreadStat; |
|
405 |
||
406 |
thread.Rendezvous(writeThreadStat); |
|
407 |
thread.Resume(); |
|
408 |
User::WaitForRequest(writeThreadStat); |
|
409 |
// thread.Close(); //close handle to thread |
|
410 |
if(writeThreadStat.Int() != KErrNone) |
|
411 |
{ |
|
412 |
test.Printf(_L("MT Thread Create 2 ret = %d\n"),writeThreadStat.Int()); |
|
413 |
test(0); |
|
414 |
} |
|
415 |
||
416 |
TBuf8<14> buf; |
|
417 |
||
418 |
||
419 |
const TInt KMaxIterations = 1000; |
|
420 |
for(TInt n=0; n<KMaxIterations; n++) |
|
421 |
{ |
|
422 |
if (n % 10 == 0) |
|
423 |
test.Printf(_L("iteration %d of %d\r"), n, KMaxIterations); |
|
424 |
||
425 |
//Set the mount info for the secure area. |
|
426 |
r = fs.RemountDrive(KDriveNumProt, &pckg, (TUint) KForceMediaChangeReOpenMediaDriver); |
|
427 |
if (r == KErrNone) |
|
428 |
{ |
|
429 |
// test.Printf(_L("Remount Drive KEY suceeded. Secure area is now unlocked\n")); |
|
430 |
} |
|
431 |
else |
|
432 |
{ |
|
433 |
test.Printf(_L("Remount Drive KEY failed with %d\n"), r); |
|
434 |
test(0); |
|
435 |
} |
|
436 |
||
437 |
// take it in turns to |
|
438 |
// (0) call Rfs:Volume() |
|
439 |
// (1) call RFile::Read |
|
440 |
// (2) do nothing |
|
441 |
TInt testNum = n & 0x3; |
|
442 |
if (testNum == 0) |
|
443 |
{ |
|
444 |
TVolumeInfo volumeInfo; |
|
445 |
r = fs.Volume( volumeInfo, KDriveNumProt ); |
|
446 |
if (r != KErrNone) |
|
447 |
{ |
|
448 |
RDebug::Print( _L("Volume returned %d after RemountDrive"), r); |
|
449 |
break; |
|
450 |
} |
|
451 |
} |
|
452 |
else if (testNum == 1) |
|
453 |
{ |
|
454 |
r = f2.Read(0,buf); |
|
455 |
if(r != KErrNone) |
|
456 |
{ |
|
457 |
test.Printf(_L("protected Drive Access failed %d\n"), r); |
|
458 |
test(0); |
|
459 |
} |
|
460 |
} |
|
461 |
else if (testNum == 2) |
|
462 |
{ |
|
463 |
} |
|
464 |
else if (testNum == 3) |
|
465 |
{ |
|
466 |
} |
|
467 |
||
468 |
||
469 |
//test.Printf(_L("protected Drive KEY Access succeeded\n")); |
|
470 |
r = fs.RemountDrive(KDriveNumProt, NULL, (TUint) KForceMediaChangeReOpenMediaDriver); |
|
471 |
if (r == KErrNone) |
|
472 |
{ |
|
473 |
// test.Printf(_L("Remount Drive NULL suceeded. Secure area is now locked\n")); |
|
474 |
} |
|
475 |
else |
|
476 |
{ |
|
477 |
test.Printf(_L("Remount Drive NULL failed with %d\n"), r); |
|
478 |
test(0); |
|
479 |
} |
|
480 |
||
481 |
if (testNum == 1) |
|
482 |
{ |
|
483 |
r = f2.Read(0,buf); |
|
484 |
//test.Printf(_L("protected Drive NULL Access failed with %d\n"), r); |
|
485 |
if (r != KErrNotReady) |
|
486 |
{ |
|
487 |
test.Printf(_L("protected Drive NULL Access failed with unexpected error %d\n"), r); |
|
488 |
test(0); |
|
489 |
} |
|
490 |
} |
|
491 |
||
492 |
} |
|
493 |
||
494 |
f1.Close(); |
|
495 |
||
496 |
||
497 |
// comment in the next 2 lines to leave the protected area mounted... |
|
498 |
r = fs.RemountDrive(KDriveNumProt, &pckg, (TUint) KForceMediaChangeReOpenMediaDriver); |
|
499 |
test(r == KErrNone); |
|
500 |
||
501 |
thread.Kill(KErrNone); |
|
502 |
thread.Close(); //close handle to thread |
|
503 |
||
504 |
fs.Close(); |
|
505 |
||
506 |
} |