0
|
1 |
// Copyright (c) 1995-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 |
// f32test\server\t_dcdiskadminallfiles.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <f32file.h>
|
|
19 |
#include <e32test.h>
|
|
20 |
#include <e32std.h>
|
|
21 |
#include <e32std_private.h>
|
|
22 |
#include <e32def.h>
|
|
23 |
#include <e32def_private.h>
|
|
24 |
#include <e32svr.h>
|
|
25 |
#include "t_server.h"
|
|
26 |
|
|
27 |
GLDEF_D RTest test(_L("T_DCDISKADMINALLFILES"));
|
|
28 |
GLDEF_D TTime gTimeNow;
|
|
29 |
LOCAL_D TInt gTheDriveNum;
|
|
30 |
|
|
31 |
|
|
32 |
const TInt KPathPosition = 2;
|
|
33 |
_LIT(KExpectedPrivatePath, "\\Private\\00000001\\");
|
|
34 |
_LIT(KResourcePath, "?:\\Resource\\");
|
|
35 |
_LIT(KSystemPath, "?:\\Sys\\");
|
|
36 |
_LIT(KPrivatePath, "?:\\Private\\");
|
|
37 |
_LIT(KPrivateFalseID, "?:\\Private\\FFFFFFFF\\");
|
|
38 |
_LIT(KDriveName, "Billy");
|
|
39 |
_LIT(KVolLable, "Benny");
|
|
40 |
_LIT(KFileSys, "systemfile.txt");
|
|
41 |
_LIT(KFileSys3, "sysfile.rna");
|
|
42 |
_LIT(KFilePri, "privatefile.txt");
|
|
43 |
_LIT(KFilePri2, "privatefile.tmp");
|
|
44 |
_LIT(KFilePri3, "prifile.rna");
|
|
45 |
_LIT(KFileRes, "resourcefile.txt");
|
|
46 |
_LIT(KFileRes3, "resfile.rna");
|
|
47 |
_LIT(KMkDirSub,"Subdir\\");
|
|
48 |
_LIT(KOldFile,"?:\\Anyold.txt");
|
|
49 |
|
|
50 |
#ifndef __WINS__
|
|
51 |
_LIT(KWildPath, "Z:\\SYSTEM\\"); // Until Loader is modified to use /Sys/
|
|
52 |
#else
|
|
53 |
_LIT(KWildPath, "Z:\\SYS\\");
|
|
54 |
#endif
|
|
55 |
_LIT(KWildFile, "*");
|
|
56 |
|
|
57 |
TCapability TheCaps;
|
|
58 |
TBuf<4> driveBuf=_L("?:\\");
|
|
59 |
RFormat format;
|
|
60 |
TInt count;
|
|
61 |
RRawDisk rawdisk;
|
|
62 |
RFile file1;
|
|
63 |
RFile file2;
|
|
64 |
RDir dir;
|
|
65 |
|
|
66 |
TInt r;
|
|
67 |
TBuf<40> fsname;
|
|
68 |
TBuf<40> systestname;
|
|
69 |
TBuf<40> pritestname;
|
|
70 |
TBuf<40> restestname;
|
|
71 |
TBuf<40> theprivatepath;
|
|
72 |
TBuf<40> pritestfalseidname;
|
|
73 |
TBuf<40> mkdirname;
|
|
74 |
TFileName fromTemp;
|
|
75 |
|
|
76 |
TBuf<25> sysfilename;
|
|
77 |
TBuf<30> realName;
|
|
78 |
TBuf<40> shortfilename;
|
|
79 |
TBuf<40> longfilename;
|
|
80 |
|
|
81 |
TRequestStatus aStat1;
|
|
82 |
TRequestStatus aStat2;
|
|
83 |
TRequestStatus aStat3;
|
|
84 |
TRequestStatus aStat4;
|
|
85 |
|
|
86 |
TVolumeInfo aVolInfo;
|
|
87 |
// TDriveInfo adriveInfo;
|
|
88 |
|
|
89 |
TBuf<40> systestfile;
|
|
90 |
TBuf<40> pritestfile;
|
|
91 |
TBuf<40> restestfile;
|
|
92 |
TBuf<40> systestfile1;
|
|
93 |
TBuf<40> pritestfile1;
|
|
94 |
TBuf<40> restestfile1;
|
|
95 |
|
|
96 |
TTime testtime;
|
|
97 |
TBuf<20> oldName;
|
|
98 |
|
|
99 |
TBuf<25> temp;
|
|
100 |
|
|
101 |
TEntry entry;
|
|
102 |
|
|
103 |
|
|
104 |
LOCAL_C void systemRFsTest()
|
|
105 |
//
|
|
106 |
// RFs test on system Directory
|
|
107 |
//
|
|
108 |
{
|
|
109 |
systestname=KSystemPath;
|
|
110 |
systestname[0]=(TText)('A' + gTheDriveNum);
|
|
111 |
|
|
112 |
mkdirname.Zero();
|
|
113 |
mkdirname.Append(systestname);
|
|
114 |
mkdirname.Append(KMkDirSub);
|
|
115 |
r=TheFs.MkDirAll(mkdirname);
|
|
116 |
test(r==KErrPermissionDenied);
|
|
117 |
|
|
118 |
TheFs.RmDir(mkdirname);
|
|
119 |
test(r==KErrPermissionDenied);
|
|
120 |
|
|
121 |
r=TheFs.SetSubst(systestname,EDriveO);
|
|
122 |
test(r==KErrPermissionDenied);
|
|
123 |
|
|
124 |
r=TheFs.SetSessionPath(systestname);
|
|
125 |
test(r==KErrNone);
|
|
126 |
|
|
127 |
TheFs.NotifyChange(ENotifyAll,aStat1,systestname);
|
|
128 |
test(aStat1==KRequestPending);
|
|
129 |
|
|
130 |
systestfile=KSystemPath;
|
|
131 |
systestfile[0]=(TText)('A' + gTheDriveNum);
|
|
132 |
systestfile1=systestfile;
|
|
133 |
systestfile.Append(KFileSys);
|
|
134 |
systestfile1.Append(KFileSys3);
|
|
135 |
|
|
136 |
oldName=KOldFile;
|
|
137 |
oldName[0]=(TText)gDriveToTest;
|
|
138 |
|
|
139 |
r=TheFs.GetShortName(systestfile, shortfilename);
|
|
140 |
test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
|
141 |
|
|
142 |
r=TheFs.GetLongName(systestfile1, longfilename);
|
|
143 |
test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
|
144 |
|
|
145 |
r=file1.Create(TheFs,oldName,EFileWrite);
|
|
146 |
test(r==KErrNone || r==KErrAlreadyExists);
|
|
147 |
file1.Close();
|
|
148 |
|
|
149 |
r=TheFs.Replace(oldName,systestfile);
|
|
150 |
test(r==KErrPermissionDenied);
|
|
151 |
|
|
152 |
r=TheFs.Rename(systestfile,systestfile1);
|
|
153 |
test(r==KErrPermissionDenied);
|
|
154 |
|
|
155 |
r=TheFs.Entry(systestfile1,entry);
|
|
156 |
test(r==KErrNone || KErrNotFound);
|
|
157 |
|
|
158 |
r=TheFs.SetEntry(systestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
|
|
159 |
test(r==KErrPermissionDenied);
|
|
160 |
|
|
161 |
r=TheFs.Delete(systestfile1);
|
|
162 |
test(r==KErrPermissionDenied);
|
|
163 |
}
|
|
164 |
|
|
165 |
LOCAL_C void ResourceRFsTest()
|
|
166 |
//
|
|
167 |
//
|
|
168 |
//
|
|
169 |
{
|
|
170 |
restestname=KResourcePath;
|
|
171 |
restestname[0]=(TText)('A' + gTheDriveNum);
|
|
172 |
|
|
173 |
mkdirname.Zero();
|
|
174 |
mkdirname.Append(restestname);
|
|
175 |
mkdirname.Append(KMkDirSub);
|
|
176 |
r=TheFs.MkDirAll(mkdirname);
|
|
177 |
test(r==KErrPermissionDenied);
|
|
178 |
|
|
179 |
TheFs.RmDir(mkdirname);
|
|
180 |
test(r==KErrPermissionDenied);
|
|
181 |
|
|
182 |
// Change due to defect DEF099546 fix
|
|
183 |
// TCB capability is required for following operation.
|
|
184 |
r=TheFs.SetSubst(restestname,EDriveO);
|
|
185 |
//test(r==KErrNone);
|
|
186 |
test(r==KErrPermissionDenied);
|
|
187 |
|
|
188 |
// SetSubst will fail.
|
|
189 |
//r=TheFs.RealName(_L("O:\\File.XXX"),realName);
|
|
190 |
//test(r==KErrNone);
|
|
191 |
|
|
192 |
//r=TheFs.SetSubst(_L(""),EDriveO);
|
|
193 |
//test(r==KErrNone);
|
|
194 |
|
|
195 |
r=TheFs.SetSessionPath(restestname);
|
|
196 |
test(r==KErrNone);
|
|
197 |
|
|
198 |
TheFs.NotifyChange(ENotifyAll,aStat4,restestname);
|
|
199 |
test(aStat4==KRequestPending);
|
|
200 |
|
|
201 |
restestfile=KResourcePath;
|
|
202 |
restestfile[0]=(TText)('A' + gTheDriveNum);
|
|
203 |
restestfile1=restestfile;
|
|
204 |
restestfile.Append(KFileRes);
|
|
205 |
restestfile1.Append(KFileRes3);
|
|
206 |
|
|
207 |
oldName=KOldFile;
|
|
208 |
oldName[0]=(TText)gDriveToTest;
|
|
209 |
|
|
210 |
r=TheFs.GetShortName(restestfile, shortfilename);
|
|
211 |
test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
|
212 |
|
|
213 |
r=TheFs.GetLongName(restestfile1, longfilename);
|
|
214 |
test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
|
215 |
|
|
216 |
r=file1.Create(TheFs,oldName,EFileWrite);
|
|
217 |
test(r==KErrNone || r==KErrAlreadyExists);
|
|
218 |
file1.Close();
|
|
219 |
|
|
220 |
r=TheFs.Replace(oldName,restestfile);
|
|
221 |
test(r==KErrPermissionDenied);
|
|
222 |
|
|
223 |
r=TheFs.Rename(restestfile,restestfile1);
|
|
224 |
test(r==KErrPermissionDenied);
|
|
225 |
|
|
226 |
r=TheFs.Entry(restestfile1,entry);
|
|
227 |
test(r==KErrNone || r==KErrPathNotFound || r==KErrNotFound);
|
|
228 |
|
|
229 |
r=TheFs.SetEntry(restestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
|
|
230 |
test(r==KErrPermissionDenied);
|
|
231 |
|
|
232 |
r=TheFs.Delete(restestfile1);
|
|
233 |
test(r==KErrPermissionDenied);
|
|
234 |
|
|
235 |
}
|
|
236 |
|
|
237 |
|
|
238 |
LOCAL_C void privatefalseIDRFsTest()
|
|
239 |
//
|
|
240 |
//
|
|
241 |
//
|
|
242 |
{
|
|
243 |
pritestfalseidname=KPrivateFalseID;
|
|
244 |
pritestfalseidname[0]=(TText)('A' + gTheDriveNum);
|
|
245 |
|
|
246 |
mkdirname.Zero();
|
|
247 |
mkdirname.Append(pritestfalseidname);
|
|
248 |
mkdirname.Append(KMkDirSub);
|
|
249 |
|
|
250 |
r=TheFs.MkDirAll(mkdirname);
|
|
251 |
test(r==KErrNone);
|
|
252 |
|
|
253 |
r=TheFs.RmDir(mkdirname);
|
|
254 |
test(r==KErrNone);
|
|
255 |
|
|
256 |
r=TheFs.SetSubst(pritestfalseidname,EDriveO);
|
|
257 |
test(r==KErrNone);
|
|
258 |
|
|
259 |
r=TheFs.RealName(_L("O:\\File.XXX"),realName);
|
|
260 |
test(r==KErrNone);
|
|
261 |
|
|
262 |
r=TheFs.SetSubst(_L(""),EDriveO);
|
|
263 |
test(r==KErrNone);
|
|
264 |
|
|
265 |
r=TheFs.SetSessionPath(pritestfalseidname);
|
|
266 |
test(r==KErrNone);
|
|
267 |
|
|
268 |
TheFs.NotifyChange(ENotifyAll,aStat2,pritestfalseidname);
|
|
269 |
test(aStat2==KRequestPending);
|
|
270 |
|
|
271 |
|
|
272 |
pritestfile=KPrivateFalseID;
|
|
273 |
pritestfile[0]=(TText)('A' + gTheDriveNum);
|
|
274 |
pritestfile1=pritestfile;
|
|
275 |
pritestfile.Append(KFilePri2);
|
|
276 |
pritestfile1.Append(KFilePri3);
|
|
277 |
|
|
278 |
oldName=KOldFile;
|
|
279 |
oldName[0]=(TText)gDriveToTest;
|
|
280 |
|
|
281 |
r=TheFs.GetShortName(pritestfile, shortfilename);
|
|
282 |
test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
|
283 |
|
|
284 |
r=TheFs.GetLongName(pritestfile1, longfilename);
|
|
285 |
test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
|
286 |
|
|
287 |
r=file1.Create(TheFs,oldName,EFileWrite);
|
|
288 |
test(r==KErrNone || r==KErrAlreadyExists);
|
|
289 |
file1.Close();
|
|
290 |
|
|
291 |
r=TheFs.Replace(oldName,pritestfile);
|
|
292 |
test(r==KErrNone);
|
|
293 |
|
|
294 |
r=TheFs.Rename(pritestfile,pritestfile1);
|
|
295 |
test(r==KErrNone);
|
|
296 |
|
|
297 |
r=TheFs.Entry(pritestfile1,entry);
|
|
298 |
test(r==KErrNone);
|
|
299 |
|
|
300 |
r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
|
|
301 |
test(r==KErrNone);
|
|
302 |
|
|
303 |
r=TheFs.Delete(pritestfile1);
|
|
304 |
test(r==KErrNone);
|
|
305 |
|
|
306 |
}
|
|
307 |
|
|
308 |
|
|
309 |
LOCAL_C void privateRFsTest()
|
|
310 |
//
|
|
311 |
//
|
|
312 |
//
|
|
313 |
{
|
|
314 |
//private
|
|
315 |
pritestname=KPrivatePath;
|
|
316 |
pritestname[0]=(TText)('A' + gTheDriveNum);
|
|
317 |
|
|
318 |
mkdirname.Zero();
|
|
319 |
mkdirname.Append(pritestname);
|
|
320 |
mkdirname.Append(KMkDirSub);
|
|
321 |
|
|
322 |
r=TheFs.MkDirAll(mkdirname);
|
|
323 |
test(r==KErrNone);
|
|
324 |
|
|
325 |
r=TheFs.RmDir(mkdirname);
|
|
326 |
test(r==KErrNone);
|
|
327 |
|
|
328 |
r=TheFs.SetSubst(pritestname,EDriveO);
|
|
329 |
test(r==KErrNone);
|
|
330 |
|
|
331 |
r=TheFs.RealName(_L("O:\\File.XXX"),realName);
|
|
332 |
test(r==KErrNone);
|
|
333 |
|
|
334 |
r=TheFs.SetSubst(_L(""),EDriveO);
|
|
335 |
test(r==KErrNone);
|
|
336 |
|
|
337 |
r=TheFs.SetSessionPath(pritestname);
|
|
338 |
test(r==KErrNone);
|
|
339 |
|
|
340 |
TheFs.NotifyChange(ENotifyAll,aStat2,pritestname);
|
|
341 |
test(aStat2==KRequestPending);
|
|
342 |
|
|
343 |
|
|
344 |
pritestfile=KPrivatePath;
|
|
345 |
pritestfile[0]=(TText)('A' + gTheDriveNum);
|
|
346 |
pritestfile1=pritestfile;
|
|
347 |
pritestfile.Append(KFilePri2);
|
|
348 |
pritestfile1.Append(KFilePri3);
|
|
349 |
|
|
350 |
oldName=KOldFile;
|
|
351 |
oldName[0]=(TText)gDriveToTest;
|
|
352 |
|
|
353 |
r=TheFs.GetShortName(pritestfile, shortfilename);
|
|
354 |
test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
|
355 |
|
|
356 |
r=TheFs.GetLongName(pritestfile1, longfilename);
|
|
357 |
test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
|
358 |
|
|
359 |
r=file1.Create(TheFs,oldName,EFileWrite);
|
|
360 |
test(r==KErrNone || r==KErrAlreadyExists);
|
|
361 |
file1.Close();
|
|
362 |
|
|
363 |
r=TheFs.Replace(oldName,pritestfile);
|
|
364 |
test(r==KErrNone || r==KErrNotFound);
|
|
365 |
|
|
366 |
r=TheFs.Rename(pritestfile,pritestfile1);
|
|
367 |
test(r==KErrNone);
|
|
368 |
|
|
369 |
r=TheFs.Entry(pritestfile1,entry);
|
|
370 |
test(r==KErrNone);
|
|
371 |
|
|
372 |
r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
|
|
373 |
test(r==KErrNone);
|
|
374 |
|
|
375 |
r=TheFs.Delete(pritestfile1);
|
|
376 |
test(r==KErrNone);
|
|
377 |
|
|
378 |
}
|
|
379 |
|
|
380 |
|
|
381 |
LOCAL_C void privateSIDRFstest()
|
|
382 |
{
|
|
383 |
theprivatepath[0]=(TText)gDriveToTest;
|
|
384 |
test.Printf(_L("the Private Path = %S"),&theprivatepath);
|
|
385 |
|
|
386 |
mkdirname.Zero();
|
|
387 |
mkdirname.Append(theprivatepath);
|
|
388 |
mkdirname.Append(KMkDirSub);
|
|
389 |
r=TheFs.MkDirAll(mkdirname);
|
|
390 |
test(r==KErrNone);
|
|
391 |
|
|
392 |
r=TheFs.RmDir(mkdirname);
|
|
393 |
test(r==KErrNone);
|
|
394 |
|
|
395 |
r=TheFs.SetSubst(theprivatepath,EDriveO);
|
|
396 |
test(r==KErrNone);
|
|
397 |
|
|
398 |
r=TheFs.RealName(_L("O:\\File.XXX"),realName);
|
|
399 |
test(r==KErrNone);
|
|
400 |
|
|
401 |
r=TheFs.SetSubst(_L(""),EDriveO);
|
|
402 |
test(r==KErrNone);
|
|
403 |
|
|
404 |
r=TheFs.SetSessionPath(theprivatepath);
|
|
405 |
test(r==KErrNone);
|
|
406 |
|
|
407 |
TheFs.NotifyChange(ENotifyAll,aStat3,theprivatepath);
|
|
408 |
test(aStat3==KRequestPending);
|
|
409 |
|
|
410 |
pritestfile=theprivatepath;
|
|
411 |
pritestfile[0]=(TText)('A' + gTheDriveNum);
|
|
412 |
pritestfile1=pritestfile;
|
|
413 |
pritestfile.Append(KFilePri2);
|
|
414 |
pritestfile1.Append(KFilePri3);
|
|
415 |
|
|
416 |
oldName=KOldFile;
|
|
417 |
oldName[0]=(TText)gDriveToTest;
|
|
418 |
|
|
419 |
r=TheFs.GetShortName(pritestfile, shortfilename);
|
|
420 |
test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
|
421 |
|
|
422 |
r=TheFs.GetLongName(pritestfile1, longfilename);
|
|
423 |
test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
|
|
424 |
|
|
425 |
r=file1.Create(TheFs,oldName,EFileWrite);
|
|
426 |
test(r==KErrNone || r==KErrAlreadyExists);
|
|
427 |
file1.Close();
|
|
428 |
|
|
429 |
r=TheFs.Replace(oldName,pritestfile);
|
|
430 |
test(r==KErrNone);
|
|
431 |
|
|
432 |
r=TheFs.Rename(pritestfile,pritestfile1);
|
|
433 |
test(r==KErrNone || r==KErrAlreadyExists);
|
|
434 |
|
|
435 |
r=TheFs.Entry(pritestfile1,entry);
|
|
436 |
test(r==KErrNone);
|
|
437 |
|
|
438 |
r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
|
|
439 |
test(r==KErrNone);
|
|
440 |
|
|
441 |
r=TheFs.Delete(pritestfile1);
|
|
442 |
test(r==KErrNone);
|
|
443 |
}
|
|
444 |
|
|
445 |
|
|
446 |
LOCAL_C void systemRFiletest()
|
|
447 |
//
|
|
448 |
//RFile testing with session path set to //system//
|
|
449 |
//
|
|
450 |
{
|
|
451 |
|
|
452 |
r=TheFs.SetSessionPath(systestname);
|
|
453 |
test(r==KErrNone);
|
|
454 |
|
|
455 |
r=file1.Temp(TheFs,systestname,fromTemp,EFileWrite);
|
|
456 |
test(r==KErrPermissionDenied);
|
|
457 |
file1.Close();
|
|
458 |
|
|
459 |
systestfile=systestname;
|
|
460 |
systestfile.Append(KFileSys);
|
|
461 |
r=file1.Create(TheFs,systestfile,EFileWrite);
|
|
462 |
test(r==KErrPermissionDenied);
|
|
463 |
file1.Close();
|
|
464 |
|
|
465 |
r=file1.Open(TheFs,systestfile,EFileWrite);
|
|
466 |
test(r==KErrPermissionDenied);
|
|
467 |
|
|
468 |
r=file1.Open(TheFs,systestfile,EFileRead);
|
|
469 |
test(r==KErrNone|| r==KErrNotFound);
|
|
470 |
|
|
471 |
r=file1.Replace(TheFs,systestfile,EFileWrite);
|
|
472 |
test(r==KErrPermissionDenied);
|
|
473 |
|
|
474 |
TFindFile finder(TheFs);
|
|
475 |
CDir* dir = NULL;
|
|
476 |
r=finder.FindWildByDir(KWildFile, KWildPath, dir);
|
|
477 |
if (!(r==KErrNone))
|
|
478 |
test.Printf(_L("T_DCDISKADMINALLFILES: test find wildcards r = %d (expected KErrNone)\n"), r);
|
|
479 |
test(r==KErrNone);
|
|
480 |
delete dir;
|
|
481 |
}
|
|
482 |
|
|
483 |
LOCAL_C void resourceRFiletest()
|
|
484 |
//
|
|
485 |
//RFile testing with session path set to //resource//
|
|
486 |
//
|
|
487 |
{
|
|
488 |
r=TheFs.SetSessionPath(restestname);
|
|
489 |
test(r==KErrNone);
|
|
490 |
|
|
491 |
r=file1.Temp(TheFs,restestname,fromTemp,EFileWrite);
|
|
492 |
test(r==KErrPermissionDenied);
|
|
493 |
file1.Close();
|
|
494 |
|
|
495 |
r=file1.Create(TheFs,KFileRes,EFileWrite);
|
|
496 |
test(r==KErrPermissionDenied);
|
|
497 |
file1.Close();
|
|
498 |
|
|
499 |
r=file1.Open(TheFs,KFileRes,EFileWrite|EFileShareExclusive );
|
|
500 |
test(r==KErrPermissionDenied);
|
|
501 |
|
|
502 |
r=file1.Open(TheFs,KFileRes,EFileShareReadersOnly);
|
|
503 |
test(r==KErrNone || KErrPathNotFound || KErrNotFound);
|
|
504 |
file1.Close();
|
|
505 |
|
|
506 |
r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileRead);
|
|
507 |
test(r==KErrNone || KErrPathNotFound || KErrNotFound);
|
|
508 |
file1.Close();
|
|
509 |
|
|
510 |
r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileWrite);
|
|
511 |
test(r==KErrPermissionDenied);
|
|
512 |
file1.Close();
|
|
513 |
|
|
514 |
r=file1.Replace(TheFs,KFileRes3,EFileWrite);
|
|
515 |
test(r==KErrPermissionDenied);
|
|
516 |
file1.Close();
|
|
517 |
}
|
|
518 |
|
|
519 |
|
|
520 |
LOCAL_C void privatefalseIDRFiletest()
|
|
521 |
//
|
|
522 |
//RFile testing with session path set to //Private//false ID
|
|
523 |
//
|
|
524 |
{
|
|
525 |
r=TheFs.SetSessionPath(pritestfalseidname);
|
|
526 |
test(r==KErrNone);
|
|
527 |
|
|
528 |
r=file1.Temp(TheFs,pritestfalseidname,fromTemp,EFileWrite);
|
|
529 |
test(r==KErrNone);
|
|
530 |
file1.Close();
|
|
531 |
|
|
532 |
r=file1.Create(TheFs,KFilePri,EFileWrite);
|
|
533 |
test(r==KErrNone);
|
|
534 |
file1.Close();
|
|
535 |
|
|
536 |
r=file1.Open(TheFs,KFilePri,EFileWrite);
|
|
537 |
test(r==KErrNone);
|
|
538 |
file1.Close();
|
|
539 |
|
|
540 |
r=file1.Open(TheFs,KFilePri,EFileRead);
|
|
541 |
test(r==KErrNone);
|
|
542 |
file1.Close();
|
|
543 |
|
|
544 |
r=file1.Replace(TheFs,KFilePri,EFileWrite);
|
|
545 |
test(r==KErrNone);
|
|
546 |
|
|
547 |
r=file1.Rename(KFilePri3);
|
|
548 |
test(r==KErrNone);
|
|
549 |
file1.Close();
|
|
550 |
}
|
|
551 |
|
|
552 |
|
|
553 |
LOCAL_C void privateRFiletest()
|
|
554 |
//
|
|
555 |
//RFile testing with session path set to //Private//
|
|
556 |
//
|
|
557 |
{
|
|
558 |
r=TheFs.SetSessionPath(pritestname);
|
|
559 |
test(r==KErrNone);
|
|
560 |
|
|
561 |
r=file1.Temp(TheFs,pritestname,fromTemp,EFileWrite);
|
|
562 |
test(r==KErrNone);
|
|
563 |
file1.Close();
|
|
564 |
|
|
565 |
r=file1.Create(TheFs,KFilePri,EFileWrite);
|
|
566 |
test(r==KErrNone);
|
|
567 |
file1.Close();
|
|
568 |
|
|
569 |
r=file1.Open(TheFs,KFilePri,EFileWrite);
|
|
570 |
test(r==KErrNone);
|
|
571 |
file1.Close();
|
|
572 |
|
|
573 |
r=file1.Open(TheFs,KFilePri,EFileRead);
|
|
574 |
test(r==KErrNone);
|
|
575 |
file1.Close();
|
|
576 |
|
|
577 |
r=file1.Replace(TheFs,KFilePri,EFileWrite);
|
|
578 |
test(r==KErrNone);
|
|
579 |
|
|
580 |
r=file1.Rename(KFilePri3);
|
|
581 |
test(r==KErrNone);
|
|
582 |
file1.Close();
|
|
583 |
}
|
|
584 |
|
|
585 |
|
|
586 |
LOCAL_C void privateSIDRFiletest()
|
|
587 |
//
|
|
588 |
//Rfile Testing with session path set to //Private//UID//
|
|
589 |
//
|
|
590 |
{
|
|
591 |
r=TheFs.SetSessionToPrivate(gTheDriveNum);
|
|
592 |
test(r==KErrNone);
|
|
593 |
|
|
594 |
r=file1.Temp(TheFs,theprivatepath,fromTemp,EFileWrite);
|
|
595 |
test(r==KErrNone);
|
|
596 |
file1.Close();
|
|
597 |
|
|
598 |
r=file1.Create(TheFs,KFilePri,EFileWrite);
|
|
599 |
test(r==KErrNone);
|
|
600 |
file1.Close();
|
|
601 |
|
|
602 |
r=file1.Open(TheFs,KFilePri,EFileWrite);
|
|
603 |
test(r==KErrNone);
|
|
604 |
file1.Close();
|
|
605 |
|
|
606 |
r=file1.Open(TheFs,KFilePri,EFileRead);
|
|
607 |
test(r==KErrNone);
|
|
608 |
file1.Close();
|
|
609 |
|
|
610 |
|
|
611 |
r=file1.Replace(TheFs,KFilePri,EFileWrite);
|
|
612 |
test(r==KErrNone);
|
|
613 |
|
|
614 |
r=file1.Rename(KFilePri3);
|
|
615 |
test(r==KErrNone);
|
|
616 |
file1.Close();
|
|
617 |
}
|
|
618 |
|
|
619 |
LOCAL_C void RDirtest()
|
|
620 |
//
|
|
621 |
//
|
|
622 |
//
|
|
623 |
{
|
|
624 |
|
|
625 |
//system
|
|
626 |
CDir* dirEntries;
|
|
627 |
TBuf<30> dirNameBuf(KSystemPath);
|
|
628 |
dirNameBuf[0]=(TText)gDriveToTest;
|
|
629 |
r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
|
|
630 |
test(r==KErrNone || r==KErrPathNotFound || r==KErrNotFound);
|
|
631 |
dir.Close();
|
|
632 |
if(r==KErrNone)
|
|
633 |
{
|
|
634 |
r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
|
|
635 |
test(r==KErrNone);
|
|
636 |
delete dirEntries;
|
|
637 |
}
|
|
638 |
dirNameBuf.Zero();
|
|
639 |
//Private//falseID
|
|
640 |
dirNameBuf=KPrivateFalseID;
|
|
641 |
dirNameBuf[0]=(TText)gDriveToTest;
|
|
642 |
r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
|
|
643 |
test(r==KErrNone);
|
|
644 |
dir.Close();
|
|
645 |
r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
|
|
646 |
test(r==KErrNone);
|
|
647 |
dirNameBuf.Zero();
|
|
648 |
delete dirEntries;
|
|
649 |
//Private
|
|
650 |
dirNameBuf=KPrivatePath;
|
|
651 |
dirNameBuf[0]=(TText)gDriveToTest;
|
|
652 |
r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
|
|
653 |
test(r==KErrNone);
|
|
654 |
dir.Close();
|
|
655 |
r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
|
|
656 |
test(r==KErrNone);
|
|
657 |
dirNameBuf.Zero();
|
|
658 |
delete dirEntries;
|
|
659 |
//Private/uid
|
|
660 |
TheFs.PrivatePath(dirNameBuf);
|
|
661 |
dirNameBuf.Insert(0,_L("?:"));
|
|
662 |
dirNameBuf[0]=(TText)gDriveToTest;
|
|
663 |
r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
|
|
664 |
test(r==KErrNone);
|
|
665 |
dir.Close();
|
|
666 |
r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
|
|
667 |
test(r==KErrNone);
|
|
668 |
dirNameBuf.Zero();
|
|
669 |
delete dirEntries;
|
|
670 |
//Resource
|
|
671 |
dirNameBuf=KResourcePath;
|
|
672 |
dirNameBuf[0]=(TText)gDriveToTest;
|
|
673 |
r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
|
|
674 |
test(r==KErrNone || r==KErrPathNotFound);
|
|
675 |
if(r==KErrNone)
|
|
676 |
{
|
|
677 |
r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
|
|
678 |
test(r==KErrNone);
|
|
679 |
dir.Close();
|
|
680 |
delete dirEntries;
|
|
681 |
}
|
|
682 |
}
|
|
683 |
|
|
684 |
|
|
685 |
LOCAL_C void TestDiskAdminAllfiles()
|
|
686 |
//
|
|
687 |
// Test with root capabilities
|
|
688 |
//
|
|
689 |
{
|
|
690 |
r=TheFs.FileSystemName(fsname,gTheDriveNum);
|
|
691 |
test(r==KErrNone);
|
|
692 |
r = DismountFileSystem(TheFs, fsname, gTheDriveNum);
|
|
693 |
test(r==KErrNone);
|
|
694 |
// r=TheFs.RemoveFileSystem(fsname); //can not test due to bug else where fix exists
|
|
695 |
// test(r==KErrNone);
|
|
696 |
// r=TheFs.AddFileSystem(fsname);
|
|
697 |
// test(r==KErrNone);
|
|
698 |
r = MountFileSystem(TheFs, fsname, gTheDriveNum);
|
|
699 |
test(r==KErrNone);
|
|
700 |
r=TheFs.SetDriveName(gTheDriveNum,KDriveName);
|
|
701 |
test(r==KErrNone);
|
|
702 |
#ifndef __WINS__
|
|
703 |
r=TheFs.SetVolumeLabel(KVolLable, gTheDriveNum);
|
|
704 |
test(r==KErrNone);
|
|
705 |
#endif
|
|
706 |
|
|
707 |
systemRFsTest();
|
|
708 |
ResourceRFsTest();
|
|
709 |
privateRFsTest();
|
|
710 |
privateSIDRFstest();
|
|
711 |
privatefalseIDRFsTest();
|
|
712 |
|
|
713 |
systemRFiletest();
|
|
714 |
resourceRFiletest();
|
|
715 |
privateRFiletest();
|
|
716 |
privateSIDRFiletest();
|
|
717 |
privatefalseIDRFiletest();
|
|
718 |
|
|
719 |
//check notifier return values set in rfs testing
|
|
720 |
//User::WaitForRequest(aStat1);
|
|
721 |
User::WaitForRequest(aStat2);
|
|
722 |
User::WaitForRequest(aStat3);
|
|
723 |
//User::WaitForRequest(aStat4);
|
|
724 |
test(aStat2==KErrNone);
|
|
725 |
test(aStat3==KErrNone);
|
|
726 |
|
|
727 |
test(aStat1 == KRequestPending);
|
|
728 |
TheFs.NotifyChangeCancel(aStat1);
|
|
729 |
test(aStat1==KErrCancel);
|
|
730 |
|
|
731 |
test(aStat4 == KRequestPending);
|
|
732 |
TheFs.NotifyChangeCancel(aStat4);
|
|
733 |
test(aStat4==KErrCancel);
|
|
734 |
|
|
735 |
r=TheFs.SetSessionPath(systestname);
|
|
736 |
test(r==KErrNone);
|
|
737 |
|
|
738 |
//Test RRawDisk class
|
|
739 |
r=rawdisk.Open(TheFs,gTheDriveNum);
|
|
740 |
test(r==KErrPermissionDenied);
|
|
741 |
rawdisk.Close();
|
|
742 |
|
|
743 |
RDirtest();
|
|
744 |
|
|
745 |
#ifdef __WINS__
|
|
746 |
if (User::UpperCase(driveBuf[0]) != 'C')
|
|
747 |
#endif
|
|
748 |
{
|
|
749 |
//Test RFormat class
|
|
750 |
r=format.Open(TheFs,driveBuf,EHighDensity,count);
|
|
751 |
test(r==KErrNone);
|
|
752 |
while(count)
|
|
753 |
{
|
|
754 |
TInt r=format.Next(count);
|
|
755 |
test(r==KErrNone);
|
|
756 |
}
|
|
757 |
format.Close();
|
|
758 |
}
|
|
759 |
|
|
760 |
driveBuf[0]=(TText)gDriveToTest;
|
|
761 |
r=TheFs.ScanDrive(driveBuf);
|
|
762 |
test(r==KErrNone || r==KErrNotSupported || KErrInUse);
|
|
763 |
r=TheFs.CheckDisk(driveBuf);
|
|
764 |
test(r==KErrNone || r==KErrNotSupported || KErrInUse);
|
|
765 |
}
|
|
766 |
|
|
767 |
LOCAL_C void TestCaps()
|
|
768 |
//
|
|
769 |
// test format etc that require certain capabilities
|
|
770 |
//
|
|
771 |
{
|
|
772 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
|
|
773 |
const char myDiagMsg[] = "Capability Check Failure";
|
|
774 |
#endif //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
|
|
775 |
r=RProcess().HasCapability(ECapabilityAllFiles, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
|
|
776 |
test(r);
|
|
777 |
r=RProcess().HasCapability(ECapabilityDiskAdmin, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
|
|
778 |
test(r);
|
|
779 |
|
|
780 |
driveBuf[0]=(TText)gDriveToTest;
|
|
781 |
r=TheFs.SessionPath(temp);
|
|
782 |
test(r==KErrNone);
|
|
783 |
|
|
784 |
test.Printf(_L("Session path: %S"),&temp);
|
|
785 |
|
|
786 |
r=TheFs.CreatePrivatePath(gTheDriveNum);
|
|
787 |
test(r==KErrNone || r== KErrAlreadyExists);
|
|
788 |
|
|
789 |
TBuf<18> tempPri;
|
|
790 |
r=TheFs.PrivatePath(tempPri);
|
|
791 |
test(r==KErrNone);
|
|
792 |
theprivatepath = _L("?:");
|
|
793 |
theprivatepath.Append(tempPri);
|
|
794 |
|
|
795 |
TestDiskAdminAllfiles();
|
|
796 |
|
|
797 |
TFileName thesessionpath;
|
|
798 |
r=TheFs.SetSessionToPrivate(gTheDriveNum);
|
|
799 |
test(r==KErrNone);
|
|
800 |
r=TheFs.SessionPath(thesessionpath);
|
|
801 |
test(r==KErrNone);
|
|
802 |
test(thesessionpath == theprivatepath);
|
|
803 |
}
|
|
804 |
|
|
805 |
|
|
806 |
LOCAL_C void CleanupL()
|
|
807 |
//
|
|
808 |
// Clean up tests
|
|
809 |
//
|
|
810 |
{
|
|
811 |
test.Next(_L("Delete test directory"));
|
|
812 |
CFileMan* fMan=CFileMan::NewL(TheFs);
|
|
813 |
TInt r=fMan->RmDir(gSessionPath);
|
|
814 |
test(r==KErrNone || KErrPathNotFound);
|
|
815 |
delete fMan;
|
|
816 |
}
|
|
817 |
|
|
818 |
GLDEF_C void CallTestsL(/*TChar aDriveLetter*/)
|
|
819 |
//
|
|
820 |
// Do all tests
|
|
821 |
//
|
|
822 |
{
|
|
823 |
if( !PlatSec::IsCapabilityEnforced(ECapabilityAllFiles) ||
|
|
824 |
!PlatSec::IsCapabilityEnforced(ECapabilityDiskAdmin))
|
|
825 |
{
|
|
826 |
test.Printf(_L("Capabilities insufficient - leaving t_dcdiskadminallfiles"));
|
|
827 |
test.Printf(_L("\n")); // Prevent overwrite by next print
|
|
828 |
return;
|
|
829 |
}
|
|
830 |
TurnAllocFailureOff();
|
|
831 |
TheFs.CharToDrive(gDriveToTest,gTheDriveNum);
|
|
832 |
|
|
833 |
TBuf<30> sesspath;
|
|
834 |
sesspath=_L("?:\\");
|
|
835 |
sesspath[0] = (TText)gDriveToTest;
|
|
836 |
|
|
837 |
TInt r= TheFs.SetSessionPath(sesspath);
|
|
838 |
test(r==KErrNone);
|
|
839 |
|
|
840 |
TBuf<2> cmd;
|
|
841 |
cmd.SetLength(1);
|
|
842 |
cmd[0] = (TText)gDriveToTest;
|
|
843 |
RProcess tp;
|
|
844 |
r=tp.Create(_L("clean_prepdc.exe"),sesspath);
|
|
845 |
test(r==KErrNone);
|
|
846 |
{
|
|
847 |
TRequestStatus ps;
|
|
848 |
tp.Logon(ps);
|
|
849 |
tp.Resume();
|
|
850 |
tp.Close();
|
|
851 |
User::WaitForRequest(ps);
|
|
852 |
}
|
|
853 |
|
|
854 |
//check double mode ie that Defpath still works
|
|
855 |
RFs fs1;
|
|
856 |
RFs fs2;
|
|
857 |
|
|
858 |
r=fs1.Connect();
|
|
859 |
test(r==KErrNone);
|
|
860 |
r=fs1.SessionPath(sesspath);
|
|
861 |
test(r==KErrNone);
|
|
862 |
test.Printf(_L("session1 Path=%S"),&sesspath);
|
|
863 |
|
|
864 |
TBuf<30> privatepath;
|
|
865 |
r=fs1.SetSessionToPrivate(gTheDriveNum);
|
|
866 |
test(r==KErrNone);
|
|
867 |
r=fs1.PrivatePath(privatepath);
|
|
868 |
test(r==KErrNone);
|
|
869 |
r=privatepath.Compare(KExpectedPrivatePath());
|
|
870 |
test(r==0);
|
|
871 |
r=fs1.SessionPath(sesspath);
|
|
872 |
test(r==KErrNone);
|
|
873 |
r=privatepath.Compare(sesspath.Mid(KPathPosition));
|
|
874 |
test(r==0);
|
|
875 |
r=fs1.CreatePrivatePath(gTheDriveNum);
|
|
876 |
test(r==KErrNone);
|
|
877 |
fs1.Close();
|
|
878 |
|
|
879 |
r=fs2.Connect();
|
|
880 |
test(r==KErrNone);
|
|
881 |
r=fs2.SessionPath(sesspath);
|
|
882 |
test(r==KErrNone);
|
|
883 |
test.Printf(_L("session2 Path=%S"),&sesspath);
|
|
884 |
fs2.Close();
|
|
885 |
|
|
886 |
TestCaps();
|
|
887 |
|
|
888 |
test.Printf(_L("No of files open=%d"), TheFs.ResourceCount());
|
|
889 |
|
|
890 |
CleanupL();
|
|
891 |
}
|