HACK: Don't do the temp mount and the write test in the mount thread.

This commit is contained in:
Chris Danford
2004-10-09 09:34:30 +00:00
parent 47e2e2d48d
commit 269768f856
2 changed files with 22 additions and 5 deletions
@@ -124,7 +124,7 @@ bool MemoryCardDriverThreaded::MountAndTestWrite( UsbStorageDevice* pDevice, CSt
return false; return false;
this->Mount( pDevice, sMountPoint ); this->Mount( pDevice, sMountPoint );
return true; return pDevice->bWriteTestSucceeded;
} }
@@ -220,8 +220,11 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
else else
{ {
if( !UsbStorageDevicesChanged() ) if( !UsbStorageDevicesChanged() )
{
usleep(1000*300); // 300 ms
return; return;
} }
}
// TRICKY: We're waiting for a change in the USB device list, but // TRICKY: We're waiting for a change in the USB device list, but
// the usb-storage descriptors take a bit longer to update. It's more convenient to wait // the usb-storage descriptors take a bit longer to update. It's more convenient to wait
@@ -272,7 +275,15 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
bool bDidAnyMounts = false; bool bDidAnyMounts = false;
// unmount all disconnects // unmount all disconnects
if( ShouldDoOsMount() ) //if( ShouldDoOsMount() )
for( unsigned i=0; i<m_vDevicesLastSeen.size(); i++ )
{
UsbStorageDevice &d = m_vDevicesLastSeen[i];
d.bNeedsWriteTest = false;
d.bWriteTestSucceeded = true;
}
if( false )
{ {
for( unsigned i=0; i<vDisconnects.size(); i++ ) for( unsigned i=0; i<vDisconnects.size(); i++ )
{ {
@@ -294,6 +305,8 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
d.bNeedsWriteTest = false; d.bNeedsWriteTest = false;
d.bWriteTestSucceeded = true;
CString sCommand; CString sCommand;
// unmount this device before trying to mount it. If this device // unmount this device before trying to mount it. If this device
@@ -770,7 +783,11 @@ void MemoryCardDriverThreaded_Linux::Mount( UsbStorageDevice* pDevice, CString s
// HACK: Do OS mount for m_bMemoryCardsMountOnlyWhenNecessary // HACK: Do OS mount for m_bMemoryCardsMountOnlyWhenNecessary
CString sCommand = "mount " + pDevice->sOsMountDir; CString sCommand = "mount " + pDevice->sOsMountDir;
LOG->Trace( "hack mount (%s)", sCommand.c_str() ); LOG->Trace( "hack mount (%s)", sCommand.c_str() );
ExecuteCommand( sCommand ); bool bMountedSuccessfully = ExecuteCommand( sCommand );
pDevice->bWriteTestSucceeded = bMountedSuccessfully && TestWrite( pDevice->sOsMountDir );
LOG->Trace( "WriteTest: %s, Name: %s", pDevice->bWriteTestSucceeded ? "succeeded" : "failed", pDevice->sName.c_str() );
} }
void MemoryCardDriverThreaded_Linux::Unmount( UsbStorageDevice* pDevice, CString sMountPoint ) void MemoryCardDriverThreaded_Linux::Unmount( UsbStorageDevice* pDevice, CString sMountPoint )