sl@0
|
1 |
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <f32file.h>
|
sl@0
|
17 |
#include <e32test.h>
|
sl@0
|
18 |
#include <e32std.h>
|
sl@0
|
19 |
#include <e32std_private.h>
|
sl@0
|
20 |
#include <e32def.h>
|
sl@0
|
21 |
#include <e32def_private.h>
|
sl@0
|
22 |
#include <e32svr.h>
|
sl@0
|
23 |
#include "t_server.h"
|
sl@0
|
24 |
|
sl@0
|
25 |
GLDEF_D RTest test(_L("t_dcnone"));
|
sl@0
|
26 |
GLDEF_D TTime gTimeNow;
|
sl@0
|
27 |
LOCAL_D TInt gTheDriveNum;
|
sl@0
|
28 |
|
sl@0
|
29 |
//_LIT(KDefPath, "\\Default\\");
|
sl@0
|
30 |
|
sl@0
|
31 |
const TInt KPathPosition = 2;
|
sl@0
|
32 |
_LIT(KExpectedPrivatePath, "\\Private\\00000001\\");
|
sl@0
|
33 |
|
sl@0
|
34 |
|
sl@0
|
35 |
_LIT(KResourcePath, "?:\\Resource\\");
|
sl@0
|
36 |
_LIT(KSystemPath, "?:\\Sys\\");
|
sl@0
|
37 |
_LIT(KPrivatePath, "?:\\Private\\");
|
sl@0
|
38 |
_LIT(KPrivateFalseID, "?:\\Private\\FFFFFFFF\\");
|
sl@0
|
39 |
_LIT(KDriveName, "Billy");
|
sl@0
|
40 |
//_LIT(KVolLable, "Benny");
|
sl@0
|
41 |
|
sl@0
|
42 |
_LIT(KFileSys, "systemfile.txt");
|
sl@0
|
43 |
//_LIT(KFileSys2, "systemfile.tmp");
|
sl@0
|
44 |
_LIT(KFileSys3, "sysfile.rna");
|
sl@0
|
45 |
|
sl@0
|
46 |
_LIT(KFilePri, "privatefile.txt");
|
sl@0
|
47 |
_LIT(KFilePri2, "privatefile.tmp");
|
sl@0
|
48 |
_LIT(KFilePri3, "prifile.rna");
|
sl@0
|
49 |
|
sl@0
|
50 |
_LIT(KFileRes, "resourcefile.txt");
|
sl@0
|
51 |
//_LIT(KFileRes2, "resourcefile.tmp");
|
sl@0
|
52 |
_LIT(KFileRes3, "resfile.rna");
|
sl@0
|
53 |
|
sl@0
|
54 |
_LIT(KMkDirSub,"Subdir\\");
|
sl@0
|
55 |
_LIT(KOldFile,"?:\\Anyold.txt");
|
sl@0
|
56 |
//_LIT(KNullPath, "");
|
sl@0
|
57 |
//_LIT(KLFFSName, "Lffs");
|
sl@0
|
58 |
|
sl@0
|
59 |
_LIT(KWildPath, "Z:\\SYS\\");
|
sl@0
|
60 |
_LIT(KWildFile, "*");
|
sl@0
|
61 |
|
sl@0
|
62 |
_LIT(KPrivatePathTest1, "\\Private\\00000001");
|
sl@0
|
63 |
_LIT(KPrivatePathTest2, "\\Private\\FFFFFFFF");
|
sl@0
|
64 |
_LIT(KPrivatePathTest3, "\\Private\\FFFFFFFF\\");
|
sl@0
|
65 |
TInt theDrive=0;
|
sl@0
|
66 |
TCapability TheCaps;
|
sl@0
|
67 |
TBuf<4> driveBuf=_L("?:\\");
|
sl@0
|
68 |
RFormat format;
|
sl@0
|
69 |
TInt count;
|
sl@0
|
70 |
RRawDisk rawdisk;
|
sl@0
|
71 |
RFile file1;
|
sl@0
|
72 |
RFile file2;
|
sl@0
|
73 |
RDir dir;
|
sl@0
|
74 |
CDir* dirEntries;
|
sl@0
|
75 |
TInt r;
|
sl@0
|
76 |
TBuf<40> fsname;
|
sl@0
|
77 |
TBuf<40> systestname;
|
sl@0
|
78 |
TBuf<40> pritestname;
|
sl@0
|
79 |
TBuf<40> restestname;
|
sl@0
|
80 |
TBuf<40> theprivatepath;
|
sl@0
|
81 |
TBuf<40> pritestfalseidname;
|
sl@0
|
82 |
TBuf<40> mkdirname;
|
sl@0
|
83 |
TFileName fromTemp;
|
sl@0
|
84 |
|
sl@0
|
85 |
|
sl@0
|
86 |
TBuf<25> prifilename;
|
sl@0
|
87 |
TBuf<25> sysfilename;
|
sl@0
|
88 |
TBuf<30> realName;
|
sl@0
|
89 |
TBuf<40> shortfilename;
|
sl@0
|
90 |
TBuf<40> longfilename;
|
sl@0
|
91 |
|
sl@0
|
92 |
TRequestStatus aStat1;
|
sl@0
|
93 |
TRequestStatus aStat2;
|
sl@0
|
94 |
TRequestStatus aStat3;
|
sl@0
|
95 |
TRequestStatus aStat4;
|
sl@0
|
96 |
|
sl@0
|
97 |
TVolumeInfo aVolInfo;
|
sl@0
|
98 |
// TDriveInfo adriveInfo;
|
sl@0
|
99 |
|
sl@0
|
100 |
TBuf<40> systestfile;
|
sl@0
|
101 |
TBuf<40> pritestfile;
|
sl@0
|
102 |
TBuf<40> restestfile;
|
sl@0
|
103 |
TBuf<40> systestfile1;
|
sl@0
|
104 |
TBuf<40> pritestfile1;
|
sl@0
|
105 |
TBuf<40> restestfile1;
|
sl@0
|
106 |
|
sl@0
|
107 |
TTime testtime;
|
sl@0
|
108 |
TBuf<20> oldName;
|
sl@0
|
109 |
TBuf<25> temp;
|
sl@0
|
110 |
TEntry entry;
|
sl@0
|
111 |
|
sl@0
|
112 |
|
sl@0
|
113 |
|
sl@0
|
114 |
|
sl@0
|
115 |
LOCAL_C void TestPathCheck()
|
sl@0
|
116 |
//
|
sl@0
|
117 |
// This test case is brought in by INC054580
|
sl@0
|
118 |
// (NTT Renaming sys ¨Cfolder on C -drive on H2 allows user to access sys -files)
|
sl@0
|
119 |
//
|
sl@0
|
120 |
{
|
sl@0
|
121 |
TInt r = TheFs.Rename(_L("\\sys"), _L("\\sysbad"));
|
sl@0
|
122 |
test(r == KErrPermissionDenied);
|
sl@0
|
123 |
r = TheFs.Rename(_L("\\resource"), _L("\\resourcebad"));
|
sl@0
|
124 |
test(r == KErrPermissionDenied);
|
sl@0
|
125 |
r = TheFs.Rename(_L("\\private"), _L("\\privatebad"));
|
sl@0
|
126 |
test(r == KErrPermissionDenied);
|
sl@0
|
127 |
}
|
sl@0
|
128 |
|
sl@0
|
129 |
LOCAL_C void systemRFstest()
|
sl@0
|
130 |
//
|
sl@0
|
131 |
//
|
sl@0
|
132 |
//
|
sl@0
|
133 |
{
|
sl@0
|
134 |
systestname=KSystemPath;
|
sl@0
|
135 |
systestname[0]=(TText)('A' + gTheDriveNum);
|
sl@0
|
136 |
|
sl@0
|
137 |
mkdirname.Zero();
|
sl@0
|
138 |
mkdirname.Append(systestname);
|
sl@0
|
139 |
mkdirname.Append(KMkDirSub);
|
sl@0
|
140 |
r=TheFs.MkDirAll(mkdirname);
|
sl@0
|
141 |
test(r==KErrPermissionDenied);
|
sl@0
|
142 |
|
sl@0
|
143 |
r=TheFs.RmDir(mkdirname);
|
sl@0
|
144 |
test(r==KErrPermissionDenied);
|
sl@0
|
145 |
|
sl@0
|
146 |
r=TheFs.SetSubst(systestname,EDriveP);
|
sl@0
|
147 |
test(r==KErrPermissionDenied);
|
sl@0
|
148 |
|
sl@0
|
149 |
r=TheFs.SetSessionPath(systestname);
|
sl@0
|
150 |
test(r==KErrPermissionDenied);
|
sl@0
|
151 |
|
sl@0
|
152 |
TheFs.NotifyChange(ENotifyAll,aStat1,systestname);
|
sl@0
|
153 |
test(aStat1==KErrPermissionDenied);
|
sl@0
|
154 |
|
sl@0
|
155 |
systestfile=KSystemPath;
|
sl@0
|
156 |
systestfile[0]=(TText)('A' + gTheDriveNum);
|
sl@0
|
157 |
systestfile1=systestfile;
|
sl@0
|
158 |
systestfile.Append(KFileSys);
|
sl@0
|
159 |
systestfile1.Append(KFileSys3);
|
sl@0
|
160 |
|
sl@0
|
161 |
oldName=KOldFile;
|
sl@0
|
162 |
oldName[0]=(TText)gDriveToTest;
|
sl@0
|
163 |
|
sl@0
|
164 |
r=TheFs.GetShortName(systestfile, shortfilename);
|
sl@0
|
165 |
test(r==KErrPermissionDenied);
|
sl@0
|
166 |
|
sl@0
|
167 |
r=TheFs.GetLongName(systestfile1, longfilename);
|
sl@0
|
168 |
test(r==KErrPermissionDenied);
|
sl@0
|
169 |
|
sl@0
|
170 |
r=file1.Create(TheFs,oldName,EFileWrite);
|
sl@0
|
171 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
172 |
file1.Close();
|
sl@0
|
173 |
|
sl@0
|
174 |
r=TheFs.Replace(oldName,systestfile);
|
sl@0
|
175 |
test(r==KErrPermissionDenied);
|
sl@0
|
176 |
|
sl@0
|
177 |
r=TheFs.Rename(systestfile,systestfile1);
|
sl@0
|
178 |
test(r==KErrPermissionDenied);
|
sl@0
|
179 |
|
sl@0
|
180 |
// check that the entry for the system directory itself can be retrieved with no error
|
sl@0
|
181 |
// - with or without a slash
|
sl@0
|
182 |
TPtrC restrictedDir(systestname.Ptr(), systestname.Length());
|
sl@0
|
183 |
r=TheFs.Entry(restrictedDir, entry);
|
sl@0
|
184 |
test.Printf(_L("RFs::Entry(%S) returned %d"), &restrictedDir, r);
|
sl@0
|
185 |
test(r==KErrNone);
|
sl@0
|
186 |
test (entry.iAtt & KEntryAttDir);
|
sl@0
|
187 |
|
sl@0
|
188 |
TPtrC restrictedDirWithNoBackSlash(restrictedDir.Ptr(), restrictedDir.Length()-1);
|
sl@0
|
189 |
r=TheFs.Entry(restrictedDirWithNoBackSlash,entry);
|
sl@0
|
190 |
test.Printf(_L("RFs::Entry(%S) returned %d"), &restrictedDirWithNoBackSlash, r);
|
sl@0
|
191 |
test(r==KErrNone);
|
sl@0
|
192 |
|
sl@0
|
193 |
r=TheFs.Entry(systestfile1,entry);
|
sl@0
|
194 |
test(r==KErrPermissionDenied);
|
sl@0
|
195 |
|
sl@0
|
196 |
r=TheFs.SetEntry(systestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
|
sl@0
|
197 |
test(r==KErrPermissionDenied);
|
sl@0
|
198 |
|
sl@0
|
199 |
r=TheFs.Delete(systestfile1);
|
sl@0
|
200 |
test(r==KErrPermissionDenied);
|
sl@0
|
201 |
|
sl@0
|
202 |
}
|
sl@0
|
203 |
|
sl@0
|
204 |
|
sl@0
|
205 |
LOCAL_C void resourceRFstest()
|
sl@0
|
206 |
//
|
sl@0
|
207 |
//
|
sl@0
|
208 |
//
|
sl@0
|
209 |
{
|
sl@0
|
210 |
|
sl@0
|
211 |
restestname=KResourcePath;
|
sl@0
|
212 |
restestname[0]=(TText)('A' + gTheDriveNum);
|
sl@0
|
213 |
|
sl@0
|
214 |
mkdirname.Zero();
|
sl@0
|
215 |
mkdirname.Append(restestname);
|
sl@0
|
216 |
mkdirname.Append(KMkDirSub);
|
sl@0
|
217 |
r=TheFs.MkDirAll(mkdirname);
|
sl@0
|
218 |
test(r==KErrPermissionDenied);
|
sl@0
|
219 |
|
sl@0
|
220 |
TheFs.RmDir(mkdirname);
|
sl@0
|
221 |
test(r==KErrPermissionDenied);
|
sl@0
|
222 |
|
sl@0
|
223 |
r=TheFs.SetSubst(restestname,EDriveP);
|
sl@0
|
224 |
test(r==KErrPermissionDenied);
|
sl@0
|
225 |
|
sl@0
|
226 |
r=TheFs.RealName(_L("P:\\File.XXX"),realName);
|
sl@0
|
227 |
test(r==KErrNone);
|
sl@0
|
228 |
|
sl@0
|
229 |
r=TheFs.SetSessionPath(restestname);
|
sl@0
|
230 |
test(r==KErrNone);
|
sl@0
|
231 |
|
sl@0
|
232 |
TheFs.NotifyChange(ENotifyAll,aStat4,restestname);
|
sl@0
|
233 |
test(aStat4==KRequestPending);
|
sl@0
|
234 |
|
sl@0
|
235 |
|
sl@0
|
236 |
restestfile=KResourcePath;
|
sl@0
|
237 |
restestfile[0]=(TText)('A' + gTheDriveNum);
|
sl@0
|
238 |
restestfile1=restestfile;
|
sl@0
|
239 |
restestfile.Append(KFileRes);
|
sl@0
|
240 |
restestfile1.Append(KFileRes3);
|
sl@0
|
241 |
|
sl@0
|
242 |
oldName=KOldFile;
|
sl@0
|
243 |
oldName[0]=(TText)gDriveToTest;
|
sl@0
|
244 |
|
sl@0
|
245 |
r=TheFs.GetShortName(restestfile, shortfilename);
|
sl@0
|
246 |
test(r==KErrNone || KErrPathNotFound);
|
sl@0
|
247 |
|
sl@0
|
248 |
r=TheFs.GetLongName(restestfile1, longfilename);
|
sl@0
|
249 |
test(r==KErrNone || KErrPathNotFound);
|
sl@0
|
250 |
|
sl@0
|
251 |
r=file1.Create(TheFs,oldName,EFileWrite);
|
sl@0
|
252 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
253 |
file1.Close();
|
sl@0
|
254 |
|
sl@0
|
255 |
r=TheFs.Replace(oldName,restestfile);
|
sl@0
|
256 |
test(r==KErrPermissionDenied);
|
sl@0
|
257 |
|
sl@0
|
258 |
r=TheFs.Rename(restestfile,restestfile1);
|
sl@0
|
259 |
test(r==KErrPermissionDenied);
|
sl@0
|
260 |
|
sl@0
|
261 |
// check that the entry for the resource directory itself can be retrieved with no error
|
sl@0
|
262 |
// - with or without a slash
|
sl@0
|
263 |
TPtrC restrictedDir(restestname.Ptr(), restestname.Length());
|
sl@0
|
264 |
r=TheFs.Entry(restrictedDir, entry);
|
sl@0
|
265 |
test.Printf(_L("RFs::Entry(%S) returned %d"), &restrictedDir, r);
|
sl@0
|
266 |
test(r==KErrNone);
|
sl@0
|
267 |
test (entry.iAtt & KEntryAttDir);
|
sl@0
|
268 |
|
sl@0
|
269 |
TPtrC restrictedDirWithNoBackSlash(restrictedDir.Ptr(), restrictedDir.Length()-1);
|
sl@0
|
270 |
r=TheFs.Entry(restrictedDirWithNoBackSlash,entry);
|
sl@0
|
271 |
test.Printf(_L("RFs::Entry(%S) returned %d"), &restrictedDirWithNoBackSlash, r);
|
sl@0
|
272 |
test(r==KErrNone);
|
sl@0
|
273 |
|
sl@0
|
274 |
r=TheFs.Entry(restestfile1,entry);
|
sl@0
|
275 |
test(r==KErrNone || r==KErrNotFound);
|
sl@0
|
276 |
|
sl@0
|
277 |
r=TheFs.SetEntry(restestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
|
sl@0
|
278 |
test(r==KErrPermissionDenied);
|
sl@0
|
279 |
|
sl@0
|
280 |
r=TheFs.Delete(restestfile1);
|
sl@0
|
281 |
test(r==KErrPermissionDenied);
|
sl@0
|
282 |
|
sl@0
|
283 |
}
|
sl@0
|
284 |
|
sl@0
|
285 |
|
sl@0
|
286 |
LOCAL_C void privatefalseIDRFstest()
|
sl@0
|
287 |
//
|
sl@0
|
288 |
//
|
sl@0
|
289 |
//
|
sl@0
|
290 |
{
|
sl@0
|
291 |
pritestfalseidname=KPrivateFalseID;
|
sl@0
|
292 |
pritestfalseidname[0]=(TText)('A' + gTheDriveNum);
|
sl@0
|
293 |
|
sl@0
|
294 |
mkdirname.Zero();
|
sl@0
|
295 |
mkdirname.Append(pritestfalseidname);
|
sl@0
|
296 |
mkdirname.Append(KMkDirSub);
|
sl@0
|
297 |
|
sl@0
|
298 |
r=TheFs.MkDirAll(mkdirname);
|
sl@0
|
299 |
test(r==KErrPermissionDenied);
|
sl@0
|
300 |
|
sl@0
|
301 |
r=TheFs.RmDir(mkdirname);
|
sl@0
|
302 |
test(r==KErrPermissionDenied);
|
sl@0
|
303 |
|
sl@0
|
304 |
r=TheFs.SetSubst(pritestfalseidname,EDriveP);
|
sl@0
|
305 |
test(r==KErrPermissionDenied);
|
sl@0
|
306 |
|
sl@0
|
307 |
TheFs.NotifyChange(ENotifyAll,aStat2,pritestfalseidname);
|
sl@0
|
308 |
test(aStat2==KErrPermissionDenied);
|
sl@0
|
309 |
|
sl@0
|
310 |
|
sl@0
|
311 |
pritestfile=KPrivateFalseID;
|
sl@0
|
312 |
pritestfile[0]=(TText)('A' + gTheDriveNum);
|
sl@0
|
313 |
pritestfile1=pritestfile;
|
sl@0
|
314 |
pritestfile.Append(KFilePri2);
|
sl@0
|
315 |
pritestfile1.Append(KFilePri3);
|
sl@0
|
316 |
|
sl@0
|
317 |
oldName=KOldFile;
|
sl@0
|
318 |
oldName[0]=(TText)gDriveToTest;
|
sl@0
|
319 |
|
sl@0
|
320 |
r=TheFs.GetShortName(pritestfile, shortfilename);
|
sl@0
|
321 |
test(r==KErrPermissionDenied);
|
sl@0
|
322 |
|
sl@0
|
323 |
r=TheFs.GetLongName(pritestfile1, longfilename);
|
sl@0
|
324 |
test(r==KErrPermissionDenied);
|
sl@0
|
325 |
|
sl@0
|
326 |
r=file1.Create(TheFs,oldName,EFileWrite);
|
sl@0
|
327 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
328 |
file1.Close();
|
sl@0
|
329 |
|
sl@0
|
330 |
r=TheFs.Replace(oldName,pritestfile);
|
sl@0
|
331 |
test(r==KErrPermissionDenied);
|
sl@0
|
332 |
|
sl@0
|
333 |
r=TheFs.Rename(pritestfile,pritestfile1);
|
sl@0
|
334 |
test(r==KErrPermissionDenied);
|
sl@0
|
335 |
|
sl@0
|
336 |
r=TheFs.Entry(pritestfile1,entry);
|
sl@0
|
337 |
test(r==KErrPermissionDenied);
|
sl@0
|
338 |
|
sl@0
|
339 |
r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
|
sl@0
|
340 |
test(r==KErrPermissionDenied);
|
sl@0
|
341 |
|
sl@0
|
342 |
r=TheFs.Delete(pritestfile1);
|
sl@0
|
343 |
test(r==KErrPermissionDenied);
|
sl@0
|
344 |
|
sl@0
|
345 |
}
|
sl@0
|
346 |
|
sl@0
|
347 |
|
sl@0
|
348 |
|
sl@0
|
349 |
LOCAL_C void privateRFstest()
|
sl@0
|
350 |
//
|
sl@0
|
351 |
//
|
sl@0
|
352 |
//
|
sl@0
|
353 |
{
|
sl@0
|
354 |
pritestname=KPrivatePath;
|
sl@0
|
355 |
pritestname[0]=(TText)('A' + gTheDriveNum);
|
sl@0
|
356 |
|
sl@0
|
357 |
mkdirname.Zero();
|
sl@0
|
358 |
mkdirname.Append(pritestname);
|
sl@0
|
359 |
mkdirname.Append(KMkDirSub);
|
sl@0
|
360 |
|
sl@0
|
361 |
r=TheFs.MkDirAll(mkdirname);
|
sl@0
|
362 |
test(r==KErrPermissionDenied);
|
sl@0
|
363 |
|
sl@0
|
364 |
r=TheFs.RmDir(mkdirname);
|
sl@0
|
365 |
test(r==KErrPermissionDenied);
|
sl@0
|
366 |
|
sl@0
|
367 |
r=TheFs.SetSubst(pritestname,EDriveP);
|
sl@0
|
368 |
test(r==KErrPermissionDenied);
|
sl@0
|
369 |
|
sl@0
|
370 |
TheFs.NotifyChange(ENotifyAll,aStat2,pritestname);
|
sl@0
|
371 |
test(aStat2==KErrPermissionDenied);
|
sl@0
|
372 |
|
sl@0
|
373 |
|
sl@0
|
374 |
pritestfile=KPrivatePath;
|
sl@0
|
375 |
pritestfile[0]=(TText)('A' + gTheDriveNum);
|
sl@0
|
376 |
pritestfile1=pritestfile;
|
sl@0
|
377 |
pritestfile.Append(KFilePri2);
|
sl@0
|
378 |
pritestfile1.Append(KFilePri3);
|
sl@0
|
379 |
|
sl@0
|
380 |
oldName=KOldFile;
|
sl@0
|
381 |
oldName[0]=(TText)gDriveToTest;
|
sl@0
|
382 |
|
sl@0
|
383 |
r=TheFs.GetShortName(pritestfile, shortfilename);
|
sl@0
|
384 |
test(r==KErrPermissionDenied);
|
sl@0
|
385 |
|
sl@0
|
386 |
r=TheFs.GetLongName(pritestfile1, longfilename);
|
sl@0
|
387 |
test(r==KErrPermissionDenied);
|
sl@0
|
388 |
|
sl@0
|
389 |
r=file1.Create(TheFs,oldName,EFileWrite);
|
sl@0
|
390 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
391 |
file1.Close();
|
sl@0
|
392 |
|
sl@0
|
393 |
r=TheFs.Replace(oldName,pritestfile);
|
sl@0
|
394 |
test(r==KErrPermissionDenied);
|
sl@0
|
395 |
|
sl@0
|
396 |
r=TheFs.Rename(pritestfile,pritestfile1);
|
sl@0
|
397 |
test(r==KErrPermissionDenied);
|
sl@0
|
398 |
|
sl@0
|
399 |
r=TheFs.Entry(pritestfile1,entry);
|
sl@0
|
400 |
test(r==KErrPermissionDenied);
|
sl@0
|
401 |
|
sl@0
|
402 |
// check that the entry for the private directory itself can be retrieved with no error
|
sl@0
|
403 |
// - with or without a slash
|
sl@0
|
404 |
TPtrC restrictedDir(pritestname.Ptr(), pritestname.Length());
|
sl@0
|
405 |
r=TheFs.Entry(restrictedDir, entry);
|
sl@0
|
406 |
test.Printf(_L("RFs::Entry(%S) returned %d"), &restrictedDir, r);
|
sl@0
|
407 |
test(r==KErrNone);
|
sl@0
|
408 |
test (entry.iAtt & KEntryAttDir);
|
sl@0
|
409 |
|
sl@0
|
410 |
TPtrC restrictedDirWithNoBackSlash(restrictedDir.Ptr(), restrictedDir.Length()-1);
|
sl@0
|
411 |
r=TheFs.Entry(restrictedDirWithNoBackSlash,entry);
|
sl@0
|
412 |
test.Printf(_L("RFs::Entry(%S) returned %d"), &restrictedDirWithNoBackSlash, r);
|
sl@0
|
413 |
test(r==KErrNone);
|
sl@0
|
414 |
|
sl@0
|
415 |
r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
|
sl@0
|
416 |
test(r==KErrPermissionDenied);
|
sl@0
|
417 |
|
sl@0
|
418 |
r=TheFs.Delete(pritestfile1);
|
sl@0
|
419 |
test(r==KErrPermissionDenied);
|
sl@0
|
420 |
|
sl@0
|
421 |
}
|
sl@0
|
422 |
|
sl@0
|
423 |
|
sl@0
|
424 |
LOCAL_C void privateSIDRFstest()
|
sl@0
|
425 |
//
|
sl@0
|
426 |
//
|
sl@0
|
427 |
//
|
sl@0
|
428 |
{
|
sl@0
|
429 |
theprivatepath[0]=(TText)gDriveToTest;
|
sl@0
|
430 |
test.Printf(_L("the Private Path = %S"),&theprivatepath);
|
sl@0
|
431 |
|
sl@0
|
432 |
mkdirname.Zero();
|
sl@0
|
433 |
mkdirname.Append(theprivatepath);
|
sl@0
|
434 |
mkdirname.Append(KMkDirSub);
|
sl@0
|
435 |
r=TheFs.MkDirAll(mkdirname);
|
sl@0
|
436 |
test(r==KErrNone);
|
sl@0
|
437 |
|
sl@0
|
438 |
r=TheFs.RmDir(mkdirname);
|
sl@0
|
439 |
test(r==KErrNone);
|
sl@0
|
440 |
|
sl@0
|
441 |
r=TheFs.SetSubst(theprivatepath,EDriveP);
|
sl@0
|
442 |
test(r==KErrPermissionDenied);
|
sl@0
|
443 |
|
sl@0
|
444 |
r=TheFs.RealName(_L("P:\\File.XXX"),realName);
|
sl@0
|
445 |
test(r==KErrNone);
|
sl@0
|
446 |
|
sl@0
|
447 |
r=TheFs.SetSessionPath(theprivatepath);
|
sl@0
|
448 |
test(r==KErrNone);
|
sl@0
|
449 |
|
sl@0
|
450 |
TheFs.NotifyChange(ENotifyAll,aStat3,theprivatepath);
|
sl@0
|
451 |
test(aStat3==KRequestPending);
|
sl@0
|
452 |
|
sl@0
|
453 |
|
sl@0
|
454 |
pritestfile=theprivatepath;
|
sl@0
|
455 |
pritestfile[0]=(TText)('A' + gTheDriveNum);
|
sl@0
|
456 |
pritestfile1=pritestfile;
|
sl@0
|
457 |
pritestfile.Append(KFilePri2);
|
sl@0
|
458 |
pritestfile1.Append(KFilePri3);
|
sl@0
|
459 |
|
sl@0
|
460 |
oldName=KOldFile;
|
sl@0
|
461 |
oldName[0]=(TText)gDriveToTest;
|
sl@0
|
462 |
|
sl@0
|
463 |
r=TheFs.GetShortName(pritestfile, shortfilename);
|
sl@0
|
464 |
test(r==KErrNone || KErrPathNotFound);
|
sl@0
|
465 |
|
sl@0
|
466 |
r=TheFs.GetLongName(pritestfile1, longfilename);
|
sl@0
|
467 |
test(r==KErrNone || KErrPathNotFound);
|
sl@0
|
468 |
|
sl@0
|
469 |
r=file1.Create(TheFs,oldName,EFileWrite);
|
sl@0
|
470 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
471 |
file1.Close();
|
sl@0
|
472 |
|
sl@0
|
473 |
r=TheFs.Replace(oldName,pritestfile);
|
sl@0
|
474 |
test(r==KErrNone);
|
sl@0
|
475 |
|
sl@0
|
476 |
r=TheFs.Rename(pritestfile,pritestfile1);
|
sl@0
|
477 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
478 |
|
sl@0
|
479 |
r=TheFs.Entry(pritestfile1,entry);
|
sl@0
|
480 |
test(r==KErrNone);
|
sl@0
|
481 |
|
sl@0
|
482 |
//Test Entry with correct SID
|
sl@0
|
483 |
r=TheFs.Entry(theprivatepath,entry);
|
sl@0
|
484 |
test(r==KErrNone);
|
sl@0
|
485 |
|
sl@0
|
486 |
//Test Entry with correct SID and without "//" appended
|
sl@0
|
487 |
r=TheFs.Entry(KPrivatePathTest1,entry);
|
sl@0
|
488 |
test(r==KErrNone);
|
sl@0
|
489 |
|
sl@0
|
490 |
//Test Entry with invalid SID, without // appended
|
sl@0
|
491 |
r=TheFs.Entry(KPrivatePathTest2,entry);
|
sl@0
|
492 |
test(r==KErrPermissionDenied);
|
sl@0
|
493 |
|
sl@0
|
494 |
//Test Entry with invalid SID
|
sl@0
|
495 |
r=TheFs.Entry(KPrivatePathTest3,entry);
|
sl@0
|
496 |
test(r==KErrPermissionDenied);
|
sl@0
|
497 |
|
sl@0
|
498 |
r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
|
sl@0
|
499 |
test(r==KErrNone);
|
sl@0
|
500 |
|
sl@0
|
501 |
r=TheFs.Delete(pritestfile1);
|
sl@0
|
502 |
test(r==KErrNone);
|
sl@0
|
503 |
|
sl@0
|
504 |
}
|
sl@0
|
505 |
|
sl@0
|
506 |
|
sl@0
|
507 |
LOCAL_C void systemRFiletest()
|
sl@0
|
508 |
//
|
sl@0
|
509 |
//
|
sl@0
|
510 |
//
|
sl@0
|
511 |
{
|
sl@0
|
512 |
r=TheFs.SetSessionPath(systestname);
|
sl@0
|
513 |
test(r==KErrPermissionDenied);
|
sl@0
|
514 |
|
sl@0
|
515 |
r=file1.Temp(TheFs,systestname,fromTemp,EFileWrite);
|
sl@0
|
516 |
test(r==KErrPermissionDenied);
|
sl@0
|
517 |
|
sl@0
|
518 |
|
sl@0
|
519 |
TBuf<25> sysfilename;
|
sl@0
|
520 |
sysfilename.Append(systestname);
|
sl@0
|
521 |
sysfilename.Append(KFileSys);
|
sl@0
|
522 |
|
sl@0
|
523 |
r=file1.Create(TheFs,sysfilename,EFileWrite);
|
sl@0
|
524 |
test(r==KErrPermissionDenied);
|
sl@0
|
525 |
|
sl@0
|
526 |
r=file1.Open(TheFs,sysfilename,EFileWrite);
|
sl@0
|
527 |
test(r==KErrPermissionDenied);
|
sl@0
|
528 |
|
sl@0
|
529 |
r=file1.Open(TheFs,sysfilename,EFileRead);
|
sl@0
|
530 |
test(r==KErrPermissionDenied);
|
sl@0
|
531 |
|
sl@0
|
532 |
r=file1.Replace(TheFs,sysfilename,EFileWrite);
|
sl@0
|
533 |
test(r==KErrPermissionDenied);
|
sl@0
|
534 |
|
sl@0
|
535 |
TFindFile finder(TheFs);
|
sl@0
|
536 |
CDir* dir = NULL;
|
sl@0
|
537 |
r=finder.FindWildByDir(KWildFile, KWildPath, dir);
|
sl@0
|
538 |
if (!(r==KErrPermissionDenied))
|
sl@0
|
539 |
test.Printf(_L("T_DCNONE: test find wildcards r = %d (expected KErrPermissionDenied)\n"), r);
|
sl@0
|
540 |
test(r==KErrPermissionDenied);
|
sl@0
|
541 |
delete dir;
|
sl@0
|
542 |
}
|
sl@0
|
543 |
|
sl@0
|
544 |
LOCAL_C void resourceRFiletest()
|
sl@0
|
545 |
//
|
sl@0
|
546 |
//
|
sl@0
|
547 |
//
|
sl@0
|
548 |
{
|
sl@0
|
549 |
r=TheFs.SetSessionPath(restestname);
|
sl@0
|
550 |
test(r==KErrNone);
|
sl@0
|
551 |
|
sl@0
|
552 |
r=file1.Temp(TheFs,restestname,fromTemp,EFileWrite);
|
sl@0
|
553 |
test(r==KErrPermissionDenied);
|
sl@0
|
554 |
file1.Close();
|
sl@0
|
555 |
|
sl@0
|
556 |
r=file1.Create(TheFs,KFileRes,EFileWrite);
|
sl@0
|
557 |
test(r==KErrPermissionDenied);
|
sl@0
|
558 |
file1.Close();
|
sl@0
|
559 |
|
sl@0
|
560 |
r=file1.Open(TheFs,KFileRes,EFileWrite);
|
sl@0
|
561 |
test(r==KErrPermissionDenied);
|
sl@0
|
562 |
file1.Close();
|
sl@0
|
563 |
|
sl@0
|
564 |
r=file1.Open(TheFs,KFileRes,EFileRead|EFileShareReadersOnly);
|
sl@0
|
565 |
test(r==KErrNone || r==KErrPathNotFound);
|
sl@0
|
566 |
file1.Close();
|
sl@0
|
567 |
|
sl@0
|
568 |
r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileRead);
|
sl@0
|
569 |
test(r==KErrNone || r==KErrPathNotFound);
|
sl@0
|
570 |
file1.Close();
|
sl@0
|
571 |
|
sl@0
|
572 |
r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileWrite);
|
sl@0
|
573 |
test(r==KErrPermissionDenied);
|
sl@0
|
574 |
file1.Close();
|
sl@0
|
575 |
|
sl@0
|
576 |
r=file1.Open(TheFs,KFileRes,EFileShareReadersOnly);
|
sl@0
|
577 |
test(r==KErrNone || r==KErrPathNotFound);
|
sl@0
|
578 |
|
sl@0
|
579 |
r=file1.ChangeMode(EFileShareExclusive); //this is not illegal though will prevent shared access to resource which is nit my fault but may be desirable to prevent
|
sl@0
|
580 |
test(r==KErrNone || r==KErrPathNotFound);
|
sl@0
|
581 |
|
sl@0
|
582 |
//this operation is prevented as you can not open a file for write access in the resource directory
|
sl@0
|
583 |
r=file1.Rename(KFileRes3);
|
sl@0
|
584 |
test(r==KErrPermissionDenied || r==KErrAccessDenied);
|
sl@0
|
585 |
|
sl@0
|
586 |
file1.Close();
|
sl@0
|
587 |
|
sl@0
|
588 |
r=file1.Replace(TheFs,KFileRes,EFileWrite);
|
sl@0
|
589 |
test(r==KErrPermissionDenied);
|
sl@0
|
590 |
file1.Close();
|
sl@0
|
591 |
|
sl@0
|
592 |
}
|
sl@0
|
593 |
|
sl@0
|
594 |
|
sl@0
|
595 |
LOCAL_C void privatefalseIDRFiletest()
|
sl@0
|
596 |
//
|
sl@0
|
597 |
//
|
sl@0
|
598 |
//
|
sl@0
|
599 |
{
|
sl@0
|
600 |
|
sl@0
|
601 |
r=TheFs.SetSessionPath(pritestfalseidname);
|
sl@0
|
602 |
test(r==KErrPermissionDenied);
|
sl@0
|
603 |
|
sl@0
|
604 |
r=file1.Temp(TheFs,pritestfalseidname,fromTemp,EFileWrite);
|
sl@0
|
605 |
test(r==KErrPermissionDenied);
|
sl@0
|
606 |
|
sl@0
|
607 |
TBuf<25> prifilename;
|
sl@0
|
608 |
prifilename.Append(pritestname);
|
sl@0
|
609 |
prifilename.Append(KFileSys);
|
sl@0
|
610 |
|
sl@0
|
611 |
r=file1.Create(TheFs,prifilename,EFileWrite);
|
sl@0
|
612 |
test(r==KErrPermissionDenied);
|
sl@0
|
613 |
|
sl@0
|
614 |
|
sl@0
|
615 |
r=file1.Open(TheFs,prifilename,EFileWrite);
|
sl@0
|
616 |
test(r==KErrPermissionDenied);
|
sl@0
|
617 |
|
sl@0
|
618 |
r=file1.Open(TheFs,prifilename,EFileRead);
|
sl@0
|
619 |
test(r==KErrPermissionDenied);
|
sl@0
|
620 |
|
sl@0
|
621 |
|
sl@0
|
622 |
r=file1.Replace(TheFs,prifilename,EFileWrite);
|
sl@0
|
623 |
test(r==KErrPermissionDenied);
|
sl@0
|
624 |
|
sl@0
|
625 |
}
|
sl@0
|
626 |
|
sl@0
|
627 |
|
sl@0
|
628 |
|
sl@0
|
629 |
LOCAL_C void privateRFiletest()
|
sl@0
|
630 |
//
|
sl@0
|
631 |
//
|
sl@0
|
632 |
//
|
sl@0
|
633 |
{
|
sl@0
|
634 |
|
sl@0
|
635 |
r=TheFs.SetSessionPath(pritestname);
|
sl@0
|
636 |
test(r==KErrPermissionDenied);
|
sl@0
|
637 |
|
sl@0
|
638 |
r=file1.Temp(TheFs,pritestname,fromTemp,EFileWrite);
|
sl@0
|
639 |
test(r==KErrPermissionDenied);
|
sl@0
|
640 |
|
sl@0
|
641 |
TBuf<25> prifilename;
|
sl@0
|
642 |
prifilename.Append(pritestname);
|
sl@0
|
643 |
prifilename.Append(KFileSys);
|
sl@0
|
644 |
|
sl@0
|
645 |
r=file1.Create(TheFs,prifilename,EFileWrite);
|
sl@0
|
646 |
test(r==KErrPermissionDenied);
|
sl@0
|
647 |
|
sl@0
|
648 |
|
sl@0
|
649 |
r=file1.Open(TheFs,prifilename,EFileWrite);
|
sl@0
|
650 |
test(r==KErrPermissionDenied);
|
sl@0
|
651 |
|
sl@0
|
652 |
|
sl@0
|
653 |
r=file1.Open(TheFs,prifilename,EFileRead);
|
sl@0
|
654 |
test(r==KErrPermissionDenied);
|
sl@0
|
655 |
|
sl@0
|
656 |
|
sl@0
|
657 |
r=file1.Replace(TheFs,prifilename,EFileWrite);
|
sl@0
|
658 |
test(r==KErrPermissionDenied);
|
sl@0
|
659 |
|
sl@0
|
660 |
}
|
sl@0
|
661 |
|
sl@0
|
662 |
LOCAL_C void privateSIDRFiletest()
|
sl@0
|
663 |
//
|
sl@0
|
664 |
//
|
sl@0
|
665 |
//
|
sl@0
|
666 |
{
|
sl@0
|
667 |
|
sl@0
|
668 |
r=TheFs.SetSessionToPrivate(gTheDriveNum);
|
sl@0
|
669 |
test(r==KErrNone);
|
sl@0
|
670 |
|
sl@0
|
671 |
r=file1.Temp(TheFs,theprivatepath,fromTemp,EFileWrite);
|
sl@0
|
672 |
test(r==KErrNone);
|
sl@0
|
673 |
file1.Close();
|
sl@0
|
674 |
r=file1.Create(TheFs,KFilePri,EFileWrite);
|
sl@0
|
675 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
676 |
file1.Close();
|
sl@0
|
677 |
r=file1.Open(TheFs,KFilePri,EFileWrite);
|
sl@0
|
678 |
test(r==KErrNone);
|
sl@0
|
679 |
file1.Close();
|
sl@0
|
680 |
r=file1.Open(TheFs,KFilePri,EFileRead);
|
sl@0
|
681 |
test(r==KErrNone);
|
sl@0
|
682 |
file1.Close();
|
sl@0
|
683 |
r=file1.Replace(TheFs,KFilePri,EFileWrite);
|
sl@0
|
684 |
test(r==KErrNone);
|
sl@0
|
685 |
r=file1.Rename(KFilePri3);
|
sl@0
|
686 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
687 |
file1.Close();
|
sl@0
|
688 |
|
sl@0
|
689 |
}
|
sl@0
|
690 |
|
sl@0
|
691 |
|
sl@0
|
692 |
LOCAL_C void RDirtest()
|
sl@0
|
693 |
//
|
sl@0
|
694 |
//
|
sl@0
|
695 |
//
|
sl@0
|
696 |
{
|
sl@0
|
697 |
//system
|
sl@0
|
698 |
|
sl@0
|
699 |
TBuf<30> dirNameBuf(KSystemPath);
|
sl@0
|
700 |
dirNameBuf[0]=(TText)gDriveToTest;
|
sl@0
|
701 |
r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
|
sl@0
|
702 |
test(r==KErrPermissionDenied);
|
sl@0
|
703 |
dir.Close();
|
sl@0
|
704 |
r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
|
sl@0
|
705 |
test(r==KErrPermissionDenied);
|
sl@0
|
706 |
dirNameBuf.Zero();
|
sl@0
|
707 |
delete dirEntries;
|
sl@0
|
708 |
|
sl@0
|
709 |
dirNameBuf=KPrivateFalseID;
|
sl@0
|
710 |
dirNameBuf[0]=(TText)gDriveToTest;
|
sl@0
|
711 |
r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
|
sl@0
|
712 |
test(r==KErrPermissionDenied);
|
sl@0
|
713 |
dir.Close();
|
sl@0
|
714 |
r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
|
sl@0
|
715 |
test(r==KErrPermissionDenied);
|
sl@0
|
716 |
dirNameBuf.Zero();
|
sl@0
|
717 |
delete dirEntries;
|
sl@0
|
718 |
|
sl@0
|
719 |
//Private
|
sl@0
|
720 |
dirNameBuf=KPrivatePath;
|
sl@0
|
721 |
dirNameBuf[0]=(TText)gDriveToTest;
|
sl@0
|
722 |
r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
|
sl@0
|
723 |
test(r==KErrPermissionDenied);
|
sl@0
|
724 |
dir.Close();
|
sl@0
|
725 |
r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
|
sl@0
|
726 |
test(r==KErrPermissionDenied);
|
sl@0
|
727 |
dirNameBuf.Zero();
|
sl@0
|
728 |
delete dirEntries;
|
sl@0
|
729 |
//Private/uid
|
sl@0
|
730 |
TheFs.PrivatePath(dirNameBuf);
|
sl@0
|
731 |
dirNameBuf.Insert(0,_L("?:"));
|
sl@0
|
732 |
dirNameBuf[0]=(TText)gDriveToTest;
|
sl@0
|
733 |
r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
|
sl@0
|
734 |
test(r==KErrNone);
|
sl@0
|
735 |
dir.Close();
|
sl@0
|
736 |
r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
|
sl@0
|
737 |
test(r==KErrNone);
|
sl@0
|
738 |
dirNameBuf.Zero();
|
sl@0
|
739 |
delete dirEntries;
|
sl@0
|
740 |
//Resource
|
sl@0
|
741 |
dirNameBuf=KResourcePath;
|
sl@0
|
742 |
dirNameBuf[0]=(TText)gDriveToTest;
|
sl@0
|
743 |
r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
|
sl@0
|
744 |
test(r==KErrNone);
|
sl@0
|
745 |
r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
|
sl@0
|
746 |
test(r==KErrNone);
|
sl@0
|
747 |
dir.Close();
|
sl@0
|
748 |
delete dirEntries;
|
sl@0
|
749 |
}
|
sl@0
|
750 |
|
sl@0
|
751 |
|
sl@0
|
752 |
LOCAL_C void TestNoCaps()
|
sl@0
|
753 |
//
|
sl@0
|
754 |
// test APIs with no capabilities
|
sl@0
|
755 |
//
|
sl@0
|
756 |
{
|
sl@0
|
757 |
r=TheFs.FileSystemName(fsname,gTheDriveNum);
|
sl@0
|
758 |
test(r==KErrNone);
|
sl@0
|
759 |
r = DismountFileSystem(TheFs, fsname, gTheDriveNum);
|
sl@0
|
760 |
test(r==KErrPermissionDenied);
|
sl@0
|
761 |
// r=TheFs.RemoveFileSystem(fsname); //can not test due to bug elsewhere fix exists
|
sl@0
|
762 |
// test(r==KErrPermissionDenied);
|
sl@0
|
763 |
// r=TheFs.AddFileSystem(fsname);
|
sl@0
|
764 |
// test(r==KErrPermissionDenied);
|
sl@0
|
765 |
r = MountFileSystem(TheFs, fsname, gTheDriveNum);
|
sl@0
|
766 |
test(r==KErrPermissionDenied);
|
sl@0
|
767 |
r=TheFs.SetDriveName(gTheDriveNum,KDriveName);
|
sl@0
|
768 |
test(r==KErrPermissionDenied);
|
sl@0
|
769 |
// r=TheFs.SetVolumeLabel(KVolLable, gTheDriveNum); //broken on wins C:
|
sl@0
|
770 |
// test(r==KErrPermissionDenied);
|
sl@0
|
771 |
|
sl@0
|
772 |
systemRFstest();
|
sl@0
|
773 |
resourceRFstest();
|
sl@0
|
774 |
privateRFstest();
|
sl@0
|
775 |
privateSIDRFstest();
|
sl@0
|
776 |
privatefalseIDRFstest();
|
sl@0
|
777 |
|
sl@0
|
778 |
systemRFiletest();
|
sl@0
|
779 |
resourceRFiletest();
|
sl@0
|
780 |
privateRFiletest();
|
sl@0
|
781 |
privateSIDRFiletest();
|
sl@0
|
782 |
privatefalseIDRFiletest();
|
sl@0
|
783 |
//disk changes to sys and pri paths should have completed these
|
sl@0
|
784 |
test(aStat4 == KRequestPending);
|
sl@0
|
785 |
TheFs.NotifyChangeCancel(aStat4);
|
sl@0
|
786 |
test(aStat4==KErrCancel);
|
sl@0
|
787 |
|
sl@0
|
788 |
|
sl@0
|
789 |
User::WaitForRequest(aStat3);
|
sl@0
|
790 |
test(aStat1==KErrPermissionDenied);
|
sl@0
|
791 |
test(aStat2==KErrPermissionDenied);
|
sl@0
|
792 |
test(aStat3==KErrNone);
|
sl@0
|
793 |
|
sl@0
|
794 |
r=TheFs.SetSessionPath(systestname);
|
sl@0
|
795 |
test(r==KErrPermissionDenied);
|
sl@0
|
796 |
|
sl@0
|
797 |
|
sl@0
|
798 |
//Test RRawDisk class
|
sl@0
|
799 |
r=rawdisk.Open(TheFs,gTheDriveNum);
|
sl@0
|
800 |
test(r==KErrPermissionDenied);
|
sl@0
|
801 |
// rawdisk.Close();
|
sl@0
|
802 |
|
sl@0
|
803 |
r=format.Open(TheFs,driveBuf,EHighDensity,count);
|
sl@0
|
804 |
test(r==KErrPermissionDenied);
|
sl@0
|
805 |
|
sl@0
|
806 |
RDirtest();
|
sl@0
|
807 |
|
sl@0
|
808 |
driveBuf[0]=(TText)gDriveToTest;
|
sl@0
|
809 |
r=TheFs.ScanDrive(driveBuf);
|
sl@0
|
810 |
test(r==KErrPermissionDenied);
|
sl@0
|
811 |
r=TheFs.CheckDisk(driveBuf);
|
sl@0
|
812 |
test(r==KErrPermissionDenied);
|
sl@0
|
813 |
}
|
sl@0
|
814 |
|
sl@0
|
815 |
LOCAL_C void TestCaps()
|
sl@0
|
816 |
//
|
sl@0
|
817 |
// test format etc that require certain capabilities
|
sl@0
|
818 |
//
|
sl@0
|
819 |
{
|
sl@0
|
820 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
|
sl@0
|
821 |
const char myDiagMsg[]="Capability Check Failure";
|
sl@0
|
822 |
#endif //!__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
|
sl@0
|
823 |
r=RProcess().HasCapability(ECapabilityAllFiles, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
|
sl@0
|
824 |
test(!r);
|
sl@0
|
825 |
r=RProcess().HasCapability(ECapabilityTCB, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
|
sl@0
|
826 |
test(!r);
|
sl@0
|
827 |
r=RProcess().HasCapability(ECapabilityDiskAdmin, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
|
sl@0
|
828 |
test(!r);
|
sl@0
|
829 |
r=RProcess().HasCapability(ECapability_None, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
|
sl@0
|
830 |
test(r);
|
sl@0
|
831 |
|
sl@0
|
832 |
driveBuf[0]=(TText)gDriveToTest;
|
sl@0
|
833 |
r=TheFs.SessionPath(temp);
|
sl@0
|
834 |
test(r==KErrNone);
|
sl@0
|
835 |
|
sl@0
|
836 |
r=TheFs.CreatePrivatePath(gTheDriveNum);
|
sl@0
|
837 |
test(r==KErrNone || r== KErrAlreadyExists);
|
sl@0
|
838 |
|
sl@0
|
839 |
TBuf<18> tempPri;
|
sl@0
|
840 |
r=TheFs.PrivatePath(tempPri);
|
sl@0
|
841 |
test(r==KErrNone);
|
sl@0
|
842 |
theprivatepath = _L("?:");
|
sl@0
|
843 |
theprivatepath.Append(tempPri);
|
sl@0
|
844 |
|
sl@0
|
845 |
TestNoCaps();
|
sl@0
|
846 |
|
sl@0
|
847 |
TFileName thesessionpath;
|
sl@0
|
848 |
r=TheFs.SetSessionToPrivate(gTheDriveNum);
|
sl@0
|
849 |
test(r==KErrNone);
|
sl@0
|
850 |
r=TheFs.SessionPath(thesessionpath);
|
sl@0
|
851 |
test(r==KErrNone);
|
sl@0
|
852 |
|
sl@0
|
853 |
test(thesessionpath == theprivatepath);
|
sl@0
|
854 |
|
sl@0
|
855 |
}
|
sl@0
|
856 |
|
sl@0
|
857 |
|
sl@0
|
858 |
LOCAL_C void MakeDirs()
|
sl@0
|
859 |
//
|
sl@0
|
860 |
// Create system and private directories for scan with and without DC
|
sl@0
|
861 |
//
|
sl@0
|
862 |
{
|
sl@0
|
863 |
TInt r;
|
sl@0
|
864 |
r = TheFs.MkDir(_L("\\normal\\"));
|
sl@0
|
865 |
test(r == KErrNone || r == KErrAlreadyExists);
|
sl@0
|
866 |
r = TheFs.MkDir(_L("\\normal\\one\\"));
|
sl@0
|
867 |
test(r == KErrNone || r == KErrAlreadyExists);
|
sl@0
|
868 |
r = TheFs.MkDir(_L("\\normal\\two\\"));
|
sl@0
|
869 |
test(r == KErrNone || r == KErrAlreadyExists);
|
sl@0
|
870 |
r = TheFs.MkDir(_L("\\sys\\"));
|
sl@0
|
871 |
test(r == KErrPermissionDenied);
|
sl@0
|
872 |
r = TheFs.MkDir(_L("\\sys\\one\\"));
|
sl@0
|
873 |
test(r == KErrPermissionDenied);
|
sl@0
|
874 |
r = TheFs.MkDir(_L("\\sys\\two\\"));
|
sl@0
|
875 |
test(r == KErrPermissionDenied);
|
sl@0
|
876 |
r = TheFs.MkDir(_L("\\private\\"));
|
sl@0
|
877 |
test(r == KErrPermissionDenied);
|
sl@0
|
878 |
r = TheFs.MkDir(_L("\\private\\one\\"));
|
sl@0
|
879 |
test(r == KErrPermissionDenied);
|
sl@0
|
880 |
r = TheFs.MkDir(_L("\\private\\two\\"));
|
sl@0
|
881 |
test(r == KErrPermissionDenied);
|
sl@0
|
882 |
r = TheFs.MkDir(_L("\\ZZZZZZ\\"));
|
sl@0
|
883 |
test(r == KErrNone || r == KErrAlreadyExists);
|
sl@0
|
884 |
}
|
sl@0
|
885 |
|
sl@0
|
886 |
TFileName dirName;
|
sl@0
|
887 |
|
sl@0
|
888 |
LOCAL_C void ScanDir(const TDesC& aName, CDirScan::TScanDirection aDirection, TInt aError)
|
sl@0
|
889 |
{
|
sl@0
|
890 |
CDirScan* scanner = NULL;
|
sl@0
|
891 |
TRAP(r, scanner = CDirScan::NewL(TheFs));
|
sl@0
|
892 |
test(r == KErrNone && scanner);
|
sl@0
|
893 |
|
sl@0
|
894 |
TRAP(r, scanner->SetScanDataL(aName,KEntryAttDir,ESortByName|EAscending,aDirection));
|
sl@0
|
895 |
test(r == KErrNone);
|
sl@0
|
896 |
|
sl@0
|
897 |
CDir *entryList=NULL;
|
sl@0
|
898 |
for (;;)
|
sl@0
|
899 |
{
|
sl@0
|
900 |
TRAP(r, scanner->NextL(entryList));
|
sl@0
|
901 |
test(r == aError);
|
sl@0
|
902 |
if (entryList==NULL)
|
sl@0
|
903 |
break;
|
sl@0
|
904 |
TInt count=entryList->Count();
|
sl@0
|
905 |
while (count--)
|
sl@0
|
906 |
{
|
sl@0
|
907 |
TEntry data=(*entryList)[count];
|
sl@0
|
908 |
TBuf<KMaxFileName> path=scanner->AbbreviatedPath();
|
sl@0
|
909 |
dirName = path;
|
sl@0
|
910 |
dirName.Append(data.iName);
|
sl@0
|
911 |
test.Printf(_L(" %S\n"),&dirName);
|
sl@0
|
912 |
|
sl@0
|
913 |
}
|
sl@0
|
914 |
delete entryList;
|
sl@0
|
915 |
entryList=NULL;
|
sl@0
|
916 |
}
|
sl@0
|
917 |
delete scanner;
|
sl@0
|
918 |
|
sl@0
|
919 |
}
|
sl@0
|
920 |
|
sl@0
|
921 |
/**
|
sl@0
|
922 |
The following test, tests CFileMan and CDirScan API on folders private and sys
|
sl@0
|
923 |
to confirm that any operation on these folders for any app with incorrect capability
|
sl@0
|
924 |
returns KErrPermissionDenied. This test step was added as a result of DEF051428
|
sl@0
|
925 |
("PlatSec: Incorrect errors returned by f32")
|
sl@0
|
926 |
*/
|
sl@0
|
927 |
LOCAL_C void TestCaging()
|
sl@0
|
928 |
{
|
sl@0
|
929 |
CFileMan* fMan=CFileMan::NewL(TheFs);
|
sl@0
|
930 |
TInt r;
|
sl@0
|
931 |
if(fMan!=NULL)
|
sl@0
|
932 |
{
|
sl@0
|
933 |
|
sl@0
|
934 |
// Checking the private path
|
sl@0
|
935 |
TBuf<30> privatepath;
|
sl@0
|
936 |
r=TheFs.PrivatePath(privatepath);
|
sl@0
|
937 |
test.Printf(_L("Private Path is=%S"),&privatepath);
|
sl@0
|
938 |
|
sl@0
|
939 |
r = TheFs.MkDir(_L("\\Caged\\"));
|
sl@0
|
940 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
941 |
|
sl@0
|
942 |
CDir* entryCount=NULL;
|
sl@0
|
943 |
r=TheFs.GetDir(_L("\\*.*"),KEntryAttNormal,ESortNone,entryCount);
|
sl@0
|
944 |
test(r==KErrNone);
|
sl@0
|
945 |
TInt rootCount= entryCount->Count();
|
sl@0
|
946 |
|
sl@0
|
947 |
delete entryCount;
|
sl@0
|
948 |
entryCount=NULL;
|
sl@0
|
949 |
|
sl@0
|
950 |
|
sl@0
|
951 |
//Testing Copy
|
sl@0
|
952 |
CDir* entryCount2=NULL;
|
sl@0
|
953 |
r=fMan->Copy(_L("\\sys\\"),_L("\\Caged\\"));
|
sl@0
|
954 |
test(r == KErrPermissionDenied);
|
sl@0
|
955 |
r=fMan->Copy(_L("\\*"),_L("\\Caged\\"));
|
sl@0
|
956 |
test(r == KErrNone);
|
sl@0
|
957 |
|
sl@0
|
958 |
r=TheFs.GetDir(_L("\\Caged\\*.*"),KEntryAttNormal,ESortNone,entryCount2);
|
sl@0
|
959 |
test(r==KErrNone);
|
sl@0
|
960 |
TInt cagedCount= entryCount2->Count();
|
sl@0
|
961 |
|
sl@0
|
962 |
test(cagedCount==rootCount);
|
sl@0
|
963 |
|
sl@0
|
964 |
delete entryCount2;
|
sl@0
|
965 |
entryCount2=NULL;
|
sl@0
|
966 |
|
sl@0
|
967 |
// Check if both copied sys and private are empty (no information is exposed)
|
sl@0
|
968 |
CDir* entryCount3=NULL;
|
sl@0
|
969 |
r=TheFs.GetDir(_L("\\Caged\\private\\*.*"),KEntryAttNormal|KEntryAttDir,ESortNone,entryCount3);
|
sl@0
|
970 |
test(r==KErrPathNotFound);
|
sl@0
|
971 |
delete entryCount3;
|
sl@0
|
972 |
entryCount3=NULL;
|
sl@0
|
973 |
|
sl@0
|
974 |
CDir* entryCount4=NULL;
|
sl@0
|
975 |
r=TheFs.GetDir(_L("\\Caged\\sys\\*.*"),KEntryAttNormal|KEntryAttDir,ESortNone,entryCount4);
|
sl@0
|
976 |
test(r==KErrPathNotFound);
|
sl@0
|
977 |
delete entryCount4;
|
sl@0
|
978 |
entryCount4=NULL;
|
sl@0
|
979 |
|
sl@0
|
980 |
|
sl@0
|
981 |
r=fMan->Copy(_L("\\private\\two\\moo"),_L("\\private\\two\\mew"));
|
sl@0
|
982 |
test(r == KErrPermissionDenied);
|
sl@0
|
983 |
|
sl@0
|
984 |
// Create a test file
|
sl@0
|
985 |
RFile testFile;
|
sl@0
|
986 |
r = testFile.Replace(TheFs, _L("\\capTest"),EFileWrite);
|
sl@0
|
987 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
988 |
testFile.Close();
|
sl@0
|
989 |
|
sl@0
|
990 |
TFileName name;
|
sl@0
|
991 |
name = privatepath;
|
sl@0
|
992 |
name.Append(_L("privateFile.tst"));
|
sl@0
|
993 |
RFile privateFile;
|
sl@0
|
994 |
r = privateFile.Replace(TheFs, name,EFileWrite);
|
sl@0
|
995 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
996 |
privateFile.Close();
|
sl@0
|
997 |
|
sl@0
|
998 |
|
sl@0
|
999 |
r=fMan->Copy(_L("\\capTest"),_L("\\private\\two\\moo"));
|
sl@0
|
1000 |
test(r == KErrPermissionDenied);
|
sl@0
|
1001 |
r=fMan->Copy(_L("\\capTest"),_L("\\sys\\bin\\moo"));
|
sl@0
|
1002 |
test(r == KErrPermissionDenied);
|
sl@0
|
1003 |
r=fMan->Copy(_L("\\sys\\bin\\capTest"),_L("\\sys\\bin\\moo"));
|
sl@0
|
1004 |
test(r == KErrPermissionDenied);
|
sl@0
|
1005 |
r=fMan->Copy(_L("\\sys\\*"),_L("\\"));
|
sl@0
|
1006 |
test (r==KErrPermissionDenied);
|
sl@0
|
1007 |
r=fMan->Copy(name,_L("\\sys\\"));
|
sl@0
|
1008 |
test(r==KErrPermissionDenied);
|
sl@0
|
1009 |
|
sl@0
|
1010 |
// Testing Move
|
sl@0
|
1011 |
r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo"));
|
sl@0
|
1012 |
test(r == KErrPermissionDenied);
|
sl@0
|
1013 |
r=fMan->Move(_L("\\private\\two\\moo.."),_L("\\private\\one\\moo"));
|
sl@0
|
1014 |
test(r == KErrPermissionDenied);
|
sl@0
|
1015 |
r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo.."));
|
sl@0
|
1016 |
test(r == KErrPermissionDenied);
|
sl@0
|
1017 |
r=fMan->Move(name,_L("\\privateFile.tst"));
|
sl@0
|
1018 |
test(r == KErrNone);
|
sl@0
|
1019 |
r=fMan->Move(_L("\\privateFile.tst"),name);
|
sl@0
|
1020 |
test(r == KErrNone);
|
sl@0
|
1021 |
r=fMan->Move(_L("\\capTest"),_L("\\private\\two\\moo"));
|
sl@0
|
1022 |
test(r == KErrPermissionDenied);
|
sl@0
|
1023 |
r=fMan->Move(_L("\\capTest"),_L("\\sys\\bin\\moo"));
|
sl@0
|
1024 |
test(r == KErrPermissionDenied);
|
sl@0
|
1025 |
r=fMan->Move(_L("\\sys\\bin\\capTest"),_L("\\sys\\bin\\moo"));
|
sl@0
|
1026 |
test(r == KErrPermissionDenied);
|
sl@0
|
1027 |
r=fMan->Move(_L("\\sys\\*"),_L("\\"));
|
sl@0
|
1028 |
test (r==KErrPermissionDenied);
|
sl@0
|
1029 |
r=fMan->Move(name,_L("\\sys\\"));
|
sl@0
|
1030 |
test(r==KErrPermissionDenied);
|
sl@0
|
1031 |
|
sl@0
|
1032 |
|
sl@0
|
1033 |
// Testing Attribs
|
sl@0
|
1034 |
r=fMan->Attribs(_L("\\private\\two\\moo"),KEntryAttReadOnly,0,TTime(0));
|
sl@0
|
1035 |
test(r == KErrPermissionDenied);
|
sl@0
|
1036 |
r=fMan->Attribs(_L("\\private\\moo"),KEntryAttReadOnly,0,TTime(0));
|
sl@0
|
1037 |
test(r == KErrPermissionDenied);
|
sl@0
|
1038 |
r=fMan->Attribs(name,KEntryAttReadOnly,0,TTime(0));
|
sl@0
|
1039 |
test(r == KErrNone);
|
sl@0
|
1040 |
r=fMan->Attribs(name,0,KEntryAttReadOnly,TTime(0));
|
sl@0
|
1041 |
test(r == KErrNone);
|
sl@0
|
1042 |
|
sl@0
|
1043 |
|
sl@0
|
1044 |
// Testing RmDir
|
sl@0
|
1045 |
r=fMan->RmDir(_L("\\private\\"));
|
sl@0
|
1046 |
test(r == KErrPermissionDenied);
|
sl@0
|
1047 |
r=fMan->RmDir(_L("\\private\\two\\"));
|
sl@0
|
1048 |
test(r == KErrPermissionDenied);
|
sl@0
|
1049 |
r=fMan->RmDir(_L("\\private\\tw?\\"));
|
sl@0
|
1050 |
test(r == KErrPermissionDenied);
|
sl@0
|
1051 |
r=fMan->RmDir(_L("\\sys\\"));
|
sl@0
|
1052 |
test(r == KErrPermissionDenied);
|
sl@0
|
1053 |
|
sl@0
|
1054 |
|
sl@0
|
1055 |
// Testing Rename
|
sl@0
|
1056 |
r=fMan->Rename(_L("\\private\\two\\moo"),_L("\\private\\two\\mew"));
|
sl@0
|
1057 |
test(r == KErrPermissionDenied);
|
sl@0
|
1058 |
|
sl@0
|
1059 |
// Testing Delete
|
sl@0
|
1060 |
r=fMan->Delete(_L("\\private\\two\\test"));
|
sl@0
|
1061 |
test(r == KErrPermissionDenied);
|
sl@0
|
1062 |
r=fMan->Delete(_L("\\private\\moo"));
|
sl@0
|
1063 |
test(r == KErrPermissionDenied);
|
sl@0
|
1064 |
r=fMan->Delete(_L("\\sys\\moo"));
|
sl@0
|
1065 |
test(r == KErrPermissionDenied);
|
sl@0
|
1066 |
|
sl@0
|
1067 |
|
sl@0
|
1068 |
//Something that actually exists in Private
|
sl@0
|
1069 |
r=fMan->Rename(name,_L("\\private\\00000001\\moo"));
|
sl@0
|
1070 |
test(r == KErrNone);
|
sl@0
|
1071 |
r=fMan->Rename(_L("\\private\\00000001\\moo"),name);
|
sl@0
|
1072 |
test(r == KErrNone);
|
sl@0
|
1073 |
r=fMan->Copy(name,_L("\\private\\00000001\\moo"));
|
sl@0
|
1074 |
test(r == KErrNone);
|
sl@0
|
1075 |
r=fMan->Delete(_L("\\private\\00000001\\moo"));
|
sl@0
|
1076 |
test(r == KErrNone);
|
sl@0
|
1077 |
|
sl@0
|
1078 |
// Clean up the test data
|
sl@0
|
1079 |
r=fMan->RmDir(_L("\\Caged\\"));
|
sl@0
|
1080 |
test(r == KErrNone);
|
sl@0
|
1081 |
r=fMan->Delete(_L("\\capTest"));
|
sl@0
|
1082 |
test(r == KErrNone);
|
sl@0
|
1083 |
r=fMan->Delete(name);
|
sl@0
|
1084 |
test(r == KErrNone);
|
sl@0
|
1085 |
delete(fMan);
|
sl@0
|
1086 |
}
|
sl@0
|
1087 |
|
sl@0
|
1088 |
// CDirScan tests
|
sl@0
|
1089 |
ScanDir(_L("\\"), CDirScan::EScanUpTree, KErrNone);
|
sl@0
|
1090 |
ScanDir(_L("\\"), CDirScan::EScanDownTree, KErrNone);
|
sl@0
|
1091 |
ScanDir(_L("\\private\\"), CDirScan::EScanDownTree, KErrPermissionDenied);
|
sl@0
|
1092 |
ScanDir(_L("\\private\\"), CDirScan::EScanUpTree, KErrPermissionDenied);
|
sl@0
|
1093 |
}
|
sl@0
|
1094 |
LOCAL_C void CleanDirs()
|
sl@0
|
1095 |
//
|
sl@0
|
1096 |
// Remove system and private directories for scan with and without DC
|
sl@0
|
1097 |
// (note that the \Private directory may not be able to be removed at this
|
sl@0
|
1098 |
// point if it contains other directories, so failing with "in use" is
|
sl@0
|
1099 |
// permitted in this case).
|
sl@0
|
1100 |
//
|
sl@0
|
1101 |
{
|
sl@0
|
1102 |
TInt r;
|
sl@0
|
1103 |
r = TheFs.RmDir(_L("\\normal\\one\\"));
|
sl@0
|
1104 |
test(r == KErrNone);
|
sl@0
|
1105 |
r = TheFs.RmDir(_L("\\normal\\two\\"));
|
sl@0
|
1106 |
test(r == KErrNone);
|
sl@0
|
1107 |
r = TheFs.RmDir(_L("\\normal\\"));
|
sl@0
|
1108 |
test(r == KErrNone);
|
sl@0
|
1109 |
r = TheFs.RmDir(_L("\\sys\\one\\"));
|
sl@0
|
1110 |
test(r == KErrPermissionDenied);
|
sl@0
|
1111 |
r = TheFs.RmDir(_L("\\sys\\two\\"));
|
sl@0
|
1112 |
test(r == KErrPermissionDenied);
|
sl@0
|
1113 |
r = TheFs.RmDir(_L("\\sys\\"));
|
sl@0
|
1114 |
test(r == KErrPermissionDenied);
|
sl@0
|
1115 |
r = TheFs.RmDir(_L("\\private\\one\\"));
|
sl@0
|
1116 |
test(r == KErrPermissionDenied);
|
sl@0
|
1117 |
r = TheFs.RmDir(_L("\\private\\two\\"));
|
sl@0
|
1118 |
test(r == KErrPermissionDenied);
|
sl@0
|
1119 |
r = TheFs.RmDir(_L("\\private\\"));
|
sl@0
|
1120 |
test(r == KErrPermissionDenied);
|
sl@0
|
1121 |
r = TheFs.RmDir(_L("\\ZZZZZZ\\"));
|
sl@0
|
1122 |
test(r == KErrNone);
|
sl@0
|
1123 |
}
|
sl@0
|
1124 |
|
sl@0
|
1125 |
TFileName gDirList[100];
|
sl@0
|
1126 |
TInt gDirNum = 0;
|
sl@0
|
1127 |
|
sl@0
|
1128 |
LOCAL_C void ListDirs()
|
sl@0
|
1129 |
//
|
sl@0
|
1130 |
// List the directories and files on the disk, without DC (so we
|
sl@0
|
1131 |
// find all of them), saving them in gDirList[] apart from
|
sl@0
|
1132 |
// members of the System and Private ones.
|
sl@0
|
1133 |
//
|
sl@0
|
1134 |
{
|
sl@0
|
1135 |
CDirScan* scanner = NULL;
|
sl@0
|
1136 |
TInt r;
|
sl@0
|
1137 |
TRAP(r, scanner = CDirScan::NewL(TheFs));
|
sl@0
|
1138 |
test(r == KErrNone && scanner);
|
sl@0
|
1139 |
TParse dirName;
|
sl@0
|
1140 |
TheFs.Parse(_L("\\"),dirName);
|
sl@0
|
1141 |
TRAP(r, scanner->SetScanDataL(dirName.FullName(),KEntryAttDir,ESortByName|EAscending));
|
sl@0
|
1142 |
test(r == KErrNone);
|
sl@0
|
1143 |
CDir *entryList;
|
sl@0
|
1144 |
test.Printf(_L("------ ALL DIRECTORIES ------\n"));
|
sl@0
|
1145 |
for (;;)
|
sl@0
|
1146 |
{
|
sl@0
|
1147 |
scanner->NextL(entryList);
|
sl@0
|
1148 |
if (entryList==NULL)
|
sl@0
|
1149 |
break;
|
sl@0
|
1150 |
TInt count=entryList->Count();
|
sl@0
|
1151 |
while (count--)
|
sl@0
|
1152 |
{
|
sl@0
|
1153 |
TEntry data=(*entryList)[count];
|
sl@0
|
1154 |
TBuf<KMaxFileName> path=scanner->AbbreviatedPath();
|
sl@0
|
1155 |
gDirList[gDirNum] = path;
|
sl@0
|
1156 |
gDirList[gDirNum].Append(data.iName);
|
sl@0
|
1157 |
test.Printf(_L(" %S\n"),&gDirList[gDirNum]);
|
sl@0
|
1158 |
gDirNum++;
|
sl@0
|
1159 |
}
|
sl@0
|
1160 |
delete entryList;
|
sl@0
|
1161 |
entryList=NULL;
|
sl@0
|
1162 |
}
|
sl@0
|
1163 |
delete scanner;
|
sl@0
|
1164 |
}
|
sl@0
|
1165 |
|
sl@0
|
1166 |
LOCAL_C void TestDirs()
|
sl@0
|
1167 |
//
|
sl@0
|
1168 |
// Scan directories and files with DC on, so only the root \Private
|
sl@0
|
1169 |
// and \System directories should be found (no contents).
|
sl@0
|
1170 |
//
|
sl@0
|
1171 |
{
|
sl@0
|
1172 |
|
sl@0
|
1173 |
MakeDirs();
|
sl@0
|
1174 |
ListDirs();
|
sl@0
|
1175 |
|
sl@0
|
1176 |
CDirScan* scanner = NULL;
|
sl@0
|
1177 |
TInt r;
|
sl@0
|
1178 |
TRAP(r, scanner = CDirScan::NewL(TheFs));
|
sl@0
|
1179 |
test(r == KErrNone && scanner);
|
sl@0
|
1180 |
TParse dirName;
|
sl@0
|
1181 |
TheFs.Parse(_L("\\"),dirName);
|
sl@0
|
1182 |
TRAP(r, scanner->SetScanDataL(dirName.FullName(),KEntryAttDir,ESortByName|EAscending));
|
sl@0
|
1183 |
test(r == KErrNone);
|
sl@0
|
1184 |
CDir *entryList = NULL;
|
sl@0
|
1185 |
TInt num = 0;
|
sl@0
|
1186 |
test.Printf(_L("------ ACCESSIBLE DIRECTORIES ------\n"));
|
sl@0
|
1187 |
for (;;)
|
sl@0
|
1188 |
{
|
sl@0
|
1189 |
TRAP(r, scanner->NextL(entryList));
|
sl@0
|
1190 |
if (r != KErrNone)
|
sl@0
|
1191 |
{
|
sl@0
|
1192 |
test.Printf(_L("*** ERROR %d doing NextL()\n"), r);
|
sl@0
|
1193 |
break;
|
sl@0
|
1194 |
}
|
sl@0
|
1195 |
if (entryList==NULL)
|
sl@0
|
1196 |
break;
|
sl@0
|
1197 |
TInt count=entryList->Count();
|
sl@0
|
1198 |
while (count--)
|
sl@0
|
1199 |
{
|
sl@0
|
1200 |
TEntry data=(*entryList)[count];
|
sl@0
|
1201 |
TBuf<KMaxFileName> path=scanner->AbbreviatedPath();
|
sl@0
|
1202 |
path.Append(data.iName);
|
sl@0
|
1203 |
if (path == gDirList[num])
|
sl@0
|
1204 |
{
|
sl@0
|
1205 |
test.Printf(_L("%S\n"),&path);
|
sl@0
|
1206 |
num++;
|
sl@0
|
1207 |
}
|
sl@0
|
1208 |
else
|
sl@0
|
1209 |
{
|
sl@0
|
1210 |
test.Printf(_L("%S *** NOT FOUND ***\n"),&path);
|
sl@0
|
1211 |
}
|
sl@0
|
1212 |
}
|
sl@0
|
1213 |
delete entryList;
|
sl@0
|
1214 |
entryList=NULL;
|
sl@0
|
1215 |
}
|
sl@0
|
1216 |
delete scanner;
|
sl@0
|
1217 |
CleanDirs();
|
sl@0
|
1218 |
test(r == KErrNone);
|
sl@0
|
1219 |
if (num < gDirNum)
|
sl@0
|
1220 |
{
|
sl@0
|
1221 |
test.Printf(_L("Directory not as expected (%d found < %d expected\n"), num, gDirNum);
|
sl@0
|
1222 |
test(0);
|
sl@0
|
1223 |
}
|
sl@0
|
1224 |
test.Printf(_L("------------------------------------\n"));
|
sl@0
|
1225 |
|
sl@0
|
1226 |
}
|
sl@0
|
1227 |
|
sl@0
|
1228 |
void TestSystemDrive()
|
sl@0
|
1229 |
{
|
sl@0
|
1230 |
test.Next(_L("TestSystemDrive"));
|
sl@0
|
1231 |
TDriveNumber drive = RFs::GetSystemDrive();
|
sl@0
|
1232 |
test.Printf(_L("System Drive is %c:\n"), 'A'+drive);
|
sl@0
|
1233 |
for(TInt i=EDriveA; i<=EDriveZ; i++)
|
sl@0
|
1234 |
{
|
sl@0
|
1235 |
test(TheFs.SetSystemDrive((TDriveNumber)i) == KErrPermissionDenied);
|
sl@0
|
1236 |
}
|
sl@0
|
1237 |
TChar drvchar = RFs::GetSystemDriveChar();
|
sl@0
|
1238 |
test(drvchar == (TChar)('A' + drive));
|
sl@0
|
1239 |
}
|
sl@0
|
1240 |
|
sl@0
|
1241 |
LOCAL_C void CleanupL()
|
sl@0
|
1242 |
//
|
sl@0
|
1243 |
// Clean up tests
|
sl@0
|
1244 |
//
|
sl@0
|
1245 |
{
|
sl@0
|
1246 |
test.Next(_L("Delete test directory"));
|
sl@0
|
1247 |
CFileMan* fMan=CFileMan::NewL(TheFs);
|
sl@0
|
1248 |
TInt r=fMan->RmDir(gSessionPath);
|
sl@0
|
1249 |
test(r==KErrNone);
|
sl@0
|
1250 |
delete fMan;
|
sl@0
|
1251 |
}
|
sl@0
|
1252 |
|
sl@0
|
1253 |
GLDEF_C void CallTestsL(/*TChar aDriveLetter*/)
|
sl@0
|
1254 |
//
|
sl@0
|
1255 |
// Do all tests
|
sl@0
|
1256 |
//
|
sl@0
|
1257 |
{
|
sl@0
|
1258 |
if( !PlatSec::IsCapabilityEnforced(ECapabilityTCB) ||
|
sl@0
|
1259 |
!PlatSec::IsCapabilityEnforced(ECapabilityAllFiles) ||
|
sl@0
|
1260 |
!PlatSec::IsCapabilityEnforced(ECapabilityDiskAdmin))
|
sl@0
|
1261 |
{
|
sl@0
|
1262 |
test.Printf(_L("Insufficient capabilities enabled - leaving t_dcnone"));
|
sl@0
|
1263 |
test.Printf(_L("\n")); // Prevent overwrite by next print
|
sl@0
|
1264 |
return;
|
sl@0
|
1265 |
}
|
sl@0
|
1266 |
TurnAllocFailureOff();
|
sl@0
|
1267 |
TheFs.CharToDrive(gDriveToTest,gTheDriveNum);
|
sl@0
|
1268 |
|
sl@0
|
1269 |
TBuf<30> sesspath;
|
sl@0
|
1270 |
sesspath=_L("?:\\");
|
sl@0
|
1271 |
sesspath[0] = (TText)gDriveToTest;
|
sl@0
|
1272 |
|
sl@0
|
1273 |
TInt r= TheFs.SetSessionPath(sesspath);
|
sl@0
|
1274 |
test(r==KErrNone);
|
sl@0
|
1275 |
|
sl@0
|
1276 |
TBuf<2> cmd;
|
sl@0
|
1277 |
cmd.SetLength(1);
|
sl@0
|
1278 |
cmd[0] = (TText)gDriveToTest;
|
sl@0
|
1279 |
RProcess tp;
|
sl@0
|
1280 |
r=tp.Create(_L("clean_prepdc.exe"),sesspath);
|
sl@0
|
1281 |
test(r==KErrNone);
|
sl@0
|
1282 |
{
|
sl@0
|
1283 |
TRequestStatus ps;
|
sl@0
|
1284 |
tp.Logon(ps);
|
sl@0
|
1285 |
tp.Resume();
|
sl@0
|
1286 |
tp.Close();
|
sl@0
|
1287 |
User::WaitForRequest(ps);
|
sl@0
|
1288 |
}
|
sl@0
|
1289 |
|
sl@0
|
1290 |
//check double mode ie that Defpath still works
|
sl@0
|
1291 |
RFs fs1;
|
sl@0
|
1292 |
RFs fs2;
|
sl@0
|
1293 |
|
sl@0
|
1294 |
r=fs1.Connect();
|
sl@0
|
1295 |
test(r==KErrNone);
|
sl@0
|
1296 |
r=fs1.SessionPath(sesspath);
|
sl@0
|
1297 |
test(r==KErrNone);
|
sl@0
|
1298 |
test.Printf(_L("session1 Path=%S"),&sesspath);
|
sl@0
|
1299 |
|
sl@0
|
1300 |
TBuf<30> privatepath;
|
sl@0
|
1301 |
r=fs1.SetSessionToPrivate(gTheDriveNum);
|
sl@0
|
1302 |
test(r==KErrNone);
|
sl@0
|
1303 |
r=fs1.PrivatePath(privatepath);
|
sl@0
|
1304 |
test(r==KErrNone);
|
sl@0
|
1305 |
r=privatepath.Compare(KExpectedPrivatePath());
|
sl@0
|
1306 |
test(r==0);
|
sl@0
|
1307 |
r=fs1.SessionPath(sesspath);
|
sl@0
|
1308 |
test(r==KErrNone);
|
sl@0
|
1309 |
r=privatepath.Compare(sesspath.Mid(KPathPosition));
|
sl@0
|
1310 |
test(r==0);
|
sl@0
|
1311 |
r=fs1.CreatePrivatePath(gTheDriveNum);
|
sl@0
|
1312 |
test(r==KErrNone);
|
sl@0
|
1313 |
fs1.Close();
|
sl@0
|
1314 |
|
sl@0
|
1315 |
r=fs2.Connect();
|
sl@0
|
1316 |
test(r==KErrNone);
|
sl@0
|
1317 |
r=fs2.SessionPath(sesspath);
|
sl@0
|
1318 |
test(r==KErrNone);
|
sl@0
|
1319 |
test.Printf(_L("session2 Path=%S"),&sesspath);
|
sl@0
|
1320 |
fs2.Close();
|
sl@0
|
1321 |
|
sl@0
|
1322 |
TestCaps();
|
sl@0
|
1323 |
TestCaging();
|
sl@0
|
1324 |
TestDirs();
|
sl@0
|
1325 |
TestPathCheck();
|
sl@0
|
1326 |
TestSystemDrive();
|
sl@0
|
1327 |
|
sl@0
|
1328 |
test.Printf(_L("No of files open=%d"), TheFs.ResourceCount());
|
sl@0
|
1329 |
|
sl@0
|
1330 |
CleanupL();
|
sl@0
|
1331 |
}
|