diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriver.h b/stepmania/src/arch/MemoryCard/MemoryCardDriver.h index fef26656b0..fe68089136 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriver.h +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriver.h @@ -18,6 +18,9 @@ struct UsbStorageDevice bNeedsWriteTest = true; bWriteTestSucceeded = false; sName = ""; + idVendor = 0; + sVendor = ""; + sProduct = ""; }; int iBus; int iPort; @@ -29,9 +32,11 @@ struct UsbStorageDevice bool bNeedsWriteTest; bool bWriteTestSucceeded; // only valid if bNeedsWriteTest == false CString sName; // Name in the profile on the memory card. + int idVendor; + CString sVendor; + CString sProduct; - bool IsBlank() const { return sOsMountDir.empty(); } - void SetOsMountDir( const CString &s ); + bool IsBlank() { return sOsMountDir.empty(); } bool operator==(const UsbStorageDevice& other) const; }; diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp index 3ce8b8b515..0ac8b051fa 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp @@ -334,6 +334,43 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate() CHECKPOINT; } +static const int g_iAllowedVendorIds[] = + { + 0x0781, // SanDisk Corp. + 0x045a, // Diamond Multimedia Systems (Rio) + 0x04e8, // Samsung Electronics Co., Ltd. (Kingston) + 0x05dc, // Lexar Media, Inc. + }; +static const CString g_sAllowedVendorRegex[] = + { + "Kingston", + "KINGSTON", + }; +bool IsDeviceAllowed( int idVendor, CString sVendor, CString sProduct ) +{ + bool bAllowed = false; + + vector vAllowedVendorIds( &g_iAllowedVendorIds[0], &g_iAllowedVendorIds[ARRAYSIZE(g_iAllowedVendorIds)-1] ); + vector::const_iterator iter = find( vAllowedVendorIds.begin(), vAllowedVendorIds.end(), idVendor ); + bAllowed = iter != vAllowedVendorIds.end(); + + if( !bAllowed ) + { + for( int i=0; iTrace( "Device '%X':'%s':'%s' is %sallowed.", idVendor, sVendor.c_str(), sProduct.c_str(), bAllowed?"":"not " ); + return bAllowed; +} + bool ReadUsbStorageDescriptor( CString fn, int iScsiIndex, vector& vDevicesOut ) { LOG->Trace( "ReadUsbStorageDescriptor %s", fn.c_str() ); @@ -355,11 +392,22 @@ bool ReadUsbStorageDescriptor( CString fn, int iScsiIndex, vectorTrace( "iScsiIndex: %d, iBus: %d, iLevel: %d, iPort: %d, sSerial: %s", - usbd.iScsiIndex, usbd.iBus, usbd.iLevel, usbd.iPort, usbd.sSerial.c_str() ); + usbd.sVendor = sVendor; + usbd.sProduct = sProduct; + sVendor = ""; + sProduct = ""; + LOG->Trace( "iScsiIndex: %d, iBus: %d, iLevel: %d, iPort: %d, sSerial: %s, sVendor: %s, sProduct: %s", + usbd.iScsiIndex, usbd.iBus, usbd.iLevel, usbd.iPort, usbd.sSerial.c_str(), usbd.sVendor.c_str(), usbd.sProduct.c_str() ); break; // done looking for the corresponding device. - } + } } break; // we already found the line we care about } @@ -491,6 +543,15 @@ void GetNewStorageDevices( vector& vDevicesOut ) usbd.iPort = iPort; continue; // stop processing this line } + + // idVendor 0x0781 SanDisk Corp. + int idVendor; + iRet = sscanf( sLine.c_str(), " idVendor 0x%x", &idVendor ); + if( iRet == 1 ) + { + usbd.idVendor = idVendor; + continue; // stop processing this line + } // iSerial 3 1125198948886 char szSerial[1024];