sl@0: // Copyright (c) 2001-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: // this isn't actually a test of the media driver.It scans all loaded media sl@0: // drivers a filesystems and prints information about them sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: sl@0: sl@0: LOCAL_C void ScanPhysicalDeviceDrivers() sl@0: /** sl@0: * Displays list of loaded PDDs sl@0: */ sl@0: { sl@0: RDebug::Print( _L("Scanning loaded media drivers...") ); sl@0: sl@0: _LIT( KSearchName, "Media.*" ); sl@0: TFindPhysicalDevice findHb; sl@0: findHb.Find(KSearchName); sl@0: TFullName name; sl@0: while (findHb.Next(name)==KErrNone) sl@0: { sl@0: _LIT( KFormatStr, " %S" ); sl@0: RDebug::Print( KFormatStr, &name ); sl@0: } sl@0: sl@0: RDebug::Print( _L("\r\n") ); sl@0: } sl@0: sl@0: sl@0: LOCAL_C void ShowDriveCaps( const TLocalDriveCaps& aCaps ) sl@0: { sl@0: RDebug::Print( _L(" size=%ld"), aCaps.iSize ); sl@0: RDebug::Print( _L(" media type=%d"), aCaps.iType ); sl@0: RDebug::Print( _L(" connection bus=%d"), aCaps.iConnectionBusType ); sl@0: RDebug::Print( _L(" drive attributes=0x%x"), aCaps.iDriveAtt ); sl@0: RDebug::Print( _L(" media attributes=0x%x"), aCaps.iMediaAtt ); sl@0: RDebug::Print( _L(" base address=0x%x"), aCaps.iBaseAddress ); sl@0: sl@0: _LIT( KFsysUnknown, "Unknown" ); sl@0: _LIT( KFsysRom, "ROM" ); sl@0: _LIT( KFsysFat, "FAT" ); sl@0: _LIT( KFsysLffs, "LFFS" ); sl@0: const TDesC* fsType; sl@0: switch( aCaps.iFileSystemId ) sl@0: { sl@0: case KDriveFileSysFAT: sl@0: fsType = &KFsysFat; sl@0: break; sl@0: case KDriveFileSysROM: sl@0: fsType = &KFsysRom; sl@0: break; sl@0: case KDriveFileSysLFFS: sl@0: fsType = &KFsysLffs; sl@0: break; sl@0: default: sl@0: fsType = &KFsysUnknown; sl@0: break; sl@0: } sl@0: sl@0: RDebug::Print( _L(" filesystem id=%S (%d)\r\n"), fsType, aCaps.iFileSystemId ); sl@0: } sl@0: sl@0: LOCAL_C void ShowVariantDriveInfo() sl@0: /** sl@0: * Display drive mapping info from variant/ASSP layers sl@0: */ sl@0: { sl@0: RDebug::Print( _L("Variant drive info...") ); sl@0: sl@0: sl@0: // Drive info sl@0: TDriveInfoV1Buf driveInfo; sl@0: TInt r=UserHal::DriveInfo(driveInfo); sl@0: if( KErrNone == r ) sl@0: { sl@0: RDebug::Print( _L("Total supported drives = %d"), driveInfo().iTotalSupportedDrives ); sl@0: } sl@0: else sl@0: { sl@0: RDebug::Print( _L("!! Failed to get drive info (e=%d)"), r ); sl@0: } sl@0: sl@0: // Attempt to open local drives sl@0: for( TInt i = 0; i < KMaxLocalDrives; i++ ) sl@0: { sl@0: TBusLocalDrive drive; sl@0: TBool changedFlag = EFalse; sl@0: TInt r = drive.Connect( i, changedFlag ); sl@0: if( KErrNone == r ) sl@0: { sl@0: RDebug::Print( _L("LocDrive %d: connected"), i ); sl@0: TLocalDriveCapsV2Buf caps; sl@0: TInt rv = drive.Caps( caps ); sl@0: if( KErrNone == rv ) sl@0: { sl@0: ShowDriveCaps( caps() ); sl@0: } sl@0: else sl@0: { sl@0: RDebug::Print( _L(" failed to get caps(%d)"), rv ); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: RDebug::Print( _L("LocDrive %d: not available(%d)"), r ); sl@0: } sl@0: drive.Disconnect(); sl@0: } sl@0: sl@0: RDebug::Print( _L("\r\n") ); sl@0: } sl@0: sl@0: sl@0: sl@0: LOCAL_C void ShowVolumeInfo( const TVolumeInfo& aInfo ) sl@0: { sl@0: sl@0: RDebug::Print( _L(" media type=%d"), aInfo.iDrive.iType ); sl@0: RDebug::Print( _L(" drive attributes=0x%x"), aInfo.iDrive.iDriveAtt ); sl@0: RDebug::Print( _L(" media attributes=0x%x"), aInfo.iDrive.iMediaAtt ); sl@0: RDebug::Print( _L(" connection bus=%d"), aInfo.iDrive.iConnectionBusType ); sl@0: sl@0: RDebug::Print( _L(" UID=0x%x"), aInfo.iUniqueID ); sl@0: RDebug::Print( _L(" size=0x%lx"), aInfo.iSize ); sl@0: RDebug::Print( _L(" free=0x%lx"), aInfo.iFree ); sl@0: RDebug::Print( _L(" name=%S"), &aInfo.iName ); sl@0: } sl@0: sl@0: sl@0: LOCAL_C void ShowDriveMountInfo() sl@0: /** sl@0: * Show mounted filesystems sl@0: */ sl@0: { sl@0: RDebug::Print( _L("Scanning drives") ); sl@0: sl@0: RFs fs; sl@0: TInt rv = fs.Connect(); sl@0: if( KErrNone != rv ) sl@0: { sl@0: RDebug::Print( _L("!! Failed to connect to F32(%d)"), rv ); sl@0: return; sl@0: } sl@0: sl@0: for( TInt i = EDriveA; i <= EDriveZ; i++ ) sl@0: { sl@0: RDebug::Print( _L("Drive %c:"), i+'A' ); sl@0: sl@0: TFullName name; sl@0: rv = fs.FileSystemName(name, i); sl@0: if( KErrNone != rv && KErrNotFound != rv) sl@0: { sl@0: RDebug::Print( _L(" !! failed to read filesystem name(%d)"), rv ); sl@0: } sl@0: else sl@0: { sl@0: if (name.Length() != 0) sl@0: { sl@0: RDebug::Print( _L(" FS=%S"), &name ); sl@0: } sl@0: else sl@0: { sl@0: RDebug::Print( _L(" no filesystem") ); sl@0: } sl@0: sl@0: TVolumeInfo volInfo; sl@0: rv = fs.Volume( volInfo, i ); sl@0: if( KErrNone == rv ) sl@0: { sl@0: ShowVolumeInfo( volInfo ); sl@0: } sl@0: else sl@0: { sl@0: RDebug::Print( _L(" !! failed to get volume info(%d)"), rv ); sl@0: } sl@0: RDebug::Print( _L("\r\n") ); sl@0: } sl@0: sl@0: sl@0: } sl@0: sl@0: fs.Close(); sl@0: } sl@0: sl@0: sl@0: sl@0: void E32Main() sl@0: { sl@0: RDebug::Print( _L("TF_FSSCAN") ); sl@0: sl@0: ScanPhysicalDeviceDrivers(); sl@0: ShowVariantDriveInfo(); sl@0: ShowDriveMountInfo(); sl@0: sl@0: RDebug::Print( _L("TF_FSSCAN done") ); sl@0: } sl@0: