This commit is contained in:
Chris Danford
2004-08-17 06:35:42 +00:00
parent 925c349d26
commit bac085dc6d
4 changed files with 52 additions and 112 deletions
@@ -4,7 +4,7 @@
#include "arch/arch_platform.h"
bool UsbStorageDevice::IdsMatch(const UsbStorageDevice& other) const
bool UsbStorageDevice::operator==(const UsbStorageDevice& other) const
{
// LOG->Trace( "Comparing %d %d %d %s %s to %d %d %d %s %s",
// iBus, iPort, iLevel, sName.c_str(), sOsMountDir.c_str(),
@@ -32,24 +32,7 @@ struct UsbStorageDevice
bool IsBlank() { return sOsMountDir.empty(); }
bool operator==(const UsbStorageDevice& other) const
{
#define COMPARE(x) if( x != other.x ) return false;
COMPARE( iBus );
COMPARE( iPort );
COMPARE( iLevel );
COMPARE( sSerial );
COMPARE( iScsiIndex );
COMPARE( sScsiDevice );
COMPARE( sOsMountDir );
COMPARE( sName );
COMPARE( bNeedsWriteTest );
COMPARE( bWriteTestSucceeded );
COMPARE( sOsMountDir );
#undef COMPARE
return true;
}
bool IdsMatch(const UsbStorageDevice& other) const;
bool operator==(const UsbStorageDevice& other) const;
};
class MemoryCardDriver
@@ -223,29 +223,15 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
vector<UsbStorageDevice> vDisconnects;
FOREACH( UsbStorageDevice, vOld, old )
{
bool bMatch = false;
FOREACH( UsbStorageDevice, vNew, newd )
{
if( old->IdsMatch(*newd) )
{
bMatch = true;
break;
}
}
if( !bMatch ) // didn't find
vector<UsbStorageDevice>::iterator iter = find( vNew.begin(), vNew.end(), *old );
if( iter == vNew.end() ) // didn't find
{
LOG->Trace( "Disconnected bus %d port %d level %d path %s", old->iBus, old->iPort, old->iLevel, old->sOsMountDir.c_str() );
vDisconnects.push_back( *old );
FOREACH( UsbStorageDevice, m_vDevicesLastSeen, d )
{
if( old->IdsMatch(*d) )
{
m_vDevicesLastSeen.erase( d );
break;
}
}
vector<UsbStorageDevice>::iterator iter = find( m_vDevicesLastSeen.begin(), m_vDevicesLastSeen.end(), *old );
ASSERT( iter != m_vDevicesLastSeen.end() );
m_vDevicesLastSeen.erase( iter );
}
}
@@ -254,17 +240,8 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
vector<UsbStorageDevice> vConnects;
FOREACH( UsbStorageDevice, vNew, newd )
{
bool bMatch = false;
FOREACH( UsbStorageDevice, vOld, old )
{
if( old->IdsMatch(*newd) )
{
bMatch = true;
break;
}
}
if( !bMatch ) // didn't find
vector<UsbStorageDevice>::iterator iter = find( vOld.begin(), vOld.end(), *newd );
if( iter == vOld.end() ) // didn't find
{
LOG->Trace( "Connected bus %d port %d level %d path %s", newd->iBus, newd->iPort, newd->iLevel, newd->sOsMountDir.c_str() );
vConnects.push_back( *newd );