os/kernelhwsrv/kerneltest/f32test/server/t_dctcb.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/server/t_dctcb.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1200 @@
     1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <f32file.h>
    1.20 +#include <e32test.h>
    1.21 +#include <e32std.h>
    1.22 +#include <e32std_private.h>
    1.23 +#include <e32svr.h>
    1.24 +#include <e32def.h>
    1.25 +#include <e32def_private.h>
    1.26 +#include "t_server.h"
    1.27 +
    1.28 +GLDEF_D RTest test(_L("t_dctcb"));
    1.29 +GLDEF_D TTime gTimeNow;
    1.30 +LOCAL_D TInt gTheDriveNum;
    1.31 +
    1.32 +const TInt KPathPosition = 2;
    1.33 +_LIT(KExpectedPrivatePath, "\\Private\\00000001\\");
    1.34 +
    1.35 +
    1.36 +_LIT(KResourcePath, "?:\\Resource\\");
    1.37 +_LIT(KSystemPath,	"?:\\Sys\\");
    1.38 +_LIT(KPrivatePath,	"?:\\Private\\");
    1.39 +_LIT(KPrivateFalseID,	"?:\\Private\\FFFFFFFF\\");
    1.40 +_LIT(KDriveName,	"Billy");
    1.41 +_LIT(KVolLable,		"Benny");
    1.42 +
    1.43 +_LIT(KFileSys,	"systemfile.txt");
    1.44 +//_LIT(KFileSys2,	"systemfile.tmp");
    1.45 +_LIT(KFileSys3, "sysfile.rna");
    1.46 +
    1.47 +_LIT(KFilePri,	"privatefile.txt");
    1.48 +_LIT(KFilePri2,	"privatefile.tmp");
    1.49 +_LIT(KFilePri3,	"prifile.rna");
    1.50 +
    1.51 +_LIT(KFileRes,	"resourcefile.txt");
    1.52 +//_LIT(KFileRes2,	"resourcefile.tmp");
    1.53 +_LIT(KFileRes3,	"resfile.rna");
    1.54 +
    1.55 +_LIT(KMkDirSub,"Subdir\\");
    1.56 +_LIT(KOldFile,"?:\\Anyold.txt");
    1.57 +//_LIT(KNullPath, "");
    1.58 +
    1.59 +//_LIT(KLFFSName, "Lffs");
    1.60 +
    1.61 +_LIT(KWildPath, "Z:\\SYS\\");
    1.62 +_LIT(KWildFile, "*");
    1.63 +
    1.64 +TCapability TheCaps;
    1.65 +TBuf<4> driveBuf=_L("?:\\");
    1.66 +RFormat format;
    1.67 +TInt count;
    1.68 +RRawDisk rawdisk;
    1.69 +RFile file1;
    1.70 +RFile file2;
    1.71 +RDir	dir;
    1.72 +
    1.73 +TInt r;
    1.74 +TBuf<40> fsname;
    1.75 +TBuf<40> systestname;
    1.76 +TBuf<40> pritestname;
    1.77 +TBuf<40> restestname;
    1.78 +TBuf<40> theprivatepath;
    1.79 +TBuf<40> pritestfalseidname;
    1.80 +TBuf<40> mkdirname;
    1.81 +TFileName fromTemp;
    1.82 +
    1.83 +TBuf<25> sysfilename;
    1.84 +TBuf<30> realName;
    1.85 +TBuf<40> shortfilename;
    1.86 +TBuf<40> longfilename;
    1.87 +
    1.88 +TRequestStatus aStat1;
    1.89 +TRequestStatus aStat2;
    1.90 +TRequestStatus aStat3;
    1.91 +TRequestStatus aStat4;
    1.92 +
    1.93 +TVolumeInfo aVolInfo;
    1.94 +
    1.95 +TBuf<40> systestfile;
    1.96 +TBuf<40> pritestfile;
    1.97 +TBuf<40> restestfile;
    1.98 +TBuf<40> systestfile1;
    1.99 +TBuf<40> pritestfile1;
   1.100 +TBuf<40> restestfile1;
   1.101 +
   1.102 +TTime testtime;
   1.103 +TBuf<20> oldName;
   1.104 +
   1.105 +TBuf<25> temp;
   1.106 +
   1.107 +TEntry entry;
   1.108 +
   1.109 +
   1.110 +LOCAL_C void TestPathCheck()
   1.111 +//
   1.112 +// This test case is brought in by INC054580
   1.113 +// (NTT Renaming sys ¨Cfolder on C -drive on H2 allows user to access sys -files)
   1.114 +//
   1.115 +    {
   1.116 +    TInt r = TheFs.Rename(_L("\\sys"), _L("\\sysbad"));
   1.117 +    test(r == KErrNone);
   1.118 +    r = TheFs.Rename(_L("\\resource"), _L("\\resourcebad"));
   1.119 +    test(r == KErrNone);
   1.120 +    r = TheFs.Rename(_L("\\sysbad"), _L("\\sys"));
   1.121 +    test(r == KErrNone);
   1.122 +    r = TheFs.Rename(_L("\\resourcebad"), _L("\\resource"));
   1.123 +    test(r == KErrNone);
   1.124 +    r = TheFs.Rename(_L("\\private"), _L("\\privatebad"));
   1.125 +    test(r == KErrPermissionDenied);
   1.126 +    }
   1.127 +
   1.128 +LOCAL_C void systemRFsTest()
   1.129 +//
   1.130 +//	RFs test on system Directory
   1.131 +//
   1.132 +	{
   1.133 +	__UHEAP_MARK;
   1.134 +	systestname=KSystemPath;
   1.135 +	systestname[0]=(TText)('A' + gTheDriveNum);
   1.136 +	
   1.137 +	mkdirname.Zero();
   1.138 +	mkdirname.Append(systestname);
   1.139 +	mkdirname.Append(KMkDirSub);
   1.140 +	r=TheFs.MkDirAll(mkdirname);	
   1.141 +	test(r==KErrNone);
   1.142 +
   1.143 +	TheFs.RmDir(mkdirname);
   1.144 +	test(r==KErrNone);
   1.145 +
   1.146 +	r=TheFs.SetSubst(systestname,EDriveO);
   1.147 +	test(r==KErrPermissionDenied);
   1.148 +	
   1.149 +	r=TheFs.RealName(_L("O:\\File.XXX"),realName);
   1.150 +	test(r==KErrNone);
   1.151 +
   1.152 +	r=TheFs.SetSessionPath(systestname);
   1.153 +	test(r==KErrPermissionDenied);
   1.154 +	
   1.155 +	TheFs.NotifyChange(ENotifyAll,aStat1,systestname);
   1.156 +	test(aStat1==KErrPermissionDenied);
   1.157 +
   1.158 +	systestfile=KSystemPath;
   1.159 +	systestfile[0]=(TText)('A' + gTheDriveNum);
   1.160 +	systestfile1=systestfile;
   1.161 +	systestfile.Append(KFileSys);
   1.162 +	systestfile1.Append(KFileSys3);
   1.163 +	
   1.164 +	oldName=KOldFile;
   1.165 +	oldName[0]=(TText)gDriveToTest;
   1.166 +
   1.167 +	r=TheFs.GetShortName(systestfile, shortfilename);
   1.168 +	test(r==KErrPermissionDenied || r==KErrNotSupported);
   1.169 +
   1.170 +	r=TheFs.GetLongName(systestfile1, longfilename);
   1.171 +	test(r==KErrPermissionDenied || r==KErrNotSupported);
   1.172 +
   1.173 +	r=file1.Create(TheFs,oldName,EFileWrite);
   1.174 +	test(r==KErrNone || r==KErrAlreadyExists);
   1.175 +	file1.Close();
   1.176 +
   1.177 +	r=TheFs.Replace(oldName,systestfile);
   1.178 +	test(r==KErrNone);
   1.179 +	
   1.180 +	r=TheFs.Delete(systestfile1);
   1.181 +	test(r==KErrNone || r==KErrNotFound);
   1.182 +
   1.183 +	r=TheFs.Rename(systestfile,systestfile1);
   1.184 +	test(r==KErrNone);
   1.185 +	
   1.186 +	r=TheFs.Entry(systestfile1,entry);
   1.187 +	test(r==KErrPermissionDenied);
   1.188 +
   1.189 +	r=TheFs.SetEntry(systestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
   1.190 +	test(r==KErrNone);
   1.191 +
   1.192 +	r=TheFs.Delete(systestfile1);
   1.193 +	test(r==KErrNone);
   1.194 +
   1.195 +	__UHEAP_MARKEND;
   1.196 +
   1.197 +	}
   1.198 +
   1.199 +LOCAL_C void ResourceRFsTest()
   1.200 +//
   1.201 +//
   1.202 +//
   1.203 +	{
   1.204 +	__UHEAP_MARK;
   1.205 +
   1.206 +	restestname=KResourcePath;
   1.207 +	restestname[0]=(TText)('A' + gTheDriveNum);
   1.208 +	
   1.209 +	mkdirname.Zero();
   1.210 +	mkdirname.Append(restestname);
   1.211 +	mkdirname.Append(KMkDirSub);
   1.212 +	r=TheFs.MkDirAll(mkdirname);	
   1.213 +	test(r==KErrNone);
   1.214 +
   1.215 +	TheFs.RmDir(mkdirname);
   1.216 +	test(r==KErrNone);
   1.217 +
   1.218 +	r=TheFs.SetSubst(restestname,EDriveO);
   1.219 +	test(r==KErrPermissionDenied || r==KErrGeneral);
   1.220 +	
   1.221 +	r=TheFs.RealName(_L("O:\\File.XXX"),realName);
   1.222 +	test(r==KErrNone);
   1.223 +
   1.224 +	r=TheFs.SetSessionPath(restestname);
   1.225 +	test(r==KErrNone);
   1.226 +	
   1.227 +	TheFs.NotifyChange(ENotifyAll,aStat4,restestname);
   1.228 +	test(aStat4==KRequestPending);
   1.229 +
   1.230 +	restestfile=KResourcePath;
   1.231 +	restestfile[0]=(TText)('A' + gTheDriveNum);
   1.232 +	restestfile1=restestfile;
   1.233 +	restestfile.Append(KFileRes);
   1.234 +	restestfile1.Append(KFileRes3);
   1.235 +	
   1.236 +	oldName=KOldFile;
   1.237 +	oldName[0]=(TText)gDriveToTest;
   1.238 +
   1.239 +	r=TheFs.GetShortName(restestfile, shortfilename);
   1.240 +	test(r==KErrNone || KErrNotFound || r==KErrNotSupported);
   1.241 +
   1.242 +	r=TheFs.GetLongName(restestfile1, longfilename);
   1.243 +	test(r==KErrNone || KErrNotFound || r==KErrNotSupported);
   1.244 +
   1.245 +	r=file1.Create(TheFs,oldName,EFileWrite);
   1.246 +	test(r==KErrNone || r==KErrAlreadyExists);
   1.247 +	file1.Close();
   1.248 +
   1.249 +	r=TheFs.Replace(oldName,restestfile);
   1.250 +	test(r==KErrNone);
   1.251 +	
   1.252 +	r=TheFs.Rename(restestfile,restestfile1);
   1.253 +	test(r==KErrNone);
   1.254 +	
   1.255 +	r=TheFs.Entry(restestfile1,entry);
   1.256 +	test(r==KErrNone);
   1.257 +
   1.258 +	r=TheFs.SetEntry(restestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
   1.259 +	test(r==KErrNone);
   1.260 +
   1.261 +	r=TheFs.Delete(restestfile1);
   1.262 +	test(r==KErrNone);
   1.263 +
   1.264 +	__UHEAP_MARK;
   1.265 +
   1.266 +	}
   1.267 +
   1.268 +LOCAL_C void privatefalseIDRFsTest()
   1.269 +//
   1.270 +//
   1.271 +//
   1.272 +	{
   1.273 +	__UHEAP_MARK;
   1.274 +
   1.275 +	//private
   1.276 +	pritestfalseidname=KPrivateFalseID;
   1.277 +	pritestfalseidname[0]=(TText)('A' + gTheDriveNum);
   1.278 +	
   1.279 +	mkdirname.Zero();
   1.280 +	mkdirname.Append(pritestfalseidname);
   1.281 +	mkdirname.Append(KMkDirSub);
   1.282 +
   1.283 +	r=TheFs.MkDirAll(mkdirname);	
   1.284 +	test(r==KErrPermissionDenied);
   1.285 +
   1.286 +	r=TheFs.RmDir(mkdirname);	
   1.287 +	test(r==KErrPermissionDenied);
   1.288 +
   1.289 +	r=TheFs.SetSubst(pritestfalseidname,EDriveO);
   1.290 +	test(r==KErrPermissionDenied);
   1.291 +
   1.292 +	r=TheFs.RealName(_L("O:\\File.XXX"),realName);
   1.293 +	test(r==KErrNone);
   1.294 +
   1.295 +	r=TheFs.SetSessionPath(pritestfalseidname);
   1.296 +	test(r==KErrPermissionDenied);
   1.297 +
   1.298 +	TheFs.NotifyChange(ENotifyAll,aStat2,pritestfalseidname);
   1.299 +	test(r==KErrPermissionDenied);
   1.300 +
   1.301 +
   1.302 +	pritestfile=KPrivateFalseID;
   1.303 +	pritestfile[0]=(TText)('A' + gTheDriveNum);
   1.304 +	pritestfile1=pritestfile;
   1.305 +	pritestfile.Append(KFilePri2);
   1.306 +	pritestfile1.Append(KFilePri3);
   1.307 +	
   1.308 +	oldName=KOldFile;
   1.309 +	oldName[0]=(TText)gDriveToTest;
   1.310 +
   1.311 +	r=TheFs.GetShortName(pritestfile, shortfilename);
   1.312 +	test(r==KErrPermissionDenied || r==KErrNotSupported);
   1.313 +
   1.314 +	r=TheFs.GetLongName(pritestfile1, longfilename);
   1.315 +	test(r==KErrPermissionDenied || r==KErrNotSupported);
   1.316 +
   1.317 +	r=file1.Create(TheFs,oldName,EFileWrite);
   1.318 +	test(r==KErrNone || r==KErrAlreadyExists);
   1.319 +	file1.Close();
   1.320 +
   1.321 +	r=TheFs.Replace(oldName,pritestfile);
   1.322 +	test(r==KErrPermissionDenied);
   1.323 +	
   1.324 +	r=TheFs.Rename(pritestfile,pritestfile1);
   1.325 +	test(r==KErrPermissionDenied);
   1.326 +	
   1.327 +	r=TheFs.Entry(pritestfile1,entry);
   1.328 +	test(r==KErrPermissionDenied);
   1.329 +
   1.330 +	r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
   1.331 +	test(r==KErrPermissionDenied);
   1.332 +
   1.333 +	r=TheFs.Delete(pritestfile1);
   1.334 +	test(r==KErrPermissionDenied);
   1.335 +
   1.336 +	__UHEAP_MARKEND;
   1.337 +	}
   1.338 +
   1.339 +
   1.340 +
   1.341 +LOCAL_C void privateRFsTest()
   1.342 +//
   1.343 +//
   1.344 +//
   1.345 +	{
   1.346 +	__UHEAP_MARK;
   1.347 +	//private
   1.348 +	pritestname=KPrivatePath;
   1.349 +	pritestname[0]=(TText)('A' + gTheDriveNum);
   1.350 +	
   1.351 +	mkdirname.Zero();
   1.352 +	mkdirname.Append(pritestname);
   1.353 +	mkdirname.Append(KMkDirSub);
   1.354 +
   1.355 +	r=TheFs.MkDirAll(mkdirname);	
   1.356 +	test(r==KErrPermissionDenied);
   1.357 +
   1.358 +	r=TheFs.RmDir(mkdirname);	
   1.359 +	test(r==KErrPermissionDenied);
   1.360 +
   1.361 +	r=TheFs.SetSubst(pritestname,EDriveO);
   1.362 +	test(r==KErrPermissionDenied);
   1.363 +
   1.364 +	r=TheFs.RealName(_L("O:\\File.XXX"),realName);
   1.365 +	test(r==KErrNone);
   1.366 +
   1.367 +	r=TheFs.SetSessionPath(pritestname);
   1.368 +	test(r==KErrPermissionDenied);
   1.369 +
   1.370 +	TheFs.NotifyChange(ENotifyAll,aStat2,pritestname);
   1.371 +	test(r==KErrPermissionDenied);
   1.372 +
   1.373 +
   1.374 +	pritestfile=KPrivatePath;
   1.375 +	pritestfile[0]=(TText)('A' + gTheDriveNum);
   1.376 +	pritestfile1=pritestfile;
   1.377 +	pritestfile.Append(KFilePri2);
   1.378 +	pritestfile1.Append(KFilePri3);
   1.379 +	
   1.380 +	oldName=KOldFile;
   1.381 +	oldName[0]=(TText)gDriveToTest;
   1.382 +
   1.383 +	r=TheFs.GetShortName(pritestfile, shortfilename);
   1.384 +	test(r==KErrPermissionDenied || r==KErrNotSupported);
   1.385 +
   1.386 +	r=TheFs.GetLongName(pritestfile1, longfilename);
   1.387 +	test(r==KErrPermissionDenied || r==KErrNotSupported);
   1.388 +
   1.389 +	r=file1.Create(TheFs,oldName,EFileWrite);
   1.390 +	test(r==KErrNone || r==KErrAlreadyExists);
   1.391 +	file1.Close();
   1.392 +
   1.393 +	r=TheFs.Replace(oldName,pritestfile);
   1.394 +	test(r==KErrPermissionDenied);
   1.395 +	
   1.396 +	r=TheFs.Rename(pritestfile,pritestfile1);
   1.397 +	test(r==KErrPermissionDenied);
   1.398 +	
   1.399 +	r=TheFs.Entry(pritestfile1,entry);
   1.400 +	test(r==KErrPermissionDenied);
   1.401 +
   1.402 +	r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
   1.403 +	test(r==KErrPermissionDenied);
   1.404 +
   1.405 +	r=TheFs.Delete(pritestfile1);
   1.406 +	test(r==KErrPermissionDenied);
   1.407 +
   1.408 +	__UHEAP_MARKEND;
   1.409 +	}
   1.410 +
   1.411 +
   1.412 +LOCAL_C void privateSIDRFstest()
   1.413 +	{
   1.414 +	__UHEAP_MARK;
   1.415 +
   1.416 +	theprivatepath[0]=(TText)gDriveToTest;	
   1.417 +	test.Printf(_L("the Private Path = %S"),&theprivatepath);
   1.418 +
   1.419 +	mkdirname.Zero();
   1.420 +	mkdirname.Append(theprivatepath);
   1.421 +	mkdirname.Append(KMkDirSub);
   1.422 +	r=TheFs.MkDirAll(mkdirname);	
   1.423 +	test(r==KErrNone);
   1.424 +
   1.425 +	r=TheFs.RmDir(mkdirname);	
   1.426 +	test(r==KErrNone);
   1.427 +
   1.428 +	r=TheFs.SetSubst(theprivatepath,EDriveO);	
   1.429 +	test(r==KErrPermissionDenied || r==KErrGeneral); // Drive may already be substituted
   1.430 +
   1.431 +	r=TheFs.RealName(_L("O:\\File.XXX"),realName);
   1.432 +	test(r==KErrNone);
   1.433 +
   1.434 +	r=TheFs.SetSessionPath(theprivatepath);
   1.435 +	test(r==KErrNone);
   1.436 +
   1.437 +	TheFs.NotifyChange(ENotifyAll,aStat3,theprivatepath);
   1.438 +	test(aStat3==KRequestPending);
   1.439 +
   1.440 +	pritestfile=theprivatepath;
   1.441 +	pritestfile[0]=(TText)('A' + gTheDriveNum);
   1.442 +	pritestfile1=pritestfile;
   1.443 +	pritestfile.Append(KFilePri2);
   1.444 +	pritestfile1.Append(KFilePri3);
   1.445 +	
   1.446 +	oldName=KOldFile;
   1.447 +	oldName[0]=(TText)gDriveToTest;
   1.448 +
   1.449 +	r=TheFs.GetShortName(pritestfile, shortfilename);
   1.450 +	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
   1.451 +
   1.452 +	r=TheFs.GetLongName(pritestfile1, longfilename);
   1.453 +	test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported);
   1.454 +
   1.455 +	r=file1.Create(TheFs,oldName,EFileWrite);
   1.456 +	test(r==KErrNone || r==KErrAlreadyExists);
   1.457 +	file1.Close();
   1.458 +
   1.459 +	r=TheFs.Replace(oldName,pritestfile);
   1.460 +	test(r==KErrNone);
   1.461 +	
   1.462 +	r=TheFs.Rename(pritestfile,pritestfile1);
   1.463 +	test(r==KErrNone || r==KErrAlreadyExists);
   1.464 +	
   1.465 +	r=TheFs.Entry(pritestfile1,entry);
   1.466 +	test(r==KErrNone);
   1.467 +
   1.468 +	r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly);
   1.469 +	test(r==KErrNone);
   1.470 +
   1.471 +	r=TheFs.Delete(pritestfile1);
   1.472 +	test(r==KErrNone);
   1.473 +
   1.474 +	__UHEAP_MARKEND;
   1.475 +	}
   1.476 +
   1.477 +
   1.478 +LOCAL_C void systemRFiletest()
   1.479 +//
   1.480 +//RFile testing with session path set to //sys//
   1.481 +//
   1.482 +	{
   1.483 +	__UHEAP_MARK;
   1.484 +
   1.485 +	r=TheFs.SetSessionPath(systestname);
   1.486 +	test(r==KErrPermissionDenied);
   1.487 +
   1.488 +	r=file1.Temp(TheFs,systestname,fromTemp,EFileWrite);
   1.489 +	test(r==KErrNone);
   1.490 +	file1.Close();
   1.491 +
   1.492 +	TBuf<25> sysfilename;
   1.493 +	sysfilename.Append(systestname);
   1.494 +	sysfilename.Append(KFileSys);
   1.495 +
   1.496 +	r=file1.Create(TheFs,sysfilename,EFileWrite);
   1.497 +	test(r==KErrNone);
   1.498 +	file1.Close();
   1.499 +
   1.500 +	r=file1.Open(TheFs,sysfilename,EFileWrite);
   1.501 +	test(r==KErrNone);
   1.502 +	file1.Close();
   1.503 +	
   1.504 +	r=file1.Open(TheFs,sysfilename,EFileRead);
   1.505 +	test(r==KErrPermissionDenied);
   1.506 +	file1.Close();
   1.507 +	
   1.508 +	r=file1.Replace(TheFs,sysfilename,EFileWrite);
   1.509 +	test(r==KErrNone);
   1.510 +
   1.511 +	TBuf<25> sysfilename2;
   1.512 +	sysfilename2.Append(systestname);
   1.513 +	sysfilename2.Append(KFileSys3);
   1.514 +		
   1.515 +	r=file1.Rename(sysfilename2);
   1.516 +	test(r==KErrNone);
   1.517 +	file1.Close();
   1.518 +
   1.519 +    TFindFile finder(TheFs);
   1.520 +    CDir* dir = NULL;
   1.521 +    r=finder.FindWildByDir(KWildFile, KWildPath, dir);
   1.522 +	if (!(r==KErrPermissionDenied))
   1.523 +        test.Printf(_L("T_DCTCB: test find wildcards r = %d (expected KErrPermissionDenied)\n"), r);
   1.524 +	test(r==KErrPermissionDenied);
   1.525 +	delete dir;
   1.526 +
   1.527 +	__UHEAP_MARKEND;
   1.528 +	}
   1.529 +
   1.530 +LOCAL_C void resourceRFiletest()
   1.531 +//
   1.532 +//RFile testing with session path set to //resource//
   1.533 +//
   1.534 +	{
   1.535 +	__UHEAP_MARK;
   1.536 +
   1.537 +	r=TheFs.SetSessionPath(restestname);
   1.538 +	test(r==KErrNone);
   1.539 +
   1.540 +	r=file1.Temp(TheFs,restestname,fromTemp,EFileWrite);
   1.541 +	test(r==KErrNone);
   1.542 +	file1.Close();
   1.543 +
   1.544 +	r=file1.Create(TheFs,KFileRes,EFileWrite);
   1.545 +	test(r==KErrNone);
   1.546 +	file1.Close();
   1.547 +
   1.548 +	r=file1.Open(TheFs,KFileRes,EFileWrite|EFileShareExclusive );
   1.549 +	test(r==KErrNone);
   1.550 +	
   1.551 +	r=file1.Rename(KFileRes3);
   1.552 +	test(r==KErrNone);
   1.553 +	file1.Close();
   1.554 +
   1.555 +	r=file1.Open(TheFs,KFileRes3,EFileShareReadersOrWriters|EFileRead);
   1.556 +	test(r==KErrNone);
   1.557 +	file1.Close();
   1.558 +
   1.559 +	r=file1.Open(TheFs,KFileRes3,EFileShareReadersOrWriters|EFileWrite);
   1.560 +	test(r==KErrNone);
   1.561 +	file1.Close();
   1.562 +
   1.563 +	r=file1.Open(TheFs,KFileRes3,EFileShareReadersOnly);
   1.564 +	test(r==KErrNone);
   1.565 +
   1.566 +	r=file1.ChangeMode(EFileShareExclusive);
   1.567 +	test(r==KErrNone);
   1.568 +	file1.Close();
   1.569 +
   1.570 +	r=file1.Replace(TheFs,KFileRes,EFileWrite);
   1.571 +	test(r==KErrNone);
   1.572 +	file1.Close();	
   1.573 +	
   1.574 +	__UHEAP_MARKEND;
   1.575 +
   1.576 +	}
   1.577 +
   1.578 +
   1.579 +LOCAL_C void privatefalseIDRFiletest()
   1.580 +//
   1.581 +//RFile testing with session path set to //Private//false ID
   1.582 +//
   1.583 +	{
   1.584 +	__UHEAP_MARK;
   1.585 +
   1.586 +	r=TheFs.SetSessionPath(pritestfalseidname);
   1.587 +	test(r==KErrPermissionDenied);
   1.588 +
   1.589 +	r=file1.Temp(TheFs,pritestfalseidname,fromTemp,EFileWrite);
   1.590 +	test(r==KErrPermissionDenied);
   1.591 +	file1.Close();
   1.592 +
   1.593 +	// Since can't set session path create explicit path
   1.594 +	pritestfile=KPrivateFalseID;
   1.595 +	pritestfile[0]=(TText)('A' + gTheDriveNum);
   1.596 +	pritestfile.Append(KFilePri);
   1.597 +
   1.598 +	r=file1.Create(TheFs,pritestfile,EFileWrite);
   1.599 +	test(r==KErrPermissionDenied);
   1.600 +	file1.Close();
   1.601 +
   1.602 +	r=file1.Open(TheFs,pritestfile,EFileWrite);
   1.603 +	test(r==KErrPermissionDenied);
   1.604 +	file1.Close();
   1.605 +	
   1.606 +	r=file1.Open(TheFs,pritestfile,EFileRead);
   1.607 +	test(r==KErrPermissionDenied);
   1.608 +	file1.Close();
   1.609 +		
   1.610 +	r=file1.Replace(TheFs,pritestfile,EFileWrite);
   1.611 +	test(r==KErrPermissionDenied);
   1.612 +
   1.613 +	// File does not exist so can't rename it	
   1.614 +/*	r=file1.Rename(KFilePri3);
   1.615 +	test(r==KErrAlreadyExists || r==KErrNone);
   1.616 +	file1.Close();
   1.617 +*/	__UHEAP_MARKEND;
   1.618 +	}
   1.619 +
   1.620 +
   1.621 +LOCAL_C void privateRFiletest()
   1.622 +//
   1.623 +//RFile testing with session path set to //Private//
   1.624 +//
   1.625 +	{
   1.626 +	__UHEAP_MARK;
   1.627 +
   1.628 +	r=TheFs.SetSessionPath(pritestname);
   1.629 +	test(r==KErrPermissionDenied);
   1.630 +
   1.631 +	r=file1.Temp(TheFs,pritestname,fromTemp,EFileWrite);
   1.632 +	test(r==KErrPermissionDenied);
   1.633 +	file1.Close();
   1.634 +
   1.635 +	// Since can't set session path create explicit path
   1.636 +	pritestfile=KPrivatePath;
   1.637 +	pritestfile[0]=(TText)('A' + gTheDriveNum);
   1.638 +	pritestfile.Append(KFilePri);
   1.639 +
   1.640 +	r=file1.Create(TheFs,pritestfile,EFileWrite);
   1.641 +	test(r==KErrPermissionDenied);
   1.642 +	file1.Close();
   1.643 +
   1.644 +	r=file1.Open(TheFs,pritestfile,EFileWrite);
   1.645 +	test(r==KErrPermissionDenied);
   1.646 +	file1.Close();
   1.647 +	
   1.648 +	r=file1.Open(TheFs,pritestfile,EFileRead);
   1.649 +	test(r==KErrPermissionDenied);
   1.650 +	file1.Close();
   1.651 +	
   1.652 +	r=file1.Replace(TheFs,pritestfile,EFileWrite);
   1.653 +	test(r==KErrPermissionDenied);
   1.654 +
   1.655 +	// File does not exist so can't be renamed	
   1.656 +/*	r=file1.Rename(KFilePri3);
   1.657 +	test(r==KErrNone);
   1.658 +	file1.Close();
   1.659 +*/
   1.660 +	__UHEAP_MARKEND;
   1.661 +	}
   1.662 +
   1.663 +
   1.664 +LOCAL_C void privateSIDRFiletest()
   1.665 +//
   1.666 +//Rfile Testing with session path set to //Private//UID//
   1.667 +//
   1.668 +	{
   1.669 +	__UHEAP_MARK;
   1.670 +	r=TheFs.SetSessionToPrivate(gTheDriveNum);
   1.671 +	test(r==KErrNone);
   1.672 +	
   1.673 +	r=file1.Temp(TheFs,theprivatepath,fromTemp,EFileWrite);
   1.674 +	test(r==KErrNone);
   1.675 +	file1.Close();
   1.676 +
   1.677 +	r=file1.Create(TheFs,KFilePri,EFileWrite);
   1.678 +	test(r==KErrNone);
   1.679 +	file1.Close();
   1.680 +
   1.681 +	r=file1.Open(TheFs,KFilePri,EFileWrite);
   1.682 +	test(r==KErrNone);
   1.683 +	file1.Close();
   1.684 +	
   1.685 +	r=file1.Open(TheFs,KFilePri,EFileRead);
   1.686 +	test(r==KErrNone);
   1.687 +	file1.Close();
   1.688 +	
   1.689 +	r=file1.Replace(TheFs,KFilePri,EFileWrite);
   1.690 +	test(r==KErrNone);
   1.691 +	
   1.692 +	r=file1.Rename(KFilePri3);
   1.693 +	test(r==KErrNone);
   1.694 +	file1.Close();
   1.695 +	__UHEAP_MARKEND;
   1.696 +	}
   1.697 +
   1.698 +LOCAL_C void RDirtest()
   1.699 +//
   1.700 +//
   1.701 +//
   1.702 +	{
   1.703 +	__UHEAP_MARK;
   1.704 +
   1.705 +	//system
   1.706 +	CDir*	dirEntries;
   1.707 +	TBuf<30> dirNameBuf(KSystemPath);
   1.708 +	dirNameBuf[0]=(TText)gDriveToTest;
   1.709 +	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
   1.710 +	test(r==KErrPermissionDenied);
   1.711 +	dir.Close();
   1.712 +	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
   1.713 +	test(r==KErrPermissionDenied);
   1.714 +	dirNameBuf.Zero();
   1.715 +	delete dirEntries;
   1.716 +
   1.717 +	//Private
   1.718 +	dirNameBuf=KPrivatePath;
   1.719 +	dirNameBuf[0]=(TText)gDriveToTest;
   1.720 +	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
   1.721 +	test(r==KErrPermissionDenied);
   1.722 +	dir.Close();
   1.723 +	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
   1.724 +	test(r==KErrPermissionDenied);
   1.725 +	dirNameBuf.Zero();
   1.726 +	delete dirEntries;
   1.727 +
   1.728 +	//Private//falseID
   1.729 +	dirNameBuf=KPrivateFalseID;
   1.730 +	dirNameBuf[0]=(TText)gDriveToTest;
   1.731 +	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
   1.732 +	test(r==KErrPermissionDenied);
   1.733 +	dir.Close();
   1.734 +	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
   1.735 +	test(r==KErrPermissionDenied);
   1.736 +	dirNameBuf.Zero();
   1.737 +	delete dirEntries;
   1.738 +
   1.739 +	//Private/uid
   1.740 +	TheFs.PrivatePath(dirNameBuf);
   1.741 +	dirNameBuf.Insert(0,_L("?:"));
   1.742 +	dirNameBuf[0]=(TText)gDriveToTest;
   1.743 +	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
   1.744 +	test(r==KErrNone);
   1.745 +	dir.Close();
   1.746 +	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
   1.747 +	test(r==KErrNone);
   1.748 +	dirNameBuf.Zero();
   1.749 +	delete dirEntries;
   1.750 +	//Resource
   1.751 +	dirNameBuf=KResourcePath;
   1.752 +	dirNameBuf[0]=(TText)gDriveToTest;
   1.753 +	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
   1.754 +	test(r==KErrNone);
   1.755 +	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
   1.756 +	test(r==KErrNone);
   1.757 +	dir.Close();
   1.758 +	delete dirEntries;
   1.759 +	__UHEAP_MARKEND;
   1.760 +	}
   1.761 +
   1.762 +
   1.763 +LOCAL_C void TestTcbCaps()
   1.764 +//
   1.765 +//	Test with tcb capabilities
   1.766 +//
   1.767 +	{
   1.768 +	__UHEAP_MARK;
   1.769 +	r=TheFs.FileSystemName(fsname,gTheDriveNum);
   1.770 +	test(r==KErrNone);	
   1.771 +	r = DismountFileSystem(TheFs, fsname, gTheDriveNum);
   1.772 +	test(r==KErrPermissionDenied);
   1.773 +	r = MountFileSystem(TheFs, fsname, gTheDriveNum);
   1.774 +	test(r==KErrPermissionDenied);
   1.775 +	r=TheFs.SetDriveName(gTheDriveNum,KDriveName);
   1.776 +	test(r==KErrPermissionDenied);
   1.777 +#ifndef __WINS__
   1.778 + 	r=TheFs.SetVolumeLabel(KVolLable, gTheDriveNum);
   1.779 +	test(r==KErrPermissionDenied);
   1.780 +#endif
   1.781 +
   1.782 +	systemRFsTest();
   1.783 +	ResourceRFsTest();
   1.784 +	privateRFsTest();	
   1.785 +	privateSIDRFstest();
   1.786 +
   1.787 +	privatefalseIDRFsTest();	
   1.788 +
   1.789 +	systemRFiletest();
   1.790 +	resourceRFiletest();
   1.791 +	privateRFiletest();
   1.792 +	privateSIDRFiletest();
   1.793 +	privatefalseIDRFiletest();
   1.794 +
   1.795 +	//check notifier return values set in rfs testing
   1.796 +	User::WaitForRequest(aStat1);
   1.797 +	User::WaitForRequest(aStat2);
   1.798 +	User::WaitForRequest(aStat3);
   1.799 +	User::WaitForRequest(aStat4);
   1.800 +	test(aStat1==KErrPermissionDenied);
   1.801 +	test(aStat2==KErrPermissionDenied);
   1.802 +	test(aStat3==KErrNone);
   1.803 +	test(aStat4==KErrNone);
   1.804 +
   1.805 +	r=TheFs.SetSessionPath(systestname);
   1.806 +	test(r==KErrPermissionDenied);
   1.807 +	
   1.808 +//Test RRawDisk class
   1.809 +	r=rawdisk.Open(TheFs,gTheDriveNum);
   1.810 +	test(r==KErrNone);
   1.811 +    rawdisk.Close();
   1.812 +
   1.813 +	RDirtest();
   1.814 +
   1.815 +#ifdef __WINS__
   1.816 +	if (User::UpperCase(driveBuf[0]) != 'C')
   1.817 +#endif
   1.818 +		{
   1.819 +		//Test RFormat class
   1.820 +		r=format.Open(TheFs,driveBuf,EHighDensity,count);
   1.821 +		test(r==KErrPermissionDenied);
   1.822 +
   1.823 +		while(count)	
   1.824 +			{
   1.825 +			TInt r=format.Next(count);
   1.826 +			test(r==KErrNone);
   1.827 +			}
   1.828 +		format.Close();
   1.829 +		}
   1.830 +
   1.831 +	driveBuf[0]=(TText)gDriveToTest;
   1.832 +	r=TheFs.ScanDrive(driveBuf);
   1.833 +	test((r==KErrPermissionDenied)||(r==KErrNotSupported));
   1.834 +	r=TheFs.CheckDisk(driveBuf);
   1.835 +	test((r==KErrPermissionDenied)||(r==KErrNotSupported));
   1.836 +	__UHEAP_MARKEND;
   1.837 +	}
   1.838 +
   1.839 +LOCAL_C void TestCaps()
   1.840 +//
   1.841 +//	test format etc that require certain capabilities
   1.842 +//
   1.843 +	{
   1.844 +	__UHEAP_MARK;
   1.845 +#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
   1.846 +	const char myDiagMsg[] = "Capability Check Failure";
   1.847 +#endif //!__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
   1.848 +	r=RProcess().HasCapability(ECapabilityTCB, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg));
   1.849 +	test(r);
   1.850 +
   1.851 +	driveBuf[0]=(TText)gDriveToTest;
   1.852 +	r=TheFs.SessionPath(temp);
   1.853 +	test(r==KErrNone);
   1.854 +	test.Printf(_L("Session path: %S"),&temp);
   1.855 +	r=TheFs.CreatePrivatePath(gTheDriveNum);
   1.856 +	test(r==KErrNone || r== KErrAlreadyExists);
   1.857 +
   1.858 +	TBuf<18> tempPri;
   1.859 +	r=TheFs.PrivatePath(tempPri);
   1.860 +	test(r==KErrNone);
   1.861 +	theprivatepath = _L("?:");
   1.862 +	theprivatepath.Append(tempPri);
   1.863 +
   1.864 +	TestTcbCaps();
   1.865 +
   1.866 +	TFileName thesessionpath;
   1.867 +	r=TheFs.SetSessionToPrivate(gTheDriveNum);
   1.868 +	test(r==KErrNone);
   1.869 +	r=TheFs.SessionPath(thesessionpath);
   1.870 +	test(r==KErrNone);
   1.871 +	test(thesessionpath == theprivatepath);
   1.872 +	__UHEAP_MARKEND;
   1.873 +	}
   1.874 +
   1.875 +
   1.876 +TFileName dirName;
   1.877 +
   1.878 +LOCAL_C void ScanDir(const TDesC& aName, CDirScan::TScanDirection aDirection, TInt aError)
   1.879 +	{
   1.880 +	CDirScan* scanner = NULL;
   1.881 +	TRAP(r, scanner = CDirScan::NewL(TheFs));
   1.882 +	test(r == KErrNone && scanner);
   1.883 +
   1.884 +	TRAP(r, scanner->SetScanDataL(aName,KEntryAttDir,ESortByName|EAscending,aDirection));
   1.885 +	test(r == KErrNone);
   1.886 +	
   1.887 +	CDir *entryList=NULL;
   1.888 +	for (;;)
   1.889 +		{
   1.890 +		TRAP(r, scanner->NextL(entryList));
   1.891 +		test(r == aError);
   1.892 +		if (entryList==NULL)
   1.893 +			break;
   1.894 +		TInt count=entryList->Count();
   1.895 +		while (count--)
   1.896 +			{
   1.897 +			TEntry data=(*entryList)[count];
   1.898 +			TBuf<KMaxFileName> path=scanner->AbbreviatedPath();
   1.899 +			dirName = path;
   1.900 +			dirName.Append(data.iName);
   1.901 +			test.Printf(_L("    %S\n"),&dirName);
   1.902 +			
   1.903 +			}
   1.904 +		delete entryList;
   1.905 +		entryList=NULL;
   1.906 +		}
   1.907 +	delete scanner;
   1.908 +
   1.909 +	}
   1.910 +
   1.911 +/**
   1.912 +The following test, tests CFileMan and CDirScan API on folders private and sys
   1.913 +to confirm that any operation on these folders for any app with incorrect capability
   1.914 +returns KErrPermissionDenied. This test step was added as a result of DEF051428
   1.915 +("PlatSec: Incorrect errors returned by f32")
   1.916 +*/
   1.917 +LOCAL_C void TestCaging()
   1.918 +	{
   1.919 +	CFileMan* fMan=CFileMan::NewL(TheFs);
   1.920 +	TInt r;
   1.921 +	if(fMan!=NULL)
   1.922 +		{		
   1.923 +		
   1.924 +		// Checking the private path
   1.925 +		TBuf<30> privatepath;
   1.926 +		r=TheFs.PrivatePath(privatepath);
   1.927 +		test.Printf(_L("Private Path is=%S"),&privatepath);
   1.928 +		
   1.929 +		r = TheFs.MkDir(_L("\\Caged\\"));
   1.930 +		test(r==KErrNone || r==KErrAlreadyExists);
   1.931 +		
   1.932 +		CDir* entryCount=NULL;
   1.933 +		r=TheFs.GetDir(_L("\\*.*"),KEntryAttNormal,ESortNone,entryCount);
   1.934 +		test(r==KErrNone);
   1.935 +		TInt rootCount= entryCount->Count();
   1.936 +		
   1.937 +		delete entryCount;
   1.938 +		entryCount=NULL;
   1.939 +
   1.940 +
   1.941 +		//Testing Copy
   1.942 +		CDir* entryCount2=NULL;
   1.943 +		r=fMan->Copy(_L("\\sys\\"),_L("\\Caged\\"));
   1.944 +		test(r == KErrPermissionDenied);
   1.945 +		r=fMan->Copy(_L("\\*"),_L("\\Caged\\"));
   1.946 +		test(r == KErrNone);
   1.947 +		
   1.948 +		r=TheFs.GetDir(_L("\\Caged\\*.*"),KEntryAttNormal,ESortNone,entryCount2);
   1.949 +		test(r==KErrNone);
   1.950 +		TInt cagedCount= entryCount2->Count();
   1.951 +		
   1.952 +		test(cagedCount==rootCount);
   1.953 +		
   1.954 +		delete entryCount2;
   1.955 +		entryCount2=NULL;
   1.956 +	
   1.957 +		r=fMan->Copy(_L("\\private\\two\\moo"),_L("\\private\\two\\mew")); 
   1.958 +		test(r == KErrPermissionDenied);
   1.959 +	
   1.960 +		// Create a test file
   1.961 +		RFile testFile;
   1.962 +		r = testFile.Replace(TheFs, _L("\\capTest"),EFileWrite);
   1.963 +		test(r==KErrNone || r==KErrAlreadyExists);
   1.964 +		testFile.Close();
   1.965 +		
   1.966 +		TFileName name;
   1.967 +		name = privatepath;
   1.968 +		name.Append(_L("privateFile.tst"));
   1.969 +		RFile privateFile;
   1.970 +		r = privateFile.Replace(TheFs, name,EFileWrite);
   1.971 +		test(r==KErrNone || r==KErrAlreadyExists);
   1.972 +		privateFile.Close();
   1.973 +
   1.974 +	
   1.975 +		r=fMan->Copy(_L("\\capTest"),_L("\\private\\two\\moo")); 
   1.976 +		test(r == KErrPermissionDenied);
   1.977 +		r=fMan->Copy(_L("\\capTest"),_L("\\sys\\bin\\moo")); 
   1.978 +		test(r == KErrPathNotFound); 
   1.979 +		r=fMan->Copy(_L("\\sys\\bin\\capTest"),_L("\\sys\\bin\\moo")); 
   1.980 +		test(r == KErrPermissionDenied);
   1.981 +		r=fMan->Copy(_L("\\capTest"),_L("\\sys\\capTest")); 
   1.982 +		test(r == KErrNone || r==KErrAlreadyExists); 
   1.983 +		r=fMan->Copy(_L("\\sys\\*"),_L("\\"));
   1.984 +		test (r==KErrPermissionDenied);
   1.985 +		r=fMan->Copy(name,_L("\\sys\\"));
   1.986 +		test(r==KErrNone);
   1.987 +
   1.988 +		// Testing Move
   1.989 +		r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo"));
   1.990 +		test(r == KErrPermissionDenied);
   1.991 +		r=fMan->Move(_L("\\private\\two\\moo.."),_L("\\private\\one\\moo"));
   1.992 +		test(r == KErrPermissionDenied);
   1.993 +		r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo.."));
   1.994 +		test(r == KErrPermissionDenied);
   1.995 +		r=fMan->Move(name,_L("\\privateFile.tst"));
   1.996 +		test(r == KErrNone);
   1.997 +		r=fMan->Move(_L("\\privateFile.tst"),name);
   1.998 +		test(r == KErrNone);
   1.999 +
  1.1000 +
  1.1001 +		// Testing Attribs
  1.1002 +		r=fMan->Attribs(_L("\\private\\two\\moo"),KEntryAttReadOnly,0,TTime(0)); 
  1.1003 +		test(r == KErrPermissionDenied);
  1.1004 +		r=fMan->Attribs(_L("\\private\\moo"),KEntryAttReadOnly,0,TTime(0)); 
  1.1005 +		test(r == KErrPermissionDenied);
  1.1006 +		r=fMan->Attribs(name,KEntryAttReadOnly,0,TTime(0));
  1.1007 +		test(r == KErrNone);
  1.1008 +		r=fMan->Attribs(name,0,KEntryAttReadOnly,TTime(0));
  1.1009 +		test(r == KErrNone);
  1.1010 +
  1.1011 +		// Testing Move
  1.1012 +		r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo"));
  1.1013 +		test(r == KErrPermissionDenied);
  1.1014 +		r=fMan->Move(_L("\\private\\two\\moo.."),_L("\\private\\one\\moo"));
  1.1015 +		test(r == KErrPermissionDenied);
  1.1016 +		r=fMan->Move(_L("\\private\\two\\moo"),_L("\\private\\one\\moo.."));
  1.1017 +		test(r == KErrPermissionDenied);
  1.1018 +		r=fMan->Move(name,_L("\\privateFile.tst"));
  1.1019 +		test(r == KErrNone);
  1.1020 +		r=fMan->Move(_L("\\privateFile.tst"),name);
  1.1021 +		test(r == KErrNone);
  1.1022 +
  1.1023 +
  1.1024 +		// Testing RmDir
  1.1025 +		r=fMan->RmDir(_L("\\private\\"));
  1.1026 +		test(r == KErrPermissionDenied);
  1.1027 +		r=fMan->RmDir(_L("\\private\\two\\"));
  1.1028 +		test(r == KErrPermissionDenied);
  1.1029 +		r=fMan->RmDir(_L("\\private\\tw?\\"));
  1.1030 +		test(r == KErrPermissionDenied);
  1.1031 +		r=fMan->RmDir(_L("\\sys\\"));
  1.1032 +		test(r == KErrPermissionDenied);
  1.1033 +		
  1.1034 +		
  1.1035 +		// Testing Rename
  1.1036 +		r=fMan->Rename(_L("\\private\\two\\moo"),_L("\\private\\two\\mew")); 
  1.1037 +		test(r == KErrPermissionDenied);
  1.1038 +		
  1.1039 +		// Testing Delete
  1.1040 +		r=fMan->Delete(_L("\\private\\two\\test")); 
  1.1041 +		test(r == KErrPermissionDenied);
  1.1042 +		r=fMan->Delete(_L("\\private\\moo")); 
  1.1043 +		test(r == KErrPermissionDenied);
  1.1044 +		r=fMan->Delete(_L("\\sys\\")); 
  1.1045 +		test(r == KErrPermissionDenied);
  1.1046 +
  1.1047 +		//Something that actually exists in Private
  1.1048 +		r=fMan->Rename(name,_L("\\private\\00000001\\moo")); 
  1.1049 +		test(r == KErrNone);
  1.1050 +		r=fMan->Rename(_L("\\private\\00000001\\moo"),name); 
  1.1051 +		test(r == KErrNone);
  1.1052 +		r=fMan->Copy(name,_L("\\private\\00000001\\moo")); 
  1.1053 +		test(r == KErrNone);
  1.1054 +		r=fMan->Delete(_L("\\private\\00000001\\moo")); 
  1.1055 +		test(r == KErrNone);
  1.1056 +
  1.1057 +		// Clean up the test data
  1.1058 +		r=fMan->RmDir(_L("\\Caged\\")); 
  1.1059 +		test(r == KErrNone);
  1.1060 +		r=fMan->Delete(_L("\\capTest")); 
  1.1061 +		test(r == KErrNone);
  1.1062 +		r=fMan->Delete(name); 
  1.1063 +		test(r == KErrNone);
  1.1064 +		delete(fMan);
  1.1065 +		}
  1.1066 +	
  1.1067 +	// CDirScan tests
  1.1068 +	ScanDir(_L("\\"), CDirScan::EScanUpTree, KErrNone);
  1.1069 +	ScanDir(_L("\\"), CDirScan::EScanDownTree, KErrNone);
  1.1070 +	ScanDir(_L("\\private\\"), CDirScan::EScanDownTree, KErrPermissionDenied);
  1.1071 +	ScanDir(_L("\\private\\"), CDirScan::EScanUpTree, KErrPermissionDenied);
  1.1072 +	ScanDir(_L("\\sys\\"), CDirScan::EScanDownTree, KErrPermissionDenied);
  1.1073 +	ScanDir(_L("\\sys\\"), CDirScan::EScanUpTree, KErrPermissionDenied);
  1.1074 +	}
  1.1075 +
  1.1076 +void TestSystemDrive()
  1.1077 +	{
  1.1078 +	test.Next(_L("TestSystemDrive"));
  1.1079 +	TDriveNumber drive = RFs::GetSystemDrive();
  1.1080 +	test.Printf(_L("System Drive is %c:\n"), 'A'+drive);
  1.1081 +	for(TInt i=EDriveA; i<=EDriveZ; i++)
  1.1082 +		{
  1.1083 +		TDriveInfo info;
  1.1084 +		test(TheFs.Drive(info, i) == KErrNone);
  1.1085 +		if(info.iType==EMediaHardDisk || info.iType==EMediaFlash || info.iType==EMediaNANDFlash)
  1.1086 +			{
  1.1087 +			if(info.iDriveAtt & (KDriveAttLocal|KDriveAttInternal))
  1.1088 +				{
  1.1089 +				if(!(info.iDriveAtt & (KDriveAttRom|KDriveAttRedirected|KDriveAttSubsted|KDriveAttRemovable)))
  1.1090 +					{
  1.1091 +					test.Printf(_L("Setting %c:"), 'A'+i);
  1.1092 +					TInt ret = TheFs.SetSystemDrive((TDriveNumber)i);
  1.1093 +					test.Printf(_L("%d\n"), ret);
  1.1094 +					test(ret == KErrNone || ret == KErrAlreadyExists);
  1.1095 +					if(ret == KErrNone)
  1.1096 +						{
  1.1097 +						drive = (TDriveNumber)i;
  1.1098 +						test.Printf(_L("Re-setting %c:"), 'A'+i);
  1.1099 +						ret = TheFs.SetSystemDrive(drive);
  1.1100 +						test.Printf(_L("%d\n"), ret);
  1.1101 +						test(ret == KErrAlreadyExists);
  1.1102 +						}
  1.1103 +					}
  1.1104 +				}
  1.1105 +			}
  1.1106 +		}
  1.1107 +	TChar drvchar = RFs::GetSystemDriveChar();
  1.1108 +	test(drvchar == (TChar)('A' + drive)); 
  1.1109 +	test(drive == RFs::GetSystemDrive());
  1.1110 +	}
  1.1111 +	
  1.1112 +LOCAL_C void CleanupL()
  1.1113 +//
  1.1114 +// Clean up tests
  1.1115 +//
  1.1116 +	{
  1.1117 +	test.Next(_L("Delete test directory"));
  1.1118 +	CFileMan* fMan=CFileMan::NewL(TheFs);
  1.1119 +	TInt r=fMan->RmDir(gSessionPath);
  1.1120 +	test(r==KErrNone || KErrPathNotFound);
  1.1121 +	delete fMan;
  1.1122 +	}
  1.1123 +
  1.1124 +GLDEF_C void CallTestsL(/*TChar aDriveLetter*/)
  1.1125 +//
  1.1126 +// Do all tests
  1.1127 +//
  1.1128 +	{
  1.1129 +	if( !PlatSec::IsCapabilityEnforced(ECapabilityTCB))
  1.1130 +		{
  1.1131 +		test.Printf(_L("Capability ECapabilityTCB not enabled - leaving t_dctcb"));
  1.1132 +		test.Printf(_L("\n")); // Prevent overwrite by next print
  1.1133 +		return;
  1.1134 +		}
  1.1135 +
  1.1136 +	TurnAllocFailureOff();
  1.1137 +	TheFs.CharToDrive(gDriveToTest,gTheDriveNum);
  1.1138 +	
  1.1139 +	TBuf<30> sesspath;
  1.1140 +	sesspath=_L("?:\\");
  1.1141 +	sesspath[0] = (TText)gDriveToTest;
  1.1142 +
  1.1143 +	TInt r= TheFs.SetSessionPath(sesspath);
  1.1144 +	test(r==KErrNone);
  1.1145 +
  1.1146 +	//cleanup from previous run of this test
  1.1147 +	TBuf<20> delDir;
  1.1148 +	CFileMan* fMan=CFileMan::NewL(TheFs);
  1.1149 +	delDir=KResourcePath;
  1.1150 +	delDir[0]=(TText)gDriveToTest;
  1.1151 +	r=fMan->RmDir(delDir);
  1.1152 +	test(r==KErrNone || KErrNotFound);
  1.1153 +	delDir=KSystemPath;
  1.1154 +	delDir[0]=(TText)gDriveToTest;
  1.1155 +	r=fMan->RmDir(delDir);
  1.1156 +	test(r==KErrNone || KErrNotFound);
  1.1157 +	delDir=KPrivatePath;
  1.1158 +	delDir[0]=(TText)gDriveToTest;
  1.1159 +	r=fMan->RmDir(delDir);
  1.1160 +	test(r==KErrNone || KErrNotFound);
  1.1161 +	delete fMan;
  1.1162 +
  1.1163 +	//check double mode ie that Defpath still works	
  1.1164 +	RFs fs1;
  1.1165 +	RFs fs2;
  1.1166 +	
  1.1167 +	r=fs1.Connect();
  1.1168 +	test(r==KErrNone);
  1.1169 +	r=fs1.SessionPath(sesspath);
  1.1170 +	test(r==KErrNone);
  1.1171 +	test.Printf(_L("session1 Path=%S"),&sesspath);
  1.1172 +
  1.1173 +	TBuf<30> privatepath;
  1.1174 +	r=fs1.SetSessionToPrivate(gTheDriveNum);
  1.1175 +	test(r==KErrNone);
  1.1176 +	r=fs1.PrivatePath(privatepath);
  1.1177 +	test(r==KErrNone);
  1.1178 +	r=privatepath.Compare(KExpectedPrivatePath());
  1.1179 +	test(r==0);
  1.1180 +	r=fs1.SessionPath(sesspath);
  1.1181 +	test(r==KErrNone);
  1.1182 +	r=privatepath.Compare(sesspath.Mid(KPathPosition));
  1.1183 +	test(r==0);
  1.1184 +	r=fs1.CreatePrivatePath(gTheDriveNum);
  1.1185 +	test(r==KErrNone);
  1.1186 +	fs1.Close();
  1.1187 +
  1.1188 +	r=fs2.Connect();
  1.1189 +	test(r==KErrNone);
  1.1190 +	r=fs2.SessionPath(sesspath);
  1.1191 +	test(r==KErrNone);
  1.1192 +	test.Printf(_L("session2 Path=%S"),&sesspath);
  1.1193 +	fs2.Close();
  1.1194 +
  1.1195 +	TestCaps();
  1.1196 +	TestCaging();
  1.1197 +	TestPathCheck();
  1.1198 +	TestSystemDrive();
  1.1199 +
  1.1200 +	test.Printf(_L("No of files open=%d"), TheFs.ResourceCount());
  1.1201 +
  1.1202 +	CleanupL();
  1.1203 +	}