void CTErrorStep::FindRemovableMediaL(TDriveUnit& aDriveUnit) { #ifdef __WINS__ aDriveUnit = EDriveX; #else // The removable media is expected at D: on NAND ROM and at E: on normal ROMs. // The following code works on techview but not guaranteed to work on all platforms. RFs fs; User::LeaveIfError(fs.Connect()); TDriveInfo driveInfo; TInt error = fs.Drive(driveInfo, EDriveD); if(error == KErrNone && ((driveInfo.iDriveAtt & KDriveAttRemovable) != 0)) { aDriveUnit = EDriveD; // Use drive D } else { error = fs.Drive(driveInfo, EDriveE); if(error == KErrNone && ((driveInfo.iDriveAtt & KDriveAttRemovable) != 0)) { aDriveUnit = EDriveE; // Use drive E } } fs.Close(); #endif }
void FmBkupEnginePrivate::getBackupDriveList( QStringList &driveList ) { TUint32 driveAttMask( AllowedDriveAttMatchMask() ); RFs fs; fs.Connect(); for ( TInt i( 0 ); i < KMaxDrives; ++i ) { TDriveInfo driveInfo; if ( fs.Drive( driveInfo, i ) == KErrNone ) { // Do not allow backup for internal drives TUint driveStatus( 0 ); DriveInfo::GetDriveStatus( fs, i, driveStatus ); if ( driveStatus & DriveInfo::EDriveInternal ) { continue; } if ( driveInfo.iDriveAtt & driveAttMask ) { driveList.append( NumberToDriverName( i ) ); } } } fs.Close(); }
// --------------------------------------------------------- // CPosLmLocalDatabaseManager::CreateDriveInfoListL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosLmLocalDatabaseManager::CreateDriveInfoListL() { RFs fs; CleanupClosePushL(fs); User::LeaveIfError(fs.Connect()); TDriveList driveList; User::LeaveIfError(fs.DriveList(driveList)); for (TInt drive = EDriveA; drive <= EDriveZ; drive++) { if ( driveList[drive] && !( driveList[drive] & KDriveAttRemote ) ) // avoid remote drives { TDriveInfo drvInfo; TInt err = fs.Drive( drvInfo, drive ); if ( !err && drvInfo.iType != EMediaNotPresent ) { TMediaInfo mediaInfo; mediaInfo.iMediaType = drvInfo.iType; User::LeaveIfError(fs.DriveToChar(drive, mediaInfo.iDrive)); User::LeaveIfError(iMediaInfoList.Append(mediaInfo)); } } } CleanupStack::PopAndDestroy(&fs); }
LOCAL_C void GetDriveLetters() { // Assign the first drive that matches the required criteria test.Next(_L("T_DENYCLAMP - GetDriveLetters()")); TDriveList driveList; TDriveInfo driveInfo; TInt r=TheFs.DriveList(driveList); test(r==KErrNone); TInt drvNum; TBool drivesFound = EFalse; for(drvNum=0; (drvNum<KMaxDrives) && !drivesFound; drvNum++) { TChar drvLetter='?'; TFileName fileSystem; if(!driveList[drvNum]) continue; test(TheFs.Drive(driveInfo, drvNum) == KErrNone); test(TheFs.DriveToChar(drvNum,drvLetter) == KErrNone); r=TheFs.FileSystemName(fileSystem,drvNum); fileSystem.UpperCase(); test((r==KErrNone)||(r==KErrNotFound)); // Check for FAT on NAND if(NandFatDrv=='?') { if((driveInfo.iType==EMediaNANDFlash) && (fileSystem.Compare(KFATName)==0)) NandFatDrv=drvLetter; } // Check for ROFS if(RofsDrv=='?') { if((driveInfo.iType==EMediaNANDFlash) && (fileSystem.Compare(KROFSName)==0)) RofsDrv=drvLetter; } // Check for LFFS if(LffsDrv=='?') { if((driveInfo.iType==EMediaFlash) && (fileSystem.Compare(KLFFSName)==0)) LffsDrv=drvLetter; } // Check for CompFSys if(CompDrv=='?') { if((driveInfo.iType==EMediaRom) && ((fileSystem.Compare(KROMName)==0)||(fileSystem.Compare(KCOMPName)==0))) CompDrv=drvLetter; } drivesFound=((NandFatDrv!='?')&&(RofsDrv!='?')&&(LffsDrv!='?')&&(CompDrv!='?')); } if(NandFatDrv!='?') test((NandFatDrv!=RofsDrv)&&(NandFatDrv!=LffsDrv)&&(NandFatDrv!=CompDrv)); if(RofsDrv!='?') test((RofsDrv!=LffsDrv)&&(RofsDrv!=CompDrv)); if(LffsDrv!='?') test(LffsDrv!=CompDrv); RDebug::Printf("T_DENYCLAMP: FAT drive=%C, ROFS drive=%C, LFFS drive=%C, ROM-COMP drive=%C \n",(TText)NandFatDrv,(TText)RofsDrv,(TText)LffsDrv,(TText)CompDrv); return; }
GLDEF_C TBool isDriveRemovable(TInt aDriveNumber) { RFs fs; test(KErrNone == fs.Connect()); TDriveInfo info; fs.Drive(info, aDriveNumber); fs.Close(); if (info.iDriveAtt & KDriveAttRemovable) { return ETrue; } return EFalse; }
static TBool DiskPresent(TInt aDrive) { TDriveList list; if (TheFs.DriveList(list) < KErrNone) return EFalse; TDriveInfo info; TInt error = TheFs.Drive(info, aDrive); if (error < KErrNone) return EFalse; return (list[aDrive] && info.iType != EMediaNotPresent); }
/** Creates SQL server private data path on the specified drive. The idea for calling it is to make sure that the server's private data path exists before making any other operation - attempting to create a database file there for example. @param aFs File session instance @param aDriveNumber Drive number on which the private path has to be created @internalComponent */ static void CreatePrivateDataPathL(RFs& aFs, TDriveNumber aDriveNumber) { TDriveInfo driveInfo; __SQLLEAVE_IF_ERROR2(aFs.Drive(driveInfo, aDriveNumber)); if(!(driveInfo.iDriveAtt & KDriveAttRom)) { TInt err = aFs.CreatePrivatePath(aDriveNumber); if(err != KErrNone && err != KErrAlreadyExists) { __SQLLEAVE2(err); } } }
/** @internalComponent */ void CCachedDriveInfo::ConstructL(RFs& aFs) { // Goes through each drive, and stores whether or not it is available, // the drive's attributes, and the drive's media attributes for (TDriveUnit drive(EDriveZ); drive >= EDriveA; drive = TInt(drive) - 1) { ASSERT(aFs.IsValidDrive(drive)); TDriveInfo driveInfo; User::LeaveIfError(aFs.Drive(driveInfo, drive)); iDriveAndMediaAttributes[drive].iDriveAttributes = driveInfo.iDriveAtt; iDriveAndMediaAttributes[drive].iMediaAttributes = driveInfo.iMediaAtt; iDriveAndMediaAttributes[drive].iMediaType = driveInfo.iType; } }
// -------------------------------------------------------------------------------- // void DumpToFileL( TPtrC8 aBuffer ) // -------------------------------------------------------------------------------- void DumpToFileL( TPtrC8 aBuffer ) { RFs fileSession; TInt pushed(0); if( fileSession.Connect() == KErrNone ) { CleanupClosePushL(fileSession); pushed++; RFile file; #ifdef __WINS__ if( file.Open(fileSession, KNSmlDebugOutputName(), EFileShareAny|EFileWrite) == KErrNone ) #else HBufC* outputName = HBufC::NewLC( KNSmlDebugOutputName().Length()+1 ); pushed++; TPtr namePtr = outputName->Des(); TDriveInfo driveInfo; for ( TUint driveNumber = EDriveA; driveNumber <= EDriveZ; driveNumber++ ) { fileSession.Drive( driveInfo, driveNumber ); if ( KDriveAttRemovable & driveInfo.iDriveAtt ) { // this is MMC namePtr.Insert( 0, KNSmlDebugDriveLetters().Mid( driveNumber, 1 )); namePtr.Insert( 1, KNSmlDebugOutputName() ); break; } } if( file.Open(fileSession, *outputName, EFileShareAny|EFileWrite) == KErrNone ) #endif { CleanupClosePushL(file); TInt pos(0); file.Seek(ESeekEnd, pos); RMutex mutex; NSmlGrabMutexLC(mutex, KNSmlDebugMutexName()); TInt result = file.Write(aBuffer); TInt result2 = file.Flush(); mutex.Signal(); CleanupStack::PopAndDestroy(2); // file, mutex User::LeaveIfError(result); User::LeaveIfError(result2); } CleanupStack::PopAndDestroy( pushed ); // fileSession and (for target) outputName } }
void doNSmlDebugInitL() { TInt pushed(0); RFs fileSession; User::LeaveIfError(fileSession.Connect()); CleanupClosePushL(fileSession); pushed++; TDriveInfo driveInfo; for ( TUint driveNumber = EDriveA; driveNumber <= EDriveZ; driveNumber++ ) { fileSession.Drive( driveInfo, driveNumber ); if ( KDriveAttRemovable & driveInfo.iDriveAtt ) { RFile file; HBufC* outputName = HBufC::NewLC( KNSmlDebugOutputName().Length()+1 ); pushed++; TPtr namePtr = outputName->Des(); namePtr.Insert( 0, KNSmlDebugDriveLetters().Mid( driveNumber, 1 )); namePtr.Insert( 1, KNSmlDebugOutputName() ); HBufC* outputDumpName = HBufC::NewLC( KNSmlDebugDumpName().Length()+1 ); pushed++; TPtr nameDumpPtr = outputDumpName->Des(); nameDumpPtr.Insert( 0, KNSmlDebugDriveLetters().Mid( driveNumber, 1 )); nameDumpPtr.Insert( 1, KNSmlDebugDumpName() ); fileSession.Delete(*outputName); fileSession.Delete(*outputDumpName); #if !defined(__SML_DEVELOPER_DEBUG__) { User::LeaveIfError(file.Create(fileSession, *outputName, EFileShareAny)); file.Close(); } #endif { User::LeaveIfError(file.Create(fileSession, *outputDumpName, EFileShareAny)); file.Close(); break; } } } CleanupStack::PopAndDestroy( pushed ); // fileSession }
GLDEF_C TBool StartUSBMS() { RFs fs; TInt r = fs.Connect(); if (r != KErrNone) { // BOOTFAULT RDebug::Print(_L("FAULT: Connecting RFs returned %d\r\n"), r); BOOT_FAULT(); } TInt drive; RFs::CharToDrive('D', drive); // XXX variant constant drivepath TDriveInfo info; r = fs.Drive(info, drive); if (r != KErrNone) { // BOOTFAULT RDebug::Print(_L("FAULT: Calling Drive() on RFs returned %d\r\n"), r); BOOT_FAULT(); } if (info.iType == EMediaNotPresent) { return EFalse; } LoadDevice = ELoadUSBMS; WriteConfig(); RProcess proc; TName command = _L("D"); r = proc.Create(_L("z:\\sys\\bin\\usbboot.exe"), command); if (r != KErrNone) { // BOOTFAULT RDebug::Print(_L("FAULT: error starting usbboot %d\r\n"), r); BOOT_FAULT(); } proc.Resume(); return ETrue; }
void CIAUpdateXmlParser::SetPrivateDriveL( RFs& aFs, const TDesC& aFileName ) const { IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateXmlParser::SetPrivateDriveL() begin: %S", &aFileName); // This will set the correct drive and private path // for the file server session. // First try to find the file from the private directory // of the drive where the process exists. RProcess process; // Set the session private path according to // the process file name drive. TInt driveNum( SetSessionPrivatePathL( aFs, process.FileName() ) ); // Get the session path that was set above. IAUPDATE_TRACE_1("[IAUPDATE] Find file: %d", driveNum); TFileName sessionPath; User::LeaveIfError( aFs.SessionPath( sessionPath ) ); IAUPDATE_TRACE_1("[IAUPDATE] Session path: %S", &sessionPath); // Use the file finder to check if the file actually exists // in the given drive path. If it does not, the file finder // will automatically check from other drives. So, here we // should always find the file if any exists. TFindFile finder( aFs ); User::LeaveIfError( finder.FindByDir( aFileName, sessionPath ) ); // The drive may have changed if the file was not found from // the first suggested drive. So, be sure to have the correct // private path. driveNum = SetSessionPrivatePathL( aFs, finder.File() ); // Use the drive info to check if the drive is ROM drive. // We prefer non ROM drives. But, accept ROM if nothing else is // available. IAUPDATE_TRACE_1("[IAUPDATE] Check ROM info: %d", driveNum); TDriveInfo info; User::LeaveIfError( aFs.Drive( info, driveNum ) ); TBool isRomDrive( info.iDriveAtt & KDriveAttRom ); if ( !isRomDrive ) { // The current file is not in ROM drive so use that. IAUPDATE_TRACE("[IAUPDATE] First file search done. Non ROM found."); IAUPDATE_TRACE("[IAUPDATE] CIAUpdateXmlParser::SetPrivateDriveL() end"); return; } // Because previous finding was ROM file, try to find a non ROM file. IAUPDATE_TRACE("[IAUPDATE] Try to find non ROM file."); TInt findErrorCode( finder.Find() ); if ( findErrorCode == KErrNotFound ) { // Because no new file is found, use the current settings. IAUPDATE_TRACE("[IAUPDATE] Second search done. No file found."); IAUPDATE_TRACE("[IAUPDATE] CIAUpdateXmlParser::SetPrivateDriveL() end"); return; } User::LeaveIfError( findErrorCode ); IAUPDATE_TRACE("[IAUPDATE] New file found. Use that."); // Update the session path for the correct file. SetSessionPrivatePathL( aFs, finder.File() ); IAUPDATE_TRACE("[IAUPDATE] CIAUpdateXmlParser::SetPrivateDriveL() end"); }
// this function was copied from t_sdpartition.cpp TInt FindMmcLocalDriveNumber(TChar aDriveChar, TInt& aLocalDriveNum, TInt aDriveNum) { TInt r = fs.CharToDrive(aDriveChar, aDriveNum); test(r==KErrNone); TDriveInfo driveInfo; r = fs.Drive(driveInfo, aDriveNum); test(r==KErrNone); TVolumeInfo vi; r = fs.Volume(vi, aDriveNum); test(r==KErrNone); TMediaSerialNumber serialNum; r = fs.GetMediaSerialNumber(serialNum, aDriveNum); test(r==KErrNone); test.Printf(_L("Drive %C size %ld\n"), (char) aDriveChar, vi.iSize); TInt len = serialNum.Length(); test.Printf(_L("Serial number (len %d) :"), len); TInt n; for (n=0; n<len; n+=16) { TBuf16<16*3 +1> buf; for (TInt m=n; m<n+16; m++) { TBuf16<3> hexBuf; hexBuf.Format(_L("%02X "),serialNum[m]); buf.Append(hexBuf); } buf.Append(_L("\n")); test.Printf(buf); } TBusLocalDrive drv; TBool chg(EFalse); aLocalDriveNum = -1; TInt serialNumbersMatched = 0; for (n=0; n<KMaxLocalDrives; n++) { r = drv.Connect(n, chg); //for user area //RDebug::Print(_L("TBusLocalDrive::Connect(%d) %d"), n, r); if(r != KErrNone) { test.Printf(_L("drive %d: TBusLocalDrive::Connect() failed %d\n"), n, r); continue; } TLocalDriveCapsV5Buf capsBuf; TLocalDriveCapsV5& caps = capsBuf(); r = drv.Caps(capsBuf); if(r != KErrNone) { test.Printf(_L("drive %d: TBusLocalDrive::Caps() failed %d\n"), n, r); continue; } //RDebug::Print(_L("areaSize %ld cardCapacity %ld"), caps.iSize, caps.iFormatInfo.iCapacity); TPtrC8 localSerialNum(caps.iSerialNum, caps.iSerialNumLength); if (serialNum.Compare(localSerialNum) == 0) { serialNumbersMatched++; TBool sizeMatch = (vi.iSize < caps.iSize); test.Printf(_L("drive %d: Serial number match, size match: %S\n"), n, sizeMatch?&KYes:&KNo); if (sizeMatch) { aLocalDriveNum = n; drv.Disconnect(); break; } } drv.Disconnect(); } return aLocalDriveNum == -1?KErrNotFound:KErrNone; }
// -------------------------------------------------------------------------------- // void doNSmlDebugDumpL( void* aData, TInt aLength, TText8* aFile, TInt aLine, const TText8* aMsg ) // -------------------------------------------------------------------------------- void doNSmlDebugDumpL( void* aData, TInt aLength, TText8* aFile, TInt aLine, const TText8* aMsg ) { TInt pushed(0); HBufC8* pDateBuffer8 = HBufC8::NewLC(64); pushed++; TPtr8 dateBuffer8 = pDateBuffer8->Des(); HBufC8* pTimeBuffer8 = HBufC8::NewLC(64); pushed++; TPtr8 timeBuffer8 = pTimeBuffer8->Des(); NSmlGetDateAndTimeL(dateBuffer8, timeBuffer8); TPtrC8 data(REINTERPRET_CAST(TUint8*, aData), aLength); TPtrC8 fileName(aFile); HBufC8* buffer8 = HBufC8::NewLC(KBufferSize); pushed++; TPtr8 ptrBuffer8 = buffer8->Des(); TPtrC8 msg(aMsg); if( !msg.Length() ) { #if !defined(__SML_DEVELOPER_DEBUG__) ptrBuffer8.Format(_L8("[%S %S File: %S Line: %d Length: %d]\r\n"), &dateBuffer8, &timeBuffer8, &fileName, aLine, aLength); #else ptrBuffer8.Format(_L8("[%S %S Length: %d]\r\n"), &dateBuffer8, &timeBuffer8, aLength); #endif } else { #if !defined(__SML_DEVELOPER_DEBUG__) ptrBuffer8.Format(_L8("[%S %S File: %S Line: %d Length: %d] %S\r\n"), &dateBuffer8, &timeBuffer8, &fileName, aLine, aLength, &msg); #else ptrBuffer8.Format(_L8("[%S %S Length: %d] %S\r\n"), &dateBuffer8, &timeBuffer8, aLength, &msg); #endif } // Now we're ready to write into file RFs fileSession; if( fileSession.Connect() == KErrNone ) { CleanupClosePushL(fileSession); pushed++; RFile file; #ifdef __WINS__ if( file.Open(fileSession, KNSmlDebugDumpName(), EFileShareAny|EFileWrite) == KErrNone ) #else HBufC* outputDumpName = HBufC::NewLC( KNSmlDebugDumpName().Length()+1 ); pushed++; TPtr nameDumpPtr = outputDumpName->Des(); TDriveInfo driveInfo; for ( TUint driveNumber = EDriveA; driveNumber <= EDriveZ; driveNumber++ ) { fileSession.Drive( driveInfo, driveNumber ); if ( KDriveAttRemovable & driveInfo.iDriveAtt ) { // this is MMC nameDumpPtr.Insert( 0, KNSmlDebugDriveLetters().Mid( driveNumber, 1 )); nameDumpPtr.Insert( 1, KNSmlDebugDumpName() ); break; } } if( file.Open(fileSession, *outputDumpName, EFileShareAny|EFileWrite) == KErrNone ) #endif { CleanupClosePushL(file); TInt pos(0); file.Seek(ESeekEnd, pos); RMutex mutex; NSmlGrabMutexLC(mutex, KNSmlDebugMutexNameDump()); TInt result1 = file.Write(ptrBuffer8); TInt result2 = file.Write(data); TInt result3 = file.Write(_L8("\r\n\r\n")); TInt result4 = file.Flush(); mutex.Signal(); CleanupStack::PopAndDestroy(2); // file, mutex User::LeaveIfError(result1); User::LeaveIfError(result2); User::LeaveIfError(result3); User::LeaveIfError(result4); } } CleanupStack::PopAndDestroy( pushed ); // buffer8, pDateBuffer8, pTimeBuffer8 }
// ----------------------------------------------------------------------------- // CPosLmLocalDatabaseManager::ListDatabasesLC // // (other items were commented in a header). // ----------------------------------------------------------------------------- // CDesCArray* CPosLmLocalDatabaseManager::ListDatabasesLC() { CDesCArray* dbArray = new (ELeave) CDesCArrayFlat(KPosDbListGranularity); CleanupStack::PushL(dbArray); RFs fs; CleanupClosePushL(fs); User::LeaveIfError(fs.Connect()); TDriveList driveList; User::LeaveIfError(fs.DriveList(driveList)); RDbs dbSession; CleanupClosePushL(dbSession); User::LeaveIfError(dbSession.Connect()); for (TInt drive = EDriveA; drive <= EDriveZ; drive++) { if ( driveList[drive] && !( driveList[drive] & KDriveAttRemote ) ) // avoid remote drives { TDriveInfo drvInfo; TInt err = fs.Drive( drvInfo, drive ); if ( !err && drvInfo.iType != EMediaNotPresent ) { CDbDatabaseNames* dbNames = NULL; TRAPD(err, dbNames = dbSession.DatabaseNamesL( static_cast<TDriveNumber>(drive), KPosLmDbSecureUid)); // Ignore all errors except KErrNoMemory (and KErrNone) if (err == KErrNone) { CleanupStack::PushL(dbNames); for (TInt i = 0; i < dbNames->Count(); i++) { TPtrC ptr = (*dbNames)[i]; if (ptr.Right(KFileExtension().Length()). CompareF(KFileExtension) == 0) { HBufC* fullName = HBufC::NewLC( KFileProtocol().Length() + KProtocolDelimiter().Length() + KDriveAndDelimiterLength + (*dbNames)[i].Length()); TChar chr; fs.DriveToChar(drive, chr); TPtr ptr2 = fullName->Des(); ptr2.Append(KFileProtocol); ptr2.Append(KProtocolDelimiter); ptr2.Append(chr); ptr2.Append(KDriveDelimiter); ptr2.Append((*dbNames)[i]); dbArray->AppendL(*fullName); CleanupStack::PopAndDestroy(fullName); } } CleanupStack::PopAndDestroy(dbNames); } else if (err == KErrNoMemory) { User::Leave(err); } } } } CleanupStack::PopAndDestroy(2, &fs); //dbSession return dbArray; }
/** @SYMTestCaseID PDS-SQL-UT-4141 @SYMTestCaseDesc RFileBuf64::SetReadAheadSize() test. The test iterates over all existing drives. For each R/W drive a test file is created using RFileBuf64 class. Then the test collects information regarding the block size, cluster size and read buffer size and calls RFileBuf64::SetReadAheadSize() with these parameters to check how the read-ahead buffer size will be recalculated. @SYMTestActions RFileBuf64::SetReadAheadSize() test. @SYMTestExpectedResults Test must not fail @SYMTestPriority High @SYMREQ REQ12106 REQ12109 */ void SetReadAheadSizeTest() { TheTest.Printf(_L("==================\r\n")); _LIT(KType1, "Not present"); _LIT(KType2, "Unknown"); _LIT(KType3, "Floppy"); _LIT(KType4, "Hard disk"); _LIT(KType5, "CD ROM"); _LIT(KType6, "RAM disk"); _LIT(KType7, "Flash"); _LIT(KType8, "ROM drive"); _LIT(KType9, "Remote drive"); _LIT(KType10,"NAND flash"); _LIT(KType11,"Rotating media"); for(TInt drive=EDriveA;drive<=EDriveZ;++drive) { TDriveInfo driveInfo; TInt err = TheFs.Drive(driveInfo, drive); if(err == KErrNone) { TVolumeInfo vinfo; err = TheFs.Volume(vinfo, drive); if(err == KErrNone) { TVolumeIOParamInfo vparam; err = TheFs.VolumeIOParam(drive, vparam); TEST2(err, KErrNone); TBuf8<128> vinfoex8; err = TheFs.QueryVolumeInfoExt(drive, EFileSystemSubType, vinfoex8); TEST2(err, KErrNone); TPtrC vinfoex((const TUint16*)(vinfoex8.Ptr() + 8), vinfoex8[0]); TPtrC KMediaTypeNames[] = {KType1(), KType2(), KType3(), KType4(), KType5(), KType6(), KType7(), KType8(), KType9(), KType10(), KType11()}; TheTest.Printf(_L("Drive: %C:, Type: %16.16S, File System: %8.8S, Size: %d Mb.\r\n"), 'A' + drive, &KMediaTypeNames[driveInfo.iType], &vinfoex, (TInt)(vinfo.iSize / (1024 * 1024))); TheTest.Printf(_L(" Size: %ld bytes.\r\n"), vinfo.iSize); TheTest.Printf(_L(" Block size=%d, Cluster size=%d, Read buffer size=%d.\r\n"), vparam.iBlockSize, vparam.iClusterSize, vparam.iRecReadBufSize); if(driveInfo.iType == EMediaRam || driveInfo.iType == EMediaHardDisk || driveInfo.iType == EMediaFlash || driveInfo.iType == EMediaNANDFlash) { TDriveUnit drvUnit(drive); TDriveName drvName = drvUnit.Name(); TParse parse; parse.Set(KTestFile2, &drvName, NULL); TheDbName.Copy(parse.FullName()); TRAP(err, BaflUtils::EnsurePathExistsL(TheFs, TheDbName)); if(err == KErrNone || err == KErrAlreadyExists) { (void)TheFs.Delete(TheDbName); RFileBuf64 fbuf64(8 * 1024); err = fbuf64.Create(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err, KErrNone); TInt readAhead = fbuf64.SetReadAheadSize(vparam.iBlockSize, vparam.iRecReadBufSize); TheTest.Printf(_L(" Read-ahead size=%d.\r\n"), readAhead); fbuf64.Close(); (void)TheFs.Delete(TheDbName); } else { TheTest.Printf(_L("Drive %C. BaflUtils::EnsurePathExistsL() has failed with err=%d.\r\n"), 'A' + drive, err); } } } else { TheTest.Printf(_L("Drive %C. RFs::Volume() has failed with err=%d.\r\n"), 'A' + drive, err); } } else { TheTest.Printf(_L("Drive %C. RFs::Drive() has failed with err=%d.\r\n"), 'A' + drive, err); } } TheTest.Printf(_L("==================\r\n")); // RFileBuf64 fbuf64(8 * 1024);//buffer capacity = 8Kb //"ReadRecBufSize" defined and is power of two, the "BlockSize" is also defined and is power of two TInt err2 = fbuf64.Create(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); TInt blockSize = 4096; TInt readRecBufSize = 2048; TInt readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, readRecBufSize); fbuf64.Close(); //"ReadRecBufSize" defined and is power of two but is less than the default read-ahead value err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); blockSize = 0; readRecBufSize = 128; readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, RFileBuf64::KDefaultReadAheadSize); fbuf64.Close(); //"ReadRecBufSize" defined and is power of two but is bigger than the buffer capacity err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); blockSize = -10; readRecBufSize = fbuf64.iCapacity * 2; readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, fbuf64.iCapacity); fbuf64.Close(); //"ReadRecBufSize" defined but is not power of two, "BlockSize" defined but is less than the default read-ahead value err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); blockSize = 512; readRecBufSize = 4000; readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, RFileBuf64::KDefaultReadAheadSize); fbuf64.Close(); //"ReadRecBufSize" defined but is not power of two, "BlockSize" defined and is bigger than the default read-ahead value err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); blockSize = 4096; readRecBufSize = 4000; readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, blockSize); fbuf64.Close(); //"ReadRecBufSize" defined but is not power of two, "BlockSize" defined and is bigger than the buffer capacity err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); blockSize = fbuf64.iCapacity * 2; readRecBufSize = 1; readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, fbuf64.iCapacity); fbuf64.Close(); //"ReadRecBufSize" negative, "BlockSize" defined but is not power of two err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); blockSize = 1000; readRecBufSize = -2; readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, RFileBuf64::KDefaultReadAheadSize); fbuf64.Close(); //"ReadRecBufSize" negative, "BlockSize" negative err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); blockSize = -1; readRecBufSize = -2; readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, RFileBuf64::KDefaultReadAheadSize); fbuf64.Close(); // (void)TheFs.Delete(TheDbName); }
// Member for thread function TInt CSMPSoakThread::DoSMPStressDeviceThread() { RTest test(_L("SMPStressDeviceThread")); test.Start(_L("SMPStressDeviceThread")); RTimer timer; RFs session; TFileName sessionPath; test_KErrNone(timer.CreateLocal()); TRequestStatus s; TDesC** ptrDevices = (TDesC**) (iThreadData.listPtr); PRINT ((_L("Devices Number %d [%s]\n"), ptrDevices[0]->Length(), ptrDevices[0]->Ptr())); for (TInt i = 1; ptrDevices[i] ; i++) PRINT ((_L("LDD%d=%s "),i,ptrDevices[i]->Ptr())); PRINT (_L("\n")); FOREVER { for (TInt i = 0; i < ptrDevices[0]->Length(); i++) { TText driveLetter = (*ptrDevices[0])[i]; PRINT ((_L("Device %c\n"),driveLetter)); test_KErrNone(session.Connect()); sessionPath=(_L("?:\\SESSION_TEST\\")); sessionPath[0]=driveLetter; test_KErrNone(session.SetSessionPath(sessionPath)); TInt driveNumber; test_KErrNone(session.CharToDrive(driveLetter, driveNumber)); TBuf<64> fileSystemName; test_KErrNone(session.FileSystemName(fileSystemName,driveNumber)); PRINT ((_L("File System Name %s\n"),fileSystemName.PtrZ())); TDriveInfo driveInfo; test_KErrNone(session.Drive(driveInfo, driveNumber)); TVolumeInfo volumeInfo; test_KErrNone(session.Volume(volumeInfo, driveNumber)); session.Close(); } for (TInt i = 1; ptrDevices[i] ; i += 2) { RDevice device; TInt r = User::LoadLogicalDevice(*ptrDevices[i]); if (r != KErrNone && r != KErrAlreadyExists) { test.Printf(_L("LDD %S not present\n"), ptrDevices[i]); continue; } test_KErrNone(device.Open(*ptrDevices[i+1])); TBuf8<64> deviceCaps; device.GetCaps(deviceCaps); TVersion deviceVersion; device.QueryVersionSupported(deviceVersion); device.Close(); } SetThreadPriority(); timer.After(s, iThreadData.delayTime*1000); User::WaitForRequest(s); test (s == KErrNone); if (gAbort) break; User::After(gPeriod); } timer.Close(); PRINT((_L("SMPStressDeviceThread MyTimer.Cancel() called\n"))); test.End(); test.Close(); return 0x00; }
TVerdict CDaemonStep::runTestStepL(TBool /*aOomTest*/) { iDaemon=CDaemon::NewL(*this); // Check all the correct wtachers were started up RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); TDriveList driveList; User::LeaveIfError(fs.DriveList(driveList)); TInt count=0; for (TInt drive=0; drive < KMaxDrives; ++drive) { if (driveList[drive] == 0) { continue; } TDriveInfo info; // Ignore errors since the next drive might work if (KErrNone != fs.Drive(info, drive)) { /// @todo, log error continue; } if (info.iDriveAtt & KDriveAttRemovable) { if (drive != iDaemon->Watchers()[count++]->Drive()) { ERR_PRINTF1(_L("Error, watched drives do not match")); SetTestStepResult(EFail); User::Leave(KErrNotFound); } } } // Different number started up if (count != iDaemon->Watchers().Count()) { ERR_PRINTF1(_L("Error, watched drive count does not match")); SetTestStepResult(EFail); User::Leave(KErrGeneral); } // Different number started up if (count == 0) { ERR_PRINTF1(_L("Error, there must be at least one removable drive present")); SetTestStepResult(EFail); User::Leave(KErrGeneral); } CleanupStack::PopAndDestroy(&fs); return EPass; }