sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32test\server\t_dcdiskadminallfiles.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "t_server.h" sl@0: sl@0: GLDEF_D RTest test(_L("T_DCDISKADMINALLFILES")); sl@0: GLDEF_D TTime gTimeNow; sl@0: LOCAL_D TInt gTheDriveNum; sl@0: sl@0: sl@0: const TInt KPathPosition = 2; sl@0: _LIT(KExpectedPrivatePath, "\\Private\\00000001\\"); sl@0: _LIT(KResourcePath, "?:\\Resource\\"); sl@0: _LIT(KSystemPath, "?:\\Sys\\"); sl@0: _LIT(KPrivatePath, "?:\\Private\\"); sl@0: _LIT(KPrivateFalseID, "?:\\Private\\FFFFFFFF\\"); sl@0: _LIT(KDriveName, "Billy"); sl@0: _LIT(KVolLable, "Benny"); sl@0: _LIT(KFileSys, "systemfile.txt"); sl@0: _LIT(KFileSys3, "sysfile.rna"); sl@0: _LIT(KFilePri, "privatefile.txt"); sl@0: _LIT(KFilePri2, "privatefile.tmp"); sl@0: _LIT(KFilePri3, "prifile.rna"); sl@0: _LIT(KFileRes, "resourcefile.txt"); sl@0: _LIT(KFileRes3, "resfile.rna"); sl@0: _LIT(KMkDirSub,"Subdir\\"); sl@0: _LIT(KOldFile,"?:\\Anyold.txt"); sl@0: sl@0: #ifndef __WINS__ sl@0: _LIT(KWildPath, "Z:\\SYSTEM\\"); // Until Loader is modified to use /Sys/ sl@0: #else sl@0: _LIT(KWildPath, "Z:\\SYS\\"); sl@0: #endif sl@0: _LIT(KWildFile, "*"); sl@0: sl@0: TCapability TheCaps; sl@0: TBuf<4> driveBuf=_L("?:\\"); sl@0: RFormat format; sl@0: TInt count; sl@0: RRawDisk rawdisk; sl@0: RFile file1; sl@0: RFile file2; sl@0: RDir dir; sl@0: sl@0: TInt r; sl@0: TBuf<40> fsname; sl@0: TBuf<40> systestname; sl@0: TBuf<40> pritestname; sl@0: TBuf<40> restestname; sl@0: TBuf<40> theprivatepath; sl@0: TBuf<40> pritestfalseidname; sl@0: TBuf<40> mkdirname; sl@0: TFileName fromTemp; sl@0: sl@0: TBuf<25> sysfilename; sl@0: TBuf<30> realName; sl@0: TBuf<40> shortfilename; sl@0: TBuf<40> longfilename; sl@0: sl@0: TRequestStatus aStat1; sl@0: TRequestStatus aStat2; sl@0: TRequestStatus aStat3; sl@0: TRequestStatus aStat4; sl@0: sl@0: TVolumeInfo aVolInfo; sl@0: // TDriveInfo adriveInfo; sl@0: sl@0: TBuf<40> systestfile; sl@0: TBuf<40> pritestfile; sl@0: TBuf<40> restestfile; sl@0: TBuf<40> systestfile1; sl@0: TBuf<40> pritestfile1; sl@0: TBuf<40> restestfile1; sl@0: sl@0: TTime testtime; sl@0: TBuf<20> oldName; sl@0: sl@0: TBuf<25> temp; sl@0: sl@0: TEntry entry; sl@0: sl@0: sl@0: LOCAL_C void systemRFsTest() sl@0: // sl@0: // RFs test on system Directory sl@0: // sl@0: { sl@0: systestname=KSystemPath; sl@0: systestname[0]=(TText)('A' + gTheDriveNum); sl@0: sl@0: mkdirname.Zero(); sl@0: mkdirname.Append(systestname); sl@0: mkdirname.Append(KMkDirSub); sl@0: r=TheFs.MkDirAll(mkdirname); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: TheFs.RmDir(mkdirname); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: r=TheFs.SetSubst(systestname,EDriveO); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: r=TheFs.SetSessionPath(systestname); sl@0: test(r==KErrNone); sl@0: sl@0: TheFs.NotifyChange(ENotifyAll,aStat1,systestname); sl@0: test(aStat1==KRequestPending); sl@0: sl@0: systestfile=KSystemPath; sl@0: systestfile[0]=(TText)('A' + gTheDriveNum); sl@0: systestfile1=systestfile; sl@0: systestfile.Append(KFileSys); sl@0: systestfile1.Append(KFileSys3); sl@0: sl@0: oldName=KOldFile; sl@0: oldName[0]=(TText)gDriveToTest; sl@0: sl@0: r=TheFs.GetShortName(systestfile, shortfilename); sl@0: test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported); sl@0: sl@0: r=TheFs.GetLongName(systestfile1, longfilename); sl@0: test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported); sl@0: sl@0: r=file1.Create(TheFs,oldName,EFileWrite); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: file1.Close(); sl@0: sl@0: r=TheFs.Replace(oldName,systestfile); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: r=TheFs.Rename(systestfile,systestfile1); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: r=TheFs.Entry(systestfile1,entry); sl@0: test(r==KErrNone || KErrNotFound); sl@0: sl@0: r=TheFs.SetEntry(systestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: r=TheFs.Delete(systestfile1); sl@0: test(r==KErrPermissionDenied); sl@0: } sl@0: sl@0: LOCAL_C void ResourceRFsTest() sl@0: // sl@0: // sl@0: // sl@0: { sl@0: restestname=KResourcePath; sl@0: restestname[0]=(TText)('A' + gTheDriveNum); sl@0: sl@0: mkdirname.Zero(); sl@0: mkdirname.Append(restestname); sl@0: mkdirname.Append(KMkDirSub); sl@0: r=TheFs.MkDirAll(mkdirname); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: TheFs.RmDir(mkdirname); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: // Change due to defect DEF099546 fix sl@0: // TCB capability is required for following operation. sl@0: r=TheFs.SetSubst(restestname,EDriveO); sl@0: //test(r==KErrNone); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: // SetSubst will fail. sl@0: //r=TheFs.RealName(_L("O:\\File.XXX"),realName); sl@0: //test(r==KErrNone); sl@0: sl@0: //r=TheFs.SetSubst(_L(""),EDriveO); sl@0: //test(r==KErrNone); sl@0: sl@0: r=TheFs.SetSessionPath(restestname); sl@0: test(r==KErrNone); sl@0: sl@0: TheFs.NotifyChange(ENotifyAll,aStat4,restestname); sl@0: test(aStat4==KRequestPending); sl@0: sl@0: restestfile=KResourcePath; sl@0: restestfile[0]=(TText)('A' + gTheDriveNum); sl@0: restestfile1=restestfile; sl@0: restestfile.Append(KFileRes); sl@0: restestfile1.Append(KFileRes3); sl@0: sl@0: oldName=KOldFile; sl@0: oldName[0]=(TText)gDriveToTest; sl@0: sl@0: r=TheFs.GetShortName(restestfile, shortfilename); sl@0: test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported); sl@0: sl@0: r=TheFs.GetLongName(restestfile1, longfilename); sl@0: test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported); sl@0: sl@0: r=file1.Create(TheFs,oldName,EFileWrite); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: file1.Close(); sl@0: sl@0: r=TheFs.Replace(oldName,restestfile); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: r=TheFs.Rename(restestfile,restestfile1); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: r=TheFs.Entry(restestfile1,entry); sl@0: test(r==KErrNone || r==KErrPathNotFound || r==KErrNotFound); sl@0: sl@0: r=TheFs.SetEntry(restestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: r=TheFs.Delete(restestfile1); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: } sl@0: sl@0: sl@0: LOCAL_C void privatefalseIDRFsTest() sl@0: // sl@0: // sl@0: // sl@0: { sl@0: pritestfalseidname=KPrivateFalseID; sl@0: pritestfalseidname[0]=(TText)('A' + gTheDriveNum); sl@0: sl@0: mkdirname.Zero(); sl@0: mkdirname.Append(pritestfalseidname); sl@0: mkdirname.Append(KMkDirSub); sl@0: sl@0: r=TheFs.MkDirAll(mkdirname); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.RmDir(mkdirname); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.SetSubst(pritestfalseidname,EDriveO); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.RealName(_L("O:\\File.XXX"),realName); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.SetSubst(_L(""),EDriveO); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.SetSessionPath(pritestfalseidname); sl@0: test(r==KErrNone); sl@0: sl@0: TheFs.NotifyChange(ENotifyAll,aStat2,pritestfalseidname); sl@0: test(aStat2==KRequestPending); sl@0: sl@0: sl@0: pritestfile=KPrivateFalseID; sl@0: pritestfile[0]=(TText)('A' + gTheDriveNum); sl@0: pritestfile1=pritestfile; sl@0: pritestfile.Append(KFilePri2); sl@0: pritestfile1.Append(KFilePri3); sl@0: sl@0: oldName=KOldFile; sl@0: oldName[0]=(TText)gDriveToTest; sl@0: sl@0: r=TheFs.GetShortName(pritestfile, shortfilename); sl@0: test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported); sl@0: sl@0: r=TheFs.GetLongName(pritestfile1, longfilename); sl@0: test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported); sl@0: sl@0: r=file1.Create(TheFs,oldName,EFileWrite); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: file1.Close(); sl@0: sl@0: r=TheFs.Replace(oldName,pritestfile); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.Rename(pritestfile,pritestfile1); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.Entry(pritestfile1,entry); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.Delete(pritestfile1); sl@0: test(r==KErrNone); sl@0: sl@0: } sl@0: sl@0: sl@0: LOCAL_C void privateRFsTest() sl@0: // sl@0: // sl@0: // sl@0: { sl@0: //private sl@0: pritestname=KPrivatePath; sl@0: pritestname[0]=(TText)('A' + gTheDriveNum); sl@0: sl@0: mkdirname.Zero(); sl@0: mkdirname.Append(pritestname); sl@0: mkdirname.Append(KMkDirSub); sl@0: sl@0: r=TheFs.MkDirAll(mkdirname); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.RmDir(mkdirname); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.SetSubst(pritestname,EDriveO); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.RealName(_L("O:\\File.XXX"),realName); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.SetSubst(_L(""),EDriveO); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.SetSessionPath(pritestname); sl@0: test(r==KErrNone); sl@0: sl@0: TheFs.NotifyChange(ENotifyAll,aStat2,pritestname); sl@0: test(aStat2==KRequestPending); sl@0: sl@0: sl@0: pritestfile=KPrivatePath; sl@0: pritestfile[0]=(TText)('A' + gTheDriveNum); sl@0: pritestfile1=pritestfile; sl@0: pritestfile.Append(KFilePri2); sl@0: pritestfile1.Append(KFilePri3); sl@0: sl@0: oldName=KOldFile; sl@0: oldName[0]=(TText)gDriveToTest; sl@0: sl@0: r=TheFs.GetShortName(pritestfile, shortfilename); sl@0: test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported); sl@0: sl@0: r=TheFs.GetLongName(pritestfile1, longfilename); sl@0: test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported); sl@0: sl@0: r=file1.Create(TheFs,oldName,EFileWrite); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: file1.Close(); sl@0: sl@0: r=TheFs.Replace(oldName,pritestfile); sl@0: test(r==KErrNone || r==KErrNotFound); sl@0: sl@0: r=TheFs.Rename(pritestfile,pritestfile1); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.Entry(pritestfile1,entry); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.Delete(pritestfile1); sl@0: test(r==KErrNone); sl@0: sl@0: } sl@0: sl@0: sl@0: LOCAL_C void privateSIDRFstest() sl@0: { sl@0: theprivatepath[0]=(TText)gDriveToTest; sl@0: test.Printf(_L("the Private Path = %S"),&theprivatepath); sl@0: sl@0: mkdirname.Zero(); sl@0: mkdirname.Append(theprivatepath); sl@0: mkdirname.Append(KMkDirSub); sl@0: r=TheFs.MkDirAll(mkdirname); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.RmDir(mkdirname); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.SetSubst(theprivatepath,EDriveO); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.RealName(_L("O:\\File.XXX"),realName); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.SetSubst(_L(""),EDriveO); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.SetSessionPath(theprivatepath); sl@0: test(r==KErrNone); sl@0: sl@0: TheFs.NotifyChange(ENotifyAll,aStat3,theprivatepath); sl@0: test(aStat3==KRequestPending); sl@0: sl@0: pritestfile=theprivatepath; sl@0: pritestfile[0]=(TText)('A' + gTheDriveNum); sl@0: pritestfile1=pritestfile; sl@0: pritestfile.Append(KFilePri2); sl@0: pritestfile1.Append(KFilePri3); sl@0: sl@0: oldName=KOldFile; sl@0: oldName[0]=(TText)gDriveToTest; sl@0: sl@0: r=TheFs.GetShortName(pritestfile, shortfilename); sl@0: test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported); sl@0: sl@0: r=TheFs.GetLongName(pritestfile1, longfilename); sl@0: test(r==KErrNone || r==KErrNotFound || r==KErrNotSupported); sl@0: sl@0: r=file1.Create(TheFs,oldName,EFileWrite); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: file1.Close(); sl@0: sl@0: r=TheFs.Replace(oldName,pritestfile); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.Rename(pritestfile,pritestfile1); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: sl@0: r=TheFs.Entry(pritestfile1,entry); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.SetEntry(pritestfile1,testtime,KEntryAttNormal,KEntryAttReadOnly); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.Delete(pritestfile1); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: sl@0: LOCAL_C void systemRFiletest() sl@0: // sl@0: //RFile testing with session path set to //system// sl@0: // sl@0: { sl@0: sl@0: r=TheFs.SetSessionPath(systestname); sl@0: test(r==KErrNone); sl@0: sl@0: r=file1.Temp(TheFs,systestname,fromTemp,EFileWrite); sl@0: test(r==KErrPermissionDenied); sl@0: file1.Close(); sl@0: sl@0: systestfile=systestname; sl@0: systestfile.Append(KFileSys); sl@0: r=file1.Create(TheFs,systestfile,EFileWrite); sl@0: test(r==KErrPermissionDenied); sl@0: file1.Close(); sl@0: sl@0: r=file1.Open(TheFs,systestfile,EFileWrite); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: r=file1.Open(TheFs,systestfile,EFileRead); sl@0: test(r==KErrNone|| r==KErrNotFound); sl@0: sl@0: r=file1.Replace(TheFs,systestfile,EFileWrite); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: TFindFile finder(TheFs); sl@0: CDir* dir = NULL; sl@0: r=finder.FindWildByDir(KWildFile, KWildPath, dir); sl@0: if (!(r==KErrNone)) sl@0: test.Printf(_L("T_DCDISKADMINALLFILES: test find wildcards r = %d (expected KErrNone)\n"), r); sl@0: test(r==KErrNone); sl@0: delete dir; sl@0: } sl@0: sl@0: LOCAL_C void resourceRFiletest() sl@0: // sl@0: //RFile testing with session path set to //resource// sl@0: // sl@0: { sl@0: r=TheFs.SetSessionPath(restestname); sl@0: test(r==KErrNone); sl@0: sl@0: r=file1.Temp(TheFs,restestname,fromTemp,EFileWrite); sl@0: test(r==KErrPermissionDenied); sl@0: file1.Close(); sl@0: sl@0: r=file1.Create(TheFs,KFileRes,EFileWrite); sl@0: test(r==KErrPermissionDenied); sl@0: file1.Close(); sl@0: sl@0: r=file1.Open(TheFs,KFileRes,EFileWrite|EFileShareExclusive ); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: r=file1.Open(TheFs,KFileRes,EFileShareReadersOnly); sl@0: test(r==KErrNone || KErrPathNotFound || KErrNotFound); sl@0: file1.Close(); sl@0: sl@0: r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileRead); sl@0: test(r==KErrNone || KErrPathNotFound || KErrNotFound); sl@0: file1.Close(); sl@0: sl@0: r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileWrite); sl@0: test(r==KErrPermissionDenied); sl@0: file1.Close(); sl@0: sl@0: r=file1.Replace(TheFs,KFileRes3,EFileWrite); sl@0: test(r==KErrPermissionDenied); sl@0: file1.Close(); sl@0: } sl@0: sl@0: sl@0: LOCAL_C void privatefalseIDRFiletest() sl@0: // sl@0: //RFile testing with session path set to //Private//false ID sl@0: // sl@0: { sl@0: r=TheFs.SetSessionPath(pritestfalseidname); sl@0: test(r==KErrNone); sl@0: sl@0: r=file1.Temp(TheFs,pritestfalseidname,fromTemp,EFileWrite); sl@0: test(r==KErrNone); sl@0: file1.Close(); sl@0: sl@0: r=file1.Create(TheFs,KFilePri,EFileWrite); sl@0: test(r==KErrNone); sl@0: file1.Close(); sl@0: sl@0: r=file1.Open(TheFs,KFilePri,EFileWrite); sl@0: test(r==KErrNone); sl@0: file1.Close(); sl@0: sl@0: r=file1.Open(TheFs,KFilePri,EFileRead); sl@0: test(r==KErrNone); sl@0: file1.Close(); sl@0: sl@0: r=file1.Replace(TheFs,KFilePri,EFileWrite); sl@0: test(r==KErrNone); sl@0: sl@0: r=file1.Rename(KFilePri3); sl@0: test(r==KErrNone); sl@0: file1.Close(); sl@0: } sl@0: sl@0: sl@0: LOCAL_C void privateRFiletest() sl@0: // sl@0: //RFile testing with session path set to //Private// sl@0: // sl@0: { sl@0: r=TheFs.SetSessionPath(pritestname); sl@0: test(r==KErrNone); sl@0: sl@0: r=file1.Temp(TheFs,pritestname,fromTemp,EFileWrite); sl@0: test(r==KErrNone); sl@0: file1.Close(); sl@0: sl@0: r=file1.Create(TheFs,KFilePri,EFileWrite); sl@0: test(r==KErrNone); sl@0: file1.Close(); sl@0: sl@0: r=file1.Open(TheFs,KFilePri,EFileWrite); sl@0: test(r==KErrNone); sl@0: file1.Close(); sl@0: sl@0: r=file1.Open(TheFs,KFilePri,EFileRead); sl@0: test(r==KErrNone); sl@0: file1.Close(); sl@0: sl@0: r=file1.Replace(TheFs,KFilePri,EFileWrite); sl@0: test(r==KErrNone); sl@0: sl@0: r=file1.Rename(KFilePri3); sl@0: test(r==KErrNone); sl@0: file1.Close(); sl@0: } sl@0: sl@0: sl@0: LOCAL_C void privateSIDRFiletest() sl@0: // sl@0: //Rfile Testing with session path set to //Private//UID// sl@0: // sl@0: { sl@0: r=TheFs.SetSessionToPrivate(gTheDriveNum); sl@0: test(r==KErrNone); sl@0: sl@0: r=file1.Temp(TheFs,theprivatepath,fromTemp,EFileWrite); sl@0: test(r==KErrNone); sl@0: file1.Close(); sl@0: sl@0: r=file1.Create(TheFs,KFilePri,EFileWrite); sl@0: test(r==KErrNone); sl@0: file1.Close(); sl@0: sl@0: r=file1.Open(TheFs,KFilePri,EFileWrite); sl@0: test(r==KErrNone); sl@0: file1.Close(); sl@0: sl@0: r=file1.Open(TheFs,KFilePri,EFileRead); sl@0: test(r==KErrNone); sl@0: file1.Close(); sl@0: sl@0: sl@0: r=file1.Replace(TheFs,KFilePri,EFileWrite); sl@0: test(r==KErrNone); sl@0: sl@0: r=file1.Rename(KFilePri3); sl@0: test(r==KErrNone); sl@0: file1.Close(); sl@0: } sl@0: sl@0: LOCAL_C void RDirtest() sl@0: // sl@0: // sl@0: // sl@0: { sl@0: sl@0: //system sl@0: CDir* dirEntries; sl@0: TBuf<30> dirNameBuf(KSystemPath); sl@0: dirNameBuf[0]=(TText)gDriveToTest; sl@0: r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); sl@0: test(r==KErrNone || r==KErrPathNotFound || r==KErrNotFound); sl@0: dir.Close(); sl@0: if(r==KErrNone) sl@0: { sl@0: r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); sl@0: test(r==KErrNone); sl@0: delete dirEntries; sl@0: } sl@0: dirNameBuf.Zero(); sl@0: //Private//falseID sl@0: dirNameBuf=KPrivateFalseID; sl@0: dirNameBuf[0]=(TText)gDriveToTest; sl@0: r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); sl@0: test(r==KErrNone); sl@0: dir.Close(); sl@0: r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); sl@0: test(r==KErrNone); sl@0: dirNameBuf.Zero(); sl@0: delete dirEntries; sl@0: //Private sl@0: dirNameBuf=KPrivatePath; sl@0: dirNameBuf[0]=(TText)gDriveToTest; sl@0: r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); sl@0: test(r==KErrNone); sl@0: dir.Close(); sl@0: r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); sl@0: test(r==KErrNone); sl@0: dirNameBuf.Zero(); sl@0: delete dirEntries; sl@0: //Private/uid sl@0: TheFs.PrivatePath(dirNameBuf); sl@0: dirNameBuf.Insert(0,_L("?:")); sl@0: dirNameBuf[0]=(TText)gDriveToTest; sl@0: r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); sl@0: test(r==KErrNone); sl@0: dir.Close(); sl@0: r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); sl@0: test(r==KErrNone); sl@0: dirNameBuf.Zero(); sl@0: delete dirEntries; sl@0: //Resource sl@0: dirNameBuf=KResourcePath; sl@0: dirNameBuf[0]=(TText)gDriveToTest; sl@0: r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal); sl@0: test(r==KErrNone || r==KErrPathNotFound); sl@0: if(r==KErrNone) sl@0: { sl@0: r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries); sl@0: test(r==KErrNone); sl@0: dir.Close(); sl@0: delete dirEntries; sl@0: } sl@0: } sl@0: sl@0: sl@0: LOCAL_C void TestDiskAdminAllfiles() sl@0: // sl@0: // Test with root capabilities sl@0: // sl@0: { sl@0: r=TheFs.FileSystemName(fsname,gTheDriveNum); sl@0: test(r==KErrNone); sl@0: r = DismountFileSystem(TheFs, fsname, gTheDriveNum); sl@0: test(r==KErrNone); sl@0: // r=TheFs.RemoveFileSystem(fsname); //can not test due to bug else where fix exists sl@0: // test(r==KErrNone); sl@0: // r=TheFs.AddFileSystem(fsname); sl@0: // test(r==KErrNone); sl@0: r = MountFileSystem(TheFs, fsname, gTheDriveNum); sl@0: test(r==KErrNone); sl@0: r=TheFs.SetDriveName(gTheDriveNum,KDriveName); sl@0: test(r==KErrNone); sl@0: #ifndef __WINS__ sl@0: r=TheFs.SetVolumeLabel(KVolLable, gTheDriveNum); sl@0: test(r==KErrNone); sl@0: #endif sl@0: sl@0: systemRFsTest(); sl@0: ResourceRFsTest(); sl@0: privateRFsTest(); sl@0: privateSIDRFstest(); sl@0: privatefalseIDRFsTest(); sl@0: sl@0: systemRFiletest(); sl@0: resourceRFiletest(); sl@0: privateRFiletest(); sl@0: privateSIDRFiletest(); sl@0: privatefalseIDRFiletest(); sl@0: sl@0: //check notifier return values set in rfs testing sl@0: //User::WaitForRequest(aStat1); sl@0: User::WaitForRequest(aStat2); sl@0: User::WaitForRequest(aStat3); sl@0: //User::WaitForRequest(aStat4); sl@0: test(aStat2==KErrNone); sl@0: test(aStat3==KErrNone); sl@0: sl@0: test(aStat1 == KRequestPending); sl@0: TheFs.NotifyChangeCancel(aStat1); sl@0: test(aStat1==KErrCancel); sl@0: sl@0: test(aStat4 == KRequestPending); sl@0: TheFs.NotifyChangeCancel(aStat4); sl@0: test(aStat4==KErrCancel); sl@0: sl@0: r=TheFs.SetSessionPath(systestname); sl@0: test(r==KErrNone); sl@0: sl@0: //Test RRawDisk class sl@0: r=rawdisk.Open(TheFs,gTheDriveNum); sl@0: test(r==KErrPermissionDenied); sl@0: rawdisk.Close(); sl@0: sl@0: RDirtest(); sl@0: sl@0: #ifdef __WINS__ sl@0: if (User::UpperCase(driveBuf[0]) != 'C') sl@0: #endif sl@0: { sl@0: //Test RFormat class sl@0: r=format.Open(TheFs,driveBuf,EHighDensity,count); sl@0: test(r==KErrNone); sl@0: while(count) sl@0: { sl@0: TInt r=format.Next(count); sl@0: test(r==KErrNone); sl@0: } sl@0: format.Close(); sl@0: } sl@0: sl@0: driveBuf[0]=(TText)gDriveToTest; sl@0: r=TheFs.ScanDrive(driveBuf); sl@0: test(r==KErrNone || r==KErrNotSupported || KErrInUse); sl@0: r=TheFs.CheckDisk(driveBuf); sl@0: test(r==KErrNone || r==KErrNotSupported || KErrInUse); sl@0: } sl@0: sl@0: LOCAL_C void TestCaps() sl@0: // sl@0: // test format etc that require certain capabilities sl@0: // sl@0: { sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ sl@0: const char myDiagMsg[] = "Capability Check Failure"; sl@0: #endif //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ sl@0: r=RProcess().HasCapability(ECapabilityAllFiles, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg)); sl@0: test(r); sl@0: r=RProcess().HasCapability(ECapabilityDiskAdmin, __PLATSEC_DIAGNOSTIC_STRING(myDiagMsg)); sl@0: test(r); sl@0: sl@0: driveBuf[0]=(TText)gDriveToTest; sl@0: r=TheFs.SessionPath(temp); sl@0: test(r==KErrNone); sl@0: sl@0: test.Printf(_L("Session path: %S"),&temp); sl@0: sl@0: r=TheFs.CreatePrivatePath(gTheDriveNum); sl@0: test(r==KErrNone || r== KErrAlreadyExists); sl@0: sl@0: TBuf<18> tempPri; sl@0: r=TheFs.PrivatePath(tempPri); sl@0: test(r==KErrNone); sl@0: theprivatepath = _L("?:"); sl@0: theprivatepath.Append(tempPri); sl@0: sl@0: TestDiskAdminAllfiles(); sl@0: sl@0: TFileName thesessionpath; sl@0: r=TheFs.SetSessionToPrivate(gTheDriveNum); sl@0: test(r==KErrNone); sl@0: r=TheFs.SessionPath(thesessionpath); sl@0: test(r==KErrNone); sl@0: test(thesessionpath == theprivatepath); sl@0: } sl@0: sl@0: sl@0: LOCAL_C void CleanupL() sl@0: // sl@0: // Clean up tests sl@0: // sl@0: { sl@0: test.Next(_L("Delete test directory")); sl@0: CFileMan* fMan=CFileMan::NewL(TheFs); sl@0: TInt r=fMan->RmDir(gSessionPath); sl@0: test(r==KErrNone || KErrPathNotFound); sl@0: delete fMan; sl@0: } sl@0: sl@0: GLDEF_C void CallTestsL(/*TChar aDriveLetter*/) sl@0: // sl@0: // Do all tests sl@0: // sl@0: { sl@0: if( !PlatSec::IsCapabilityEnforced(ECapabilityAllFiles) || sl@0: !PlatSec::IsCapabilityEnforced(ECapabilityDiskAdmin)) sl@0: { sl@0: test.Printf(_L("Capabilities insufficient - leaving t_dcdiskadminallfiles")); sl@0: test.Printf(_L("\n")); // Prevent overwrite by next print sl@0: return; sl@0: } sl@0: TurnAllocFailureOff(); sl@0: TheFs.CharToDrive(gDriveToTest,gTheDriveNum); sl@0: sl@0: TBuf<30> sesspath; sl@0: sesspath=_L("?:\\"); sl@0: sesspath[0] = (TText)gDriveToTest; sl@0: sl@0: TInt r= TheFs.SetSessionPath(sesspath); sl@0: test(r==KErrNone); sl@0: sl@0: TBuf<2> cmd; sl@0: cmd.SetLength(1); sl@0: cmd[0] = (TText)gDriveToTest; sl@0: RProcess tp; sl@0: r=tp.Create(_L("clean_prepdc.exe"),sesspath); sl@0: test(r==KErrNone); sl@0: { sl@0: TRequestStatus ps; sl@0: tp.Logon(ps); sl@0: tp.Resume(); sl@0: tp.Close(); sl@0: User::WaitForRequest(ps); sl@0: } sl@0: sl@0: //check double mode ie that Defpath still works sl@0: RFs fs1; sl@0: RFs fs2; sl@0: sl@0: r=fs1.Connect(); sl@0: test(r==KErrNone); sl@0: r=fs1.SessionPath(sesspath); sl@0: test(r==KErrNone); sl@0: test.Printf(_L("session1 Path=%S"),&sesspath); sl@0: sl@0: TBuf<30> privatepath; sl@0: r=fs1.SetSessionToPrivate(gTheDriveNum); sl@0: test(r==KErrNone); sl@0: r=fs1.PrivatePath(privatepath); sl@0: test(r==KErrNone); sl@0: r=privatepath.Compare(KExpectedPrivatePath()); sl@0: test(r==0); sl@0: r=fs1.SessionPath(sesspath); sl@0: test(r==KErrNone); sl@0: r=privatepath.Compare(sesspath.Mid(KPathPosition)); sl@0: test(r==0); sl@0: r=fs1.CreatePrivatePath(gTheDriveNum); sl@0: test(r==KErrNone); sl@0: fs1.Close(); sl@0: sl@0: r=fs2.Connect(); sl@0: test(r==KErrNone); sl@0: r=fs2.SessionPath(sesspath); sl@0: test(r==KErrNone); sl@0: test.Printf(_L("session2 Path=%S"),&sesspath); sl@0: fs2.Close(); sl@0: sl@0: TestCaps(); sl@0: sl@0: test.Printf(_L("No of files open=%d"), TheFs.ResourceCount()); sl@0: sl@0: CleanupL(); sl@0: }