MemoryCardDriverThreaded_Linux compiles (not yet tested)

This commit is contained in:
Glenn Maynard
2005-02-05 19:12:02 +00:00
parent c7434d29de
commit 76e45504a3
2 changed files with 20 additions and 22 deletions
@@ -62,15 +62,13 @@ static bool ExecuteCommand( CCStringRef sCommand )
MemoryCardDriverThreaded_Linux::MemoryCardDriverThreaded_Linux() MemoryCardDriverThreaded_Linux::MemoryCardDriverThreaded_Linux()
{ {
this->StartThread();
} }
MemoryCardDriverThreaded_Linux::~MemoryCardDriverThreaded_Linux() MemoryCardDriverThreaded_Linux::~MemoryCardDriverThreaded_Linux()
{ {
this->StopThread();
} }
void MemoryCardDriverThreaded_Linux::ResetUsbStorage() void MemoryCardDriverThreaded_Linux::Reset()
{ {
} }
@@ -147,7 +145,7 @@ static bool BlockDevicesChanged()
LOG->Trace( "Change in USB storage devices detected." ); LOG->Trace( "Change in USB storage devices detected." );
return bChanged; return bChanged;
} }
#if 0
bool MemoryCardDriverThreaded_Linux::MountThreadWaitForUpdate() bool MemoryCardDriverThreaded_Linux::MountThreadWaitForUpdate()
{ {
/* Check if any devices need a write test. */ /* Check if any devices need a write test. */
@@ -167,9 +165,12 @@ bool MemoryCardDriverThreaded_Linux::MountThreadWaitForUpdate()
usleep(1000*300); // 300 ms usleep(1000*300); // 300 ms
return false; return false;
} }
#endif
void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate() bool MemoryCardDriverThreaded_Linux::DoOneUpdate( bool bMount, vector<UsbStorageDevice>& vStorageDevicesOut )
{ {
if( !BlockDevicesChanged() )
return false;
vector<UsbStorageDevice> vNew; vector<UsbStorageDevice> vNew;
GetNewStorageDevices( vNew ); GetNewStorageDevices( vNew );
vector<UsbStorageDevice> vOld = m_vDevicesLastSeen; // copy vector<UsbStorageDevice> vOld = m_vDevicesLastSeen; // copy
@@ -272,12 +273,12 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
if( bDidAnyMounts || !vDisconnects.empty() || !vConnects.empty() ) if( bDidAnyMounts || !vDisconnects.empty() || !vConnects.empty() )
{ {
LockMut( m_mutexStorageDevices ); vStorageDevicesOut = m_vDevicesLastSeen;
m_bStorageDevicesChanged = true; return true;
m_vStorageDevices = m_vDevicesLastSeen;
} }
CHECKPOINT; CHECKPOINT;
return false;
} }
struct WhiteListEntry struct WhiteListEntry
@@ -516,11 +517,10 @@ void GetNewStorageDevices( vector<UsbStorageDevice>& vDevicesOut )
} }
void MemoryCardDriverThreaded_Linux::Mount( UsbStorageDevice* pDevice ) bool MemoryCardDriverThreaded_Linux::Mount( UsbStorageDevice* pDevice )
{ {
ASSERT( !pDevice->sOsMountDir.empty() ); ASSERT( !pDevice->sOsMountDir.empty() );
// 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() );
bool bMountedSuccessfully = ExecuteCommand( sCommand ); bool bMountedSuccessfully = ExecuteCommand( sCommand );
@@ -528,6 +528,8 @@ void MemoryCardDriverThreaded_Linux::Mount( UsbStorageDevice* pDevice )
pDevice->bWriteTestSucceeded = bMountedSuccessfully && TestWrite( pDevice->sOsMountDir ); pDevice->bWriteTestSucceeded = bMountedSuccessfully && TestWrite( pDevice->sOsMountDir );
LOG->Trace( "WriteTest: %s, Name: %s", pDevice->bWriteTestSucceeded ? "succeeded" : "failed", pDevice->sName.c_str() ); LOG->Trace( "WriteTest: %s, Name: %s", pDevice->bWriteTestSucceeded ? "succeeded" : "failed", pDevice->sName.c_str() );
return bMountedSuccessfully;
} }
void MemoryCardDriverThreaded_Linux::Unmount( UsbStorageDevice* pDevice ) void MemoryCardDriverThreaded_Linux::Unmount( UsbStorageDevice* pDevice )
@@ -535,9 +537,6 @@ void MemoryCardDriverThreaded_Linux::Unmount( UsbStorageDevice* pDevice )
if( pDevice->sOsMountDir.empty() ) if( pDevice->sOsMountDir.empty() )
return; return;
// already unmounted by the mounting thread
// HACK: Do OS unmount for m_bMemoryCardsMountOnlyWhenNecessary
CString sCommand = "umount " + pDevice->sOsMountDir; CString sCommand = "umount " + pDevice->sOsMountDir;
LOG->Trace( "hack unmount (%s)", sCommand.c_str() ); LOG->Trace( "hack unmount (%s)", sCommand.c_str() );
ExecuteCommand( sCommand ); ExecuteCommand( sCommand );
@@ -557,7 +556,7 @@ void MemoryCardDriverThreaded_Linux::Flush( UsbStorageDevice* pDevice )
} }
/* /*
* (c) 2003-2004 Chris Danford, Glenn Maynard * (c) 2003-2005 Chris Danford, Glenn Maynard
* All rights reserved. * All rights reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
@@ -1,22 +1,21 @@
#ifndef MemoryCardDriverThreaded_Linux_H #ifndef MemoryCardDriverThreaded_Linux_H
#define MemoryCardDriverThreaded_Linux_H 1 #define MemoryCardDriverThreaded_Linux_H 1
#include "MemoryCardDriverThreaded.h" #include "MemoryCardDriver.h"
class MemoryCardDriverThreaded_Linux : public MemoryCardDriverThreaded class MemoryCardDriverThreaded_Linux : public MemoryCardDriver
{ {
public: public:
MemoryCardDriverThreaded_Linux(); MemoryCardDriverThreaded_Linux();
virtual ~MemoryCardDriverThreaded_Linux(); virtual ~MemoryCardDriverThreaded_Linux();
virtual bool DoOneUpdate( bool bMount, vector<UsbStorageDevice>& vStorageDevicesOut );
virtual bool Mount( UsbStorageDevice* pDevice );
virtual void Unmount( UsbStorageDevice* pDevice ); virtual void Unmount( UsbStorageDevice* pDevice );
virtual void Flush( UsbStorageDevice* pDevice ); virtual void Flush( UsbStorageDevice* pDevice );
protected: virtual void Reset();
virtual void Mount( UsbStorageDevice* pDevice );
virtual void ResetUsbStorage();
virtual void MountThreadDoOneUpdate();
virtual bool MountThreadWaitForUpdate();
protected:
vector<UsbStorageDevice> m_vDevicesLastSeen; vector<UsbStorageDevice> m_vDevicesLastSeen;
}; };