First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include <e32std_private.h>
22 #include <e32def_private.h>
25 GLDEF_D RTest test(_L("t_dctcb"));
26 GLDEF_D TTime gTimeNow;
27 LOCAL_D TInt gTheDriveNum;
29 const TInt KPathPosition = 2;
30 _LIT(KExpectedPrivatePath, "\\Private\\00000001\\");
33 _LIT(KResourcePath, "?:\\Resource\\");
34 _LIT(KSystemPath, "?:\\Sys\\");
35 _LIT(KPrivatePath, "?:\\Private\\");
36 _LIT(KPrivateFalseID, "?:\\Private\\FFFFFFFF\\");
37 _LIT(KDriveName, "Billy");
38 _LIT(KVolLable, "Benny");
40 _LIT(KFileSys, "systemfile.txt");
41 //_LIT(KFileSys2, "systemfile.tmp");
42 _LIT(KFileSys3, "sysfile.rna");
44 _LIT(KFilePri, "privatefile.txt");
45 _LIT(KFilePri2, "privatefile.tmp");
46 _LIT(KFilePri3, "prifile.rna");
48 _LIT(KFileRes, "resourcefile.txt");
49 //_LIT(KFileRes2, "resourcefile.tmp");
50 _LIT(KFileRes3, "resfile.rna");
52 _LIT(KMkDirSub,"Subdir\\");
53 _LIT(KOldFile,"?:\\Anyold.txt");
54 //_LIT(KNullPath, "");
56 //_LIT(KLFFSName, "Lffs");
58 _LIT(KWildPath, "Z:\\SYS\\");
62 TBuf<4> driveBuf=_L("?:\\");
75 TBuf<40> theprivatepath;
76 TBuf<40> pritestfalseidname;
82 TBuf<40> shortfilename;
83 TBuf<40> longfilename;
85 TRequestStatus aStat1;
86 TRequestStatus aStat2;
87 TRequestStatus aStat3;
88 TRequestStatus aStat4;
95 TBuf<40> systestfile1;
96 TBuf<40> pritestfile1;
97 TBuf<40> restestfile1;
107 LOCAL_C void TestPathCheck()
109 // This test case is brought in by INC054580
110 // (NTT Renaming sys ¨Cfolder on C -drive on H2 allows user to access sys -files)
113 TInt r = TheFs.Rename(_L("\\sys"), _L("\\sysbad"));
115 r = TheFs.Rename(_L("\\resource"), _L("\\resourcebad"));
117 r = TheFs.Rename(_L("\\sysbad"), _L("\\sys"));
119 r = TheFs.Rename(_L("\\resourcebad"), _L("\\resource"));
121 r = TheFs.Rename(_L("\\private"), _L("\\privatebad"));
122 test(r == KErrPermissionDenied);
125 LOCAL_C void systemRFsTest()
127 // RFs test on system Directory
131 systestname=KSystemPath;
132 systestname[0]=(TText)('A' + gTheDriveNum);
135 mkdirname.Append(systestname);
136 mkdirname.Append(KMkDirSub);
137 r=TheFs.MkDirAll(mkdirname);
140 TheFs.RmDir(mkdirname);
143 r=TheFs.SetSubst(systestname,EDriveO);
144 test(r==KErrPermissionDenied);
146 r=TheFs.RealName(_L("O:\\File.XXX"),realName);
149 r=TheFs.SetSessionPath(systestname);
150 test(r==KErrPermissionDenied);
152 TheFs.NotifyChange(ENotifyAll,aStat1,systestname);
153 test(aStat1==KErrPermissionDenied);
155 systestfile=KSystemPath;
156 systestfile[0]=(TText)('A' + gTheDriveNum);
157 systestfile1=systestfile;
158 systestfile.Append(KFileSys);
159 systestfile1.Append(KFileSys3);
162 oldName[0]=(TText)gDriveToTest;
164 r=TheFs.GetShortName(systestfile, shortfilename);
165 test(r==KErrPermissionDenied || r==KErrNotSupported);
167 r=TheFs.GetLongName(systestfile1, longfilename);
168 test(r==KErrPermissionDenied || r==KErrNotSupported);
170 r=file1.Create(TheFs,oldName,EFileWrite);
171 test(r==KErrNone || r==KErrAlreadyExists);
174 r=TheFs.Replace(oldName,systestfile);
177 r=TheFs.Delete(systestfile1);
178 test(r==KErrNone || r==KErrNotFound);
180 r=TheFs.Rename(systestfile,systestfile1);
183 r=TheFs.Entry(systestfile1,entry);
184 test(r==KErrPermissionDenied);
186 r=TheFs.SetEntry(systestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
189 r=TheFs.Delete(systestfile1);
196 LOCAL_C void ResourceRFsTest()
203 restestname=KResourcePath;
204 restestname[0]=(TText)('A' + gTheDriveNum);
207 mkdirname.Append(restestname);
208 mkdirname.Append(KMkDirSub);
209 r=TheFs.MkDirAll(mkdirname);
212 TheFs.RmDir(mkdirname);
215 r=TheFs.SetSubst(restestname,EDriveO);
216 test(r==KErrPermissionDenied || r==KErrGeneral);
218 r=TheFs.RealName(_L("O:\\File.XXX"),realName);
221 r=TheFs.SetSessionPath(restestname);
224 TheFs.NotifyChange(ENotifyAll,aStat4,restestname);
225 test(aStat4==KRequestPending);
227 restestfile=KResourcePath;
228 restestfile[0]=(TText)('A' + gTheDriveNum);
229 restestfile1=restestfile;
230 restestfile.Append(KFileRes);
231 restestfile1.Append(KFileRes3);
234 oldName[0]=(TText)gDriveToTest;
236 r=TheFs.GetShortName(restestfile, shortfilename);
237 test(r==KErrNone || KErrNotFound || r==KErrNotSupported);
239 r=TheFs.GetLongName(restestfile1, longfilename);
240 test(r==KErrNone || KErrNotFound || r==KErrNotSupported);
242 r=file1.Create(TheFs,oldName,EFileWrite);
243 test(r==KErrNone || r==KErrAlreadyExists);
246 r=TheFs.Replace(oldName,restestfile);
249 r=TheFs.Rename(restestfile,restestfile1);
252 r=TheFs.Entry(restestfile1,entry);
255 r=TheFs.SetEntry(restestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
258 r=TheFs.Delete(restestfile1);
265 LOCAL_C void privatefalseIDRFsTest()
273 pritestfalseidname=KPrivateFalseID;
274 pritestfalseidname[0]=(TText)('A' + gTheDriveNum);
277 mkdirname.Append(pritestfalseidname);
278 mkdirname.Append(KMkDirSub);
280 r=TheFs.MkDirAll(mkdirname);
281 test(r==KErrPermissionDenied);
283 r=TheFs.RmDir(mkdirname);
284 test(r==KErrPermissionDenied);
286 r=TheFs.SetSubst(pritestfalseidname,EDriveO);
287 test(r==KErrPermissionDenied);
289 r=TheFs.RealName(_L("O:\\File.XXX"),realName);
292 r=TheFs.SetSessionPath(pritestfalseidname);
293 test(r==KErrPermissionDenied);
295 TheFs.NotifyChange(ENotifyAll,aStat2,pritestfalseidname);
296 test(r==KErrPermissionDenied);
299 pritestfile=KPrivateFalseID;
300 pritestfile[0]=(TText)('A' + gTheDriveNum);
301 pritestfile1=pritestfile;
302 pritestfile.Append(KFilePri2);
303 pritestfile1.Append(KFilePri3);
306 oldName[0]=(TText)gDriveToTest;
308 r=TheFs.GetShortName(pritestfile, shortfilename);
309 test(r==KErrPermissionDenied || r==KErrNotSupported);
311 r=TheFs.GetLongName(pritestfile1, longfilename);
312 test(r==KErrPermissionDenied || r==KErrNotSupported);
314 r=file1.Create(TheFs,oldName,EFileWrite);
315 test(r==KErrNone || r==KErrAlreadyExists);
318 r=TheFs.Replace(oldName,pritestfile);
319 test(r==KErrPermissionDenied);
321 r=TheFs.Rename(pritestfile,pritestfile1);
322 test(r==KErrPermissionDenied);
324 r=TheFs.Entry(pritestfile1,entry);
325 test(r==KErrPermissionDenied);
327 r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
328 test(r==KErrPermissionDenied);
330 r=TheFs.Delete(pritestfile1);
331 test(r==KErrPermissionDenied);
338 LOCAL_C void privateRFsTest()
345 pritestname=KPrivatePath;
346 pritestname[0]=(TText)('A' + gTheDriveNum);
349 mkdirname.Append(pritestname);
350 mkdirname.Append(KMkDirSub);
352 r=TheFs.MkDirAll(mkdirname);
353 test(r==KErrPermissionDenied);
355 r=TheFs.RmDir(mkdirname);
356 test(r==KErrPermissionDenied);
358 r=TheFs.SetSubst(pritestname,EDriveO);
359 test(r==KErrPermissionDenied);
361 r=TheFs.RealName(_L("O:\\File.XXX"),realName);
364 r=TheFs.SetSessionPath(pritestname);
365 test(r==KErrPermissionDenied);
367 TheFs.NotifyChange(ENotifyAll,aStat2,pritestname);
368 test(r==KErrPermissionDenied);
371 pritestfile=KPrivatePath;
372 pritestfile[0]=(TText)('A' + gTheDriveNum);
373 pritestfile1=pritestfile;
374 pritestfile.Append(KFilePri2);
375 pritestfile1.Append(KFilePri3);
378 oldName[0]=(TText)gDriveToTest;
380 r=TheFs.GetShortName(pritestfile, shortfilename);
381 test(r==KErrPermissionDenied || r==KErrNotSupported);
383 r=TheFs.GetLongName(pritestfile1, longfilename);
384 test(r==KErrPermissionDenied || r==KErrNotSupported);
386 r=file1.Create(TheFs,oldName,EFileWrite);
387 test(r==KErrNone || r==KErrAlreadyExists);
390 r=TheFs.Replace(oldName,pritestfile);
391 test(r==KErrPermissionDenied);
393 r=TheFs.Rename(pritestfile,pritestfile1);
394 test(r==KErrPermissionDenied);
396 r=TheFs.Entry(pritestfile1,entry);
397 test(r==KErrPermissionDenied);
399 r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
400 test(r==KErrPermissionDenied);
402 r=TheFs.Delete(pritestfile1);
403 test(r==KErrPermissionDenied);
409 LOCAL_C void privateSIDRFstest()
413 theprivatepath[0]=(TText)gDriveToTest;
414 test.Printf(_L("the Private Path = %S"),&theprivatepath);
417 mkdirname.Append(theprivatepath);
418 mkdirname.Append(KMkDirSub);
419 r=TheFs.MkDirAll(mkdirname);
422 r=TheFs.RmDir(mkdirname);
425 r=TheFs.SetSubst(theprivatepath,EDriveO);
426 test(r==KErrPermissionDenied || r==KErrGeneral); // Drive may already be substituted
428 r=TheFs.RealName(_L("O:\\File.XXX"),realName);
431 r=TheFs.SetSessionPath(theprivatepath);
434 TheFs.NotifyChange(ENotifyAll,aStat3,theprivatepath);
435 test(aStat3==KRequestPending);
437 pritestfile=theprivatepath;
438 pritestfile[0]=(TText)('A' + gTheDriveNum);
439 pritestfile1=pritestfile;
440 pritestfile.Append(KFilePri2);
441 pritestfile1.Append(KFilePri3);
444 oldName[0]=(TText)gDriveToTest;
446 r=TheFs.GetShortName(pritestfile, shortfilename);
447 test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
449 r=TheFs.GetLongName(pritestfile1, longfilename);
450 test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
452 r=file1.Create(TheFs,oldName,EFileWrite);
453 test(r==KErrNone || r==KErrAlreadyExists);
456 r=TheFs.Replace(oldName,pritestfile);
459 r=TheFs.Rename(pritestfile,pritestfile1);
460 test(r==KErrNone || r==KErrAlreadyExists);
462 r=TheFs.Entry(pritestfile1,entry);
465 r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
468 r=TheFs.Delete(pritestfile1);
475 LOCAL_C void systemRFiletest()
477 //RFile testing with session path set to //sys//
482 r=TheFs.SetSessionPath(systestname);
483 test(r==KErrPermissionDenied);
485 r=file1.Temp(TheFs,systestname,fromTemp,EFileWrite);
489 TBuf<25> sysfilename;
490 sysfilename.Append(systestname);
491 sysfilename.Append(KFileSys);
493 r=file1.Create(TheFs,sysfilename,EFileWrite);
497 r=file1.Open(TheFs,sysfilename,EFileWrite);
501 r=file1.Open(TheFs,sysfilename,EFileRead);
502 test(r==KErrPermissionDenied);
505 r=file1.Replace(TheFs,sysfilename,EFileWrite);
508 TBuf<25> sysfilename2;
509 sysfilename2.Append(systestname);
510 sysfilename2.Append(KFileSys3);
512 r=file1.Rename(sysfilename2);
516 TFindFile finder(TheFs);
518 r=finder.FindWildByDir(KWildFile, KWildPath, dir);
519 if (!(r==KErrPermissionDenied))
520 test.Printf(_L("T_DCTCB: test find wildcards r = %d (expected KErrPermissionDenied)\n"), r);
521 test(r==KErrPermissionDenied);
527 LOCAL_C void resourceRFiletest()
529 //RFile testing with session path set to //resource//
534 r=TheFs.SetSessionPath(restestname);
537 r=file1.Temp(TheFs,restestname,fromTemp,EFileWrite);
541 r=file1.Create(TheFs,KFileRes,EFileWrite);
545 r=file1.Open(TheFs,KFileRes,EFileWrite|EFileShareExclusive );
548 r=file1.Rename(KFileRes3);
552 r=file1.Open(TheFs,KFileRes3,EFileShareReadersOrWriters|EFileRead);
556 r=file1.Open(TheFs,KFileRes3,EFileShareReadersOrWriters|EFileWrite);
560 r=file1.Open(TheFs,KFileRes3,EFileShareReadersOnly);
563 r=file1.ChangeMode(EFileShareExclusive);
567 r=file1.Replace(TheFs,KFileRes,EFileWrite);
576 LOCAL_C void privatefalseIDRFiletest()
578 //RFile testing with session path set to //Private//false ID
583 r=TheFs.SetSessionPath(pritestfalseidname);
584 test(r==KErrPermissionDenied);
586 r=file1.Temp(TheFs,pritestfalseidname,fromTemp,EFileWrite);
587 test(r==KErrPermissionDenied);
590 // Since can't set session path create explicit path
591 pritestfile=KPrivateFalseID;
592 pritestfile[0]=(TText)('A' + gTheDriveNum);
593 pritestfile.Append(KFilePri);
595 r=file1.Create(TheFs,pritestfile,EFileWrite);
596 test(r==KErrPermissionDenied);
599 r=file1.Open(TheFs,pritestfile,EFileWrite);
600 test(r==KErrPermissionDenied);
603 r=file1.Open(TheFs,pritestfile,EFileRead);
604 test(r==KErrPermissionDenied);
607 r=file1.Replace(TheFs,pritestfile,EFileWrite);
608 test(r==KErrPermissionDenied);
610 // File does not exist so can't rename it
611 /* r=file1.Rename(KFilePri3);
612 test(r==KErrAlreadyExists || r==KErrNone);
618 LOCAL_C void privateRFiletest()
620 //RFile testing with session path set to //Private//
625 r=TheFs.SetSessionPath(pritestname);
626 test(r==KErrPermissionDenied);
628 r=file1.Temp(TheFs,pritestname,fromTemp,EFileWrite);
629 test(r==KErrPermissionDenied);
632 // Since can't set session path create explicit path
633 pritestfile=KPrivatePath;
634 pritestfile[0]=(TText)('A' + gTheDriveNum);
635 pritestfile.Append(KFilePri);
637 r=file1.Create(TheFs,pritestfile,EFileWrite);
638 test(r==KErrPermissionDenied);
641 r=file1.Open(TheFs,pritestfile,EFileWrite);
642 test(r==KErrPermissionDenied);
645 r=file1.Open(TheFs,pritestfile,EFileRead);
646 test(r==KErrPermissionDenied);
649 r=file1.Replace(TheFs,pritestfile,EFileWrite);
650 test(r==KErrPermissionDenied);
652 // File does not exist so can't be renamed
653 /* r=file1.Rename(KFilePri3);
661 LOCAL_C void privateSIDRFiletest()
663 //Rfile Testing with session path set to //Private//UID//
667 r=TheFs.SetSessionToPrivate(gTheDriveNum);
670 r=file1.Temp(TheFs,theprivatepath,fromTemp,EFileWrite);
674 r=file1.Create(TheFs,KFilePri,EFileWrite);
678 r=file1.Open(TheFs,KFilePri,EFileWrite);
682 r=file1.Open(TheFs,KFilePri,EFileRead);
686 r=file1.Replace(TheFs,KFilePri,EFileWrite);
689 r=file1.Rename(KFilePri3);
695 LOCAL_C void RDirtest()
704 TBuf<30> dirNameBuf(KSystemPath);
705 dirNameBuf[0]=(TText)gDriveToTest;
706 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
707 test(r==KErrPermissionDenied);
709 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
710 test(r==KErrPermissionDenied);
715 dirNameBuf=KPrivatePath;
716 dirNameBuf[0]=(TText)gDriveToTest;
717 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
718 test(r==KErrPermissionDenied);
720 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
721 test(r==KErrPermissionDenied);
726 dirNameBuf=KPrivateFalseID;
727 dirNameBuf[0]=(TText)gDriveToTest;
728 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
729 test(r==KErrPermissionDenied);
731 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
732 test(r==KErrPermissionDenied);
737 TheFs.PrivatePath(dirNameBuf);
738 dirNameBuf.Insert(0,_L("?:"));
739 dirNameBuf[0]=(TText)gDriveToTest;
740 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
743 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
748 dirNameBuf=KResourcePath;
749 dirNameBuf[0]=(TText)gDriveToTest;
750 r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
752 r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
760 LOCAL_C void TestTcbCaps()
762 // Test with tcb capabilities
766 r=TheFs.FileSystemName(fsname,gTheDriveNum);
768 r = DismountFileSystem(TheFs, fsname, gTheDriveNum);
769 test(r==KErrPermissionDenied);
770 r = MountFileSystem(TheFs, fsname, gTheDriveNum);
771 test(r==KErrPermissionDenied);
772 r=TheFs.SetDriveName(gTheDriveNum,KDriveName);
773 test(r==KErrPermissionDenied);
775 r=TheFs.SetVolumeLabel(KVolLable, gTheDriveNum);
776 test(r==KErrPermissionDenied);
784 privatefalseIDRFsTest();
789 privateSIDRFiletest();
790 privatefalseIDRFiletest();
792 //check notifier return values set in rfs testing
793 User::WaitForRequest(aStat1);
794 User::WaitForRequest(aStat2);
795 User::WaitForRequest(aStat3);
796 User::WaitForRequest(aStat4);
797 test(aStat1==KErrPermissionDenied);
798 test(aStat2==KErrPermissionDenied);
799 test(aStat3==KErrNone);
800 test(aStat4==KErrNone);
802 r=TheFs.SetSessionPath(systestname);
803 test(r==KErrPermissionDenied);
805 //Test RRawDisk class
806 r=rawdisk.Open(TheFs,gTheDriveNum);
813 if (User::UpperCase(driveBuf[0]) != 'C')
817 r=format.Open(TheFs,driveBuf,EHighDensity,count);
818 test(r==KErrPermissionDenied);
822 TInt r=format.Next(count);
828 driveBuf[0]=(TText)gDriveToTest;
829 r=TheFs.ScanDrive(driveBuf);
830 test((r==KErrPermissionDenied)||(r==KErrNotSupported));
831 r=TheFs.CheckDisk(driveBuf);
832 test((r==KErrPermissionDenied)||(r==KErrNotSupported));
836 LOCAL_C void TestCaps()
838 // test format etc that require certain capabilities
842 #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
843 const char myDiagMsg[] = "Capability Check Failure";
844 #endif //!__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
845 r=RProcess().HasCapability(ECapabilityTCB, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
848 driveBuf[0]=(TText)gDriveToTest;
849 r=TheFs.SessionPath(temp);
851 test.Printf(_L("Session path: %S"),&temp);
852 r=TheFs.CreatePrivatePath(gTheDriveNum);
853 test(r==KErrNone || r== KErrAlreadyExists);
856 r=TheFs.PrivatePath(tempPri);
858 theprivatepath = _L("?:");
859 theprivatepath.Append(tempPri);
863 TFileName thesessionpath;
864 r=TheFs.SetSessionToPrivate(gTheDriveNum);
866 r=TheFs.SessionPath(thesessionpath);
868 test(thesessionpath == theprivatepath);
875 LOCAL_C void ScanDir(const TDesC& aName, CDirScan::TScanDirection aDirection, TInt aError)
877 CDirScan* scanner = NULL;
878 TRAP(r, scanner = CDirScan::NewL(TheFs));
879 test(r == KErrNone && scanner);
881 TRAP(r, scanner->SetScanDataL(aName,KEntryAttDir,ESortByName|EAscending,aDirection));
884 CDir *entryList=NULL;
887 TRAP(r, scanner->NextL(entryList));
891 TInt count=entryList->Count();
894 TEntry data=(*entryList)[count];
895 TBuf<KMaxFileName> path=scanner->AbbreviatedPath();
897 dirName.Append(data.iName);
898 test.Printf(_L(" %S\n"),&dirName);
909 The following test, tests CFileMan and CDirScan API on folders private and sys
910 to confirm that any operation on these folders for any app with incorrect capability
911 returns KErrPermissionDenied. This test step was added as a result of DEF051428
912 ("PlatSec: Incorrect errors returned by f32")
914 LOCAL_C void TestCaging()
916 CFileMan* fMan=CFileMan::NewL(TheFs);
921 // Checking the private path
922 TBuf<30> privatepath;
923 r=TheFs.PrivatePath(privatepath);
924 test.Printf(_L("Private Path is=%S"),&privatepath);
926 r = TheFs.MkDir(_L("\\Caged\\"));
927 test(r==KErrNone || r==KErrAlreadyExists);
929 CDir* entryCount=NULL;
930 r=TheFs.GetDir(_L("\\*.*"),KEntryAttNormal,ESortNone,entryCount);
932 TInt rootCount= entryCount->Count();
939 CDir* entryCount2=NULL;
940 r=fMan->Copy(_L("\\sys\\"),_L("\\Caged\\"));
941 test(r == KErrPermissionDenied);
942 r=fMan->Copy(_L("\\*"),_L("\\Caged\\"));
945 r=TheFs.GetDir(_L("\\Caged\\*.*"),KEntryAttNormal,ESortNone,entryCount2);
947 TInt cagedCount= entryCount2->Count();
949 test(cagedCount==rootCount);
954 r=fMan->Copy(_L("\\private\\two\\moo"),_L("\\private\\two\\mew"));
955 test(r == KErrPermissionDenied);
957 // Create a test file
959 r = testFile.Replace(TheFs, _L("\\capTest"),EFileWrite);
960 test(r==KErrNone || r==KErrAlreadyExists);
965 name.Append(_L("privateFile.tst"));
967 r = privateFile.Replace(TheFs, name,EFileWrite);
968 test(r==KErrNone || r==KErrAlreadyExists);
972 r=fMan->Copy(_L("\\capTest"),_L("\\private\\two\\moo"));
973 test(r == KErrPermissionDenied);
974 r=fMan->Copy(_L("\\capTest"),_L("\\sys\\bin\\moo"));
975 test(r == KErrPathNotFound);
976 r=fMan->Copy(_L("\\sys\\bin\\capTest"),_L("\\sys\\bin\\moo"));
977 test(r == KErrPermissionDenied);
978 r=fMan->Copy(_L("\\capTest"),_L("\\sys\\capTest"));
979 test(r == KErrNone || r==KErrAlreadyExists);
980 r=fMan->Copy(_L("\\sys\\*"),_L("\\"));
981 test (r==KErrPermissionDenied);
982 r=fMan->Copy(name,_L("\\sys\\"));
986 r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo"));
987 test(r == KErrPermissionDenied);
988 r=fMan->Move(_L("\\private\\two\\moo.."),_L("\\private\\one\\moo"));
989 test(r == KErrPermissionDenied);
990 r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo.."));
991 test(r == KErrPermissionDenied);
992 r=fMan->Move(name,_L("\\privateFile.tst"));
994 r=fMan->Move(_L("\\privateFile.tst"),name);
999 r=fMan->Attribs(_L("\\private\\two\\moo"),KEntryAttReadOnly,0,TTime(0));
1000 test(r == KErrPermissionDenied);
1001 r=fMan->Attribs(_L("\\private\\moo"),KEntryAttReadOnly,0,TTime(0));
1002 test(r == KErrPermissionDenied);
1003 r=fMan->Attribs(name,KEntryAttReadOnly,0,TTime(0));
1004 test(r == KErrNone);
1005 r=fMan->Attribs(name,0,KEntryAttReadOnly,TTime(0));
1006 test(r == KErrNone);
1009 r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo"));
1010 test(r == KErrPermissionDenied);
1011 r=fMan->Move(_L("\\private\\two\\moo.."),_L("\\private\\one\\moo"));
1012 test(r == KErrPermissionDenied);
1013 r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo.."));
1014 test(r == KErrPermissionDenied);
1015 r=fMan->Move(name,_L("\\privateFile.tst"));
1016 test(r == KErrNone);
1017 r=fMan->Move(_L("\\privateFile.tst"),name);
1018 test(r == KErrNone);
1022 r=fMan->RmDir(_L("\\private\\"));
1023 test(r == KErrPermissionDenied);
1024 r=fMan->RmDir(_L("\\private\\two\\"));
1025 test(r == KErrPermissionDenied);
1026 r=fMan->RmDir(_L("\\private\\tw?\\"));
1027 test(r == KErrPermissionDenied);
1028 r=fMan->RmDir(_L("\\sys\\"));
1029 test(r == KErrPermissionDenied);
1033 r=fMan->Rename(_L("\\private\\two\\moo"),_L("\\private\\two\\mew"));
1034 test(r == KErrPermissionDenied);
1037 r=fMan->Delete(_L("\\private\\two\\test"));
1038 test(r == KErrPermissionDenied);
1039 r=fMan->Delete(_L("\\private\\moo"));
1040 test(r == KErrPermissionDenied);
1041 r=fMan->Delete(_L("\\sys\\"));
1042 test(r == KErrPermissionDenied);
1044 //Something that actually exists in Private
1045 r=fMan->Rename(name,_L("\\private\\00000001\\moo"));
1046 test(r == KErrNone);
1047 r=fMan->Rename(_L("\\private\\00000001\\moo"),name);
1048 test(r == KErrNone);
1049 r=fMan->Copy(name,_L("\\private\\00000001\\moo"));
1050 test(r == KErrNone);
1051 r=fMan->Delete(_L("\\private\\00000001\\moo"));
1052 test(r == KErrNone);
1054 // Clean up the test data
1055 r=fMan->RmDir(_L("\\Caged\\"));
1056 test(r == KErrNone);
1057 r=fMan->Delete(_L("\\capTest"));
1058 test(r == KErrNone);
1059 r=fMan->Delete(name);
1060 test(r == KErrNone);
1065 ScanDir(_L("\\"), CDirScan::EScanUpTree, KErrNone);
1066 ScanDir(_L("\\"), CDirScan::EScanDownTree, KErrNone);
1067 ScanDir(_L("\\private\\"), CDirScan::EScanDownTree, KErrPermissionDenied);
1068 ScanDir(_L("\\private\\"), CDirScan::EScanUpTree, KErrPermissionDenied);
1069 ScanDir(_L("\\sys\\"), CDirScan::EScanDownTree, KErrPermissionDenied);
1070 ScanDir(_L("\\sys\\"), CDirScan::EScanUpTree, KErrPermissionDenied);
1073 void TestSystemDrive()
1075 test.Next(_L("TestSystemDrive"));
1076 TDriveNumber drive = RFs::GetSystemDrive();
1077 test.Printf(_L("System Drive is %c:\n"), 'A'+drive);
1078 for(TInt i=EDriveA; i<=EDriveZ; i++)
1081 test(TheFs.Drive(info, i) == KErrNone);
1082 if(info.iType==EMediaHardDisk || info.iType==EMediaFlash || info.iType==EMediaNANDFlash)
1084 if(info.iDriveAtt & (KDriveAttLocal|KDriveAttInternal))
1086 if(!(info.iDriveAtt & (KDriveAttRom|KDriveAttRedirected|KDriveAttSubsted|KDriveAttRemovable)))
1088 test.Printf(_L("Setting %c:"), 'A'+i);
1089 TInt ret = TheFs.SetSystemDrive((TDriveNumber)i);
1090 test.Printf(_L("%d\n"), ret);
1091 test(ret == KErrNone || ret == KErrAlreadyExists);
1094 drive = (TDriveNumber)i;
1095 test.Printf(_L("Re-setting %c:"), 'A'+i);
1096 ret = TheFs.SetSystemDrive(drive);
1097 test.Printf(_L("%d\n"), ret);
1098 test(ret == KErrAlreadyExists);
1104 TChar drvchar = RFs::GetSystemDriveChar();
1105 test(drvchar == (TChar)('A' + drive));
1106 test(drive == RFs::GetSystemDrive());
1109 LOCAL_C void CleanupL()
1114 test.Next(_L("Delete test directory"));
1115 CFileMan* fMan=CFileMan::NewL(TheFs);
1116 TInt r=fMan->RmDir(gSessionPath);
1117 test(r==KErrNone || KErrPathNotFound);
1121 GLDEF_C void CallTestsL(/*TChar aDriveLetter*/)
1126 if( !PlatSec::IsCapabilityEnforced(ECapabilityTCB))
1128 test.Printf(_L("Capability ECapabilityTCB not enabled - leaving t_dctcb"));
1129 test.Printf(_L("\n")); // Prevent overwrite by next print
1133 TurnAllocFailureOff();
1134 TheFs.CharToDrive(gDriveToTest,gTheDriveNum);
1137 sesspath=_L("?:\\");
1138 sesspath[0] = (TText)gDriveToTest;
1140 TInt r= TheFs.SetSessionPath(sesspath);
1143 //cleanup from previous run of this test
1145 CFileMan* fMan=CFileMan::NewL(TheFs);
1146 delDir=KResourcePath;
1147 delDir[0]=(TText)gDriveToTest;
1148 r=fMan->RmDir(delDir);
1149 test(r==KErrNone || KErrNotFound);
1151 delDir[0]=(TText)gDriveToTest;
1152 r=fMan->RmDir(delDir);
1153 test(r==KErrNone || KErrNotFound);
1154 delDir=KPrivatePath;
1155 delDir[0]=(TText)gDriveToTest;
1156 r=fMan->RmDir(delDir);
1157 test(r==KErrNone || KErrNotFound);
1160 //check double mode ie that Defpath still works
1166 r=fs1.SessionPath(sesspath);
1168 test.Printf(_L("session1 Path=%S"),&sesspath);
1170 TBuf<30> privatepath;
1171 r=fs1.SetSessionToPrivate(gTheDriveNum);
1173 r=fs1.PrivatePath(privatepath);
1175 r=privatepath.Compare(KExpectedPrivatePath());
1177 r=fs1.SessionPath(sesspath);
1179 r=privatepath.Compare(sesspath.Mid(KPathPosition));
1181 r=fs1.CreatePrivatePath(gTheDriveNum);
1187 r=fs2.SessionPath(sesspath);
1189 test.Printf(_L("session2 Path=%S"),&sesspath);
1197 test.Printf(_L("No of files open=%d"), TheFs.ResourceCount());