From d2c8684449c10125f6b0dde8e99f1057ddecdaa4 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 26 Feb 2004 09:37:04 +0000 Subject: [PATCH] ignore usb-storage descriptors marked "not attached" --- .../MemoryCard/MemoryCardDriver_Linux.cpp | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriver_Linux.cpp b/stepmania/src/arch/MemoryCard/MemoryCardDriver_Linux.cpp index 31c4367e02..16d36b0ac9 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriver_Linux.cpp +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriver_Linux.cpp @@ -133,10 +133,11 @@ void MemoryCardDriver_Linux::GetStorageDevices( vector& vDevic } { - // Find the usb-storage device index for all storage class devices. - for( unsigned i=0; i& vDevic // GUID: 04e801000001125198948886 // Attached: Yes - CString fn = ssprintf( "/proc/scsi/usb-storage-%d/%d", i, i ); + CString fn = ssprintf( "/proc/scsi/usb-storage-%d/%d", iUsbStorageIndex, iUsbStorageIndex ); ifstream f; f.open(fn); if( !f.is_open() ) - { - LOG->Warn( "can't open '%s'", fn.c_str() ); - return; - } + break; + + char szTemp[1024]; CString sLine; while( getline(f, sLine) ) { - // Serial Number: 1125198948886 - char szSerial[1024]; - int iRet = sscanf( sLine.c_str(), "Serial Number: %[^\n]", szSerial ); + // Attached: Yes + int iRet = sscanf( sLine.c_str(), " Attached: %s", szTemp ); if( iRet == 1 ) // we found our line { - usbd.iUsbStorageIndex = i; - - LOG->Trace( "iUsbStorageIndex: %d, iBus: %d, iDeviceOnBus: %d, iPortOnHub: %d", - usbd.iUsbStorageIndex, usbd.iBus, usbd.iDeviceOnBus, usbd.iPortOnHub ); - - break; // stop looking + if( strcmp(szTemp,"Yes")==0 ) + { + usbd.iUsbStorageIndex = iUsbStorageIndex; + iConnectedDeviceIndex++; + } + else if( strcmp(szTemp,"No")==0 ) + { + break; // this device isn't attached. Ignore it. + } + else + { + LOG->Warn( "Invalid value for Attached: '%s'", szTemp ); + break; + } } } }