/** Read the FSInfo sector at the FSI_Free_Count field. Following this check that the last known cluster count is less than the actual cluster count of the volume. Note: This function should be called after files have been written to the disk to ensure that clusters have been occupied @param aPos The position at which to start reading from the raw disk @return KErrNone if successful */ TInt CBaseTestFat32Calculate::CheckFSInfo(TInt aPos) { TUint32 fsInfo; TUint32 data; TPtr8 buffer((TUint8*)&data,4); TInt r = TheDisk.Open(iTheFs, CurrentDrive()); r = TheDisk.Read(aPos,buffer); fsInfo = data; TheDisk.Close(); if (fsInfo < iClusterCount) { _LIT(KFSInfoPass, "FSInfo Correct, iClusterCount = %08x fsInfo = %08x fsInfo = %08x"); INFO_PRINTF4(KFSInfoPass, iClusterCount, data, fsInfo); return KErrNone; } else { _LIT(KFSInfoFail, "FSInfo incorrect, iClusterCount = %08x fsInfo = %08x"); INFO_PRINTF3(KFSInfoFail, iClusterCount, fsInfo); return -1; } }
/** Set the cluster count to a value greater than it should be The bad cluster count is caluclated as 10000 added to the actual cluster count value. The bad cluster count is then written to the disk in place of the actual cluster count. @param aClusterCount The cluster count of the volume @param aPos The position at which to start writing to the raw disk @return KErrNone if successful */ TInt CBaseTestFat32Calculate::SetToGreater(TUint32 aClusterCount, TInt aPos) { TUint32 badClusterCount; badClusterCount = aClusterCount+10000; TUint8 num[4]; TInt i; TInt r; r = TheDisk.Open(iTheFs, CurrentDrive()); for (i=0; i<4; i++) { num[i] = 0; num[i] = num[i] + badClusterCount; badClusterCount = badClusterCount >> 8; } TUint8 data[1]; TPtr8 buffer((TUint8*)&data[0],1); for (i=0; i<4; i++) { aPos = aPos + 1; r=TheDisk.Read(aPos,buffer); data[0]=num[i]; r=TheDisk.Write(aPos,buffer); } TheDisk.Close(); return r; }
LOCAL_C void TestNoCaps() // // test APIs with no capabilities // { r=TheFs.FileSystemName(fsname,gTheDriveNum); test_KErrNone(r); r = DismountFileSystem(TheFs, fsname, gTheDriveNum); test_Value(r, r == KErrPermissionDenied); // r=TheFs.RemoveFileSystem(fsname); //can not test due to bug elsewhere fix exists // test_Value(r, r == KErrPermissionDenied); // r=TheFs.AddFileSystem(fsname); // test_Value(r, r == KErrPermissionDenied); r = MountFileSystem(TheFs, fsname, gTheDriveNum); test_Value(r, r == KErrPermissionDenied); r=TheFs.SetDriveName(gTheDriveNum,KDriveName); test_Value(r, r == KErrPermissionDenied); // r=TheFs.SetVolumeLabel(KVolLable, gTheDriveNum); //broken on wins C: // test_Value(r, r == KErrPermissionDenied); systemRFstest(); resourceRFstest(); privateRFstest(); privateSIDRFstest(); privatefalseIDRFstest(); systemRFiletest(); resourceRFiletest(); privateRFiletest(); privateSIDRFiletest(); privatefalseIDRFiletest(); //disk changes to sys and pri paths should have completed these test(aStat4 == KRequestPending); TheFs.NotifyChangeCancel(aStat4); test(aStat4==KErrCancel); User::WaitForRequest(aStat3); test(aStat1==KErrPermissionDenied); test(aStat2==KErrPermissionDenied); test(aStat3==KErrNone); r=TheFs.SetSessionPath(systestname); test_Value(r, r == KErrPermissionDenied); //Test RRawDisk class r=rawdisk.Open(TheFs,gTheDriveNum); test_Value(r, r == KErrPermissionDenied); // rawdisk.Close(); r=format.Open(TheFs,driveBuf,EHighDensity,count); test_Value(r, r == KErrPermissionDenied); RDirtest(); driveBuf[0]=(TText)gDriveToTest; r=TheFs.ScanDrive(driveBuf); test_Value(r, r == KErrPermissionDenied); r=TheFs.CheckDisk(driveBuf); test_Value(r, r == KErrPermissionDenied); }
LOCAL_C void DiskAdminTest() // // test diskadministration capabilitiy // { r=TheFs.FileSystemName(fsname,gTheDriveNum); test_KErrNone(r); r = DismountFileSystem(TheFs, fsname, gTheDriveNum); test_KErrNone(r); // r=TheFs.RemoveFileSystem(fsname); //can not test due to bug else where fix exists // test_Value(r, r == KErrPermissionDenied); // r=TheFs.AddFileSystem(fsname); // test_Value(r, r == KErrPermissionDenied); r = MountFileSystem(TheFs, fsname, gTheDriveNum); test_KErrNone(r); r=TheFs.SetDriveName(gTheDriveNum,KDriveName); test_KErrNone(r); r=TheFs.SetVolumeLabel(KVolLable, gTheDriveNum); test_Value(r, r == KErrNone || r==KErrNotSupported); systemRFstest(); resourceRFstest(); privateRFstest(); privateSIDRFstest(); privateFalseIDRFstest(); systemRFiletest(); resourceRFiletest(); privateRFiletest(); privateSIDRFiletest(); privatefalseIDRFiletest(); //disk changes to sys and pri paths should have completed these test(aStat4 == KRequestPending); TheFs.NotifyChangeCancel(aStat4); test(aStat4==KErrCancel); User::WaitForRequest(aStat3); test(aStat1==KErrPermissionDenied); test(aStat2==KErrPermissionDenied); test(aStat3==KErrNone); r=TheFs.SetSessionPath(systestname); test_Value(r, r == KErrPermissionDenied); //Test RRawDisk class r=rawdisk.Open(TheFs,gTheDriveNum); test_Value(r, r == KErrPermissionDenied); rawdisk.Close(); RDirtest(); #ifdef __WINS__ if (User::UpperCase(driveBuf[0]) != 'C') #endif { //Test RFormat class r=format.Open(TheFs,driveBuf,EHighDensity,count); test_KErrNone(r); while(count) { TInt r=format.Next(count); test_KErrNone(r); } format.Close(); } driveBuf[0]=(TText)gDriveToTest; r=TheFs.ScanDrive(driveBuf); test_Value(r, r == KErrNone || r==KErrNotSupported); r=TheFs.CheckDisk(driveBuf); test_Value(r, r == KErrNone || r==KErrNotSupported); }