read memory card names in the mount thread
MemoryCardDrivers: fix Mount doesn't clear the right mount point before trying to mount
This commit is contained in:
@@ -41,6 +41,8 @@ public:
|
|||||||
|
|
||||||
bool PathIsMemCard( CString sDir ) const;
|
bool PathIsMemCard( CString sDir ) const;
|
||||||
|
|
||||||
|
CString GetName( PlayerNumber pn ) const { return m_Device[pn].sName; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AssignUnassignedCards(); // do our best to assign a Device to each player
|
void AssignUnassignedCards(); // do our best to assign a Device to each player
|
||||||
|
|
||||||
|
|||||||
@@ -133,21 +133,36 @@ bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn, bool bLoadNames
|
|||||||
// mount slot
|
// mount slot
|
||||||
if( MEMCARDMAN->GetCardState(pn) == MEMORY_CARD_STATE_READY )
|
if( MEMCARDMAN->GetCardState(pn) == MEMORY_CARD_STATE_READY )
|
||||||
{
|
{
|
||||||
CString sDir = MEM_CARD_MOUNT_POINT[pn];
|
if( bLoadNamesOnly )
|
||||||
|
{
|
||||||
|
CString sMemCardDir = MEM_CARD_MOUNT_POINT[pn];
|
||||||
|
CString sProfileDir = sMemCardDir + PREFSMAN->m_sMemoryCardProfileSubdir + '/';
|
||||||
|
|
||||||
// tack on a subdirectory so that we don't write everything to the root
|
m_sProfileDir[pn] = sProfileDir;
|
||||||
sDir += PREFSMAN->m_sMemoryCardProfileSubdir;
|
m_bWasLoadedFromMemoryCard[pn] = true;
|
||||||
sDir += '/';
|
|
||||||
|
|
||||||
bool bResult;
|
m_Profile[pn].InitAll();
|
||||||
bResult = LoadProfile( pn, sDir, true, bLoadNamesOnly );
|
m_Profile[pn].m_sDisplayName = MEMCARDMAN->GetName(pn);
|
||||||
if( bResult )
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CString sDir = MEM_CARD_MOUNT_POINT[pn];
|
||||||
|
|
||||||
CreateMemoryCardProfile( pn );
|
// tack on a subdirectory so that we don't write everything to the root
|
||||||
|
sDir += PREFSMAN->m_sMemoryCardProfileSubdir;
|
||||||
|
sDir += '/';
|
||||||
|
|
||||||
bResult = LoadProfile( pn, sDir, true, bLoadNamesOnly );
|
bool bResult;
|
||||||
return bResult;
|
bResult = LoadProfile( pn, sDir, true, bLoadNamesOnly );
|
||||||
|
if( bResult )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
CreateMemoryCardProfile( pn );
|
||||||
|
|
||||||
|
bResult = LoadProfile( pn, sDir, true, bLoadNamesOnly );
|
||||||
|
return bResult;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ struct UsbStorageDevice
|
|||||||
CString sSerial;
|
CString sSerial;
|
||||||
int iUsbStorageIndex;
|
int iUsbStorageIndex;
|
||||||
CString sOsMountDir; // WITHOUT trailing slash
|
CString sOsMountDir; // WITHOUT trailing slash
|
||||||
|
CString sName; // Name in the profile on the memory card.
|
||||||
|
// This is passed here because it's read in the mounting thread.
|
||||||
|
|
||||||
bool IsBlank() { return sOsMountDir.empty(); }
|
bool IsBlank() { return sOsMountDir.empty(); }
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "RageFileManager.h"
|
#include "RageFileManager.h"
|
||||||
|
#include "Profile.h"
|
||||||
|
#include "PrefsManager.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -13,6 +15,8 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
const CString TEMP_MOUNT_POINT = "@mctemp/";
|
||||||
|
|
||||||
static const char *USB_DEVICE_LIST_FILE = "/proc/bus/usb/devices";
|
static const char *USB_DEVICE_LIST_FILE = "/proc/bus/usb/devices";
|
||||||
static const char *ETC_MTAB = "/etc/mtab";
|
static const char *ETC_MTAB = "/etc/mtab";
|
||||||
|
|
||||||
@@ -144,6 +148,15 @@ void MemoryCardDriverThreaded_Linux::MountThreadMain()
|
|||||||
bool bMountedSuccessfully = ExecuteCommand( sCommand );
|
bool bMountedSuccessfully = ExecuteCommand( sCommand );
|
||||||
|
|
||||||
d.bWriteTestSucceeded = bMountedSuccessfully && TestWrite( d.sOsMountDir );
|
d.bWriteTestSucceeded = bMountedSuccessfully && TestWrite( d.sOsMountDir );
|
||||||
|
|
||||||
|
// read name
|
||||||
|
this->Mount( &usbd, TEMP_MOUNT_POINT );
|
||||||
|
FILEMAN->FlushDirCache( TEMP_MOUNT_POINT );
|
||||||
|
Profile profile;
|
||||||
|
CString sProfileDir = TEMP_MOUNT_POINT + PREFSMAN->m_sMemoryCardProfileSubdir + '/';
|
||||||
|
profile.LoadEditableDataFromDir( sProfileDir );
|
||||||
|
usbd.sName = profile.GetDisplayName();
|
||||||
|
|
||||||
LOG->Trace( "write test %s", d.bWriteTestSucceeded ? "succeeded" : "failed" );
|
LOG->Trace( "write test %s", d.bWriteTestSucceeded ? "succeeded" : "failed" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,8 +389,8 @@ void MemoryCardDriverThreaded_Linux::Mount( UsbStorageDevice* pDevice, CString s
|
|||||||
{
|
{
|
||||||
if( Mounts[i].Type.CompareNoCase( "dir" ) )
|
if( Mounts[i].Type.CompareNoCase( "dir" ) )
|
||||||
continue; // wrong type
|
continue; // wrong type
|
||||||
if( Mounts[i].Root.CompareNoCase( pDevice->sOsMountDir ) )
|
if( Mounts[i].MountPoint.CompareNoCase( sMountPoint ) )
|
||||||
continue; // wrong root
|
continue; // wrong mount point
|
||||||
FILEMAN->Unmount( Mounts[i].Type, Mounts[i].Root, Mounts[i].MountPoint );
|
FILEMAN->Unmount( Mounts[i].Type, Mounts[i].Root, Mounts[i].MountPoint );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,13 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "RageFileManager.h"
|
#include "RageFileManager.h"
|
||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
|
#include "Profile.h"
|
||||||
|
#include "PrefsManager.h"
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
const CString TEMP_MOUNT_POINT = "@mctemp/";
|
||||||
|
|
||||||
|
|
||||||
MemoryCardDriverThreaded_Windows::MemoryCardDriverThreaded_Windows()
|
MemoryCardDriverThreaded_Windows::MemoryCardDriverThreaded_Windows()
|
||||||
{
|
{
|
||||||
StartThread();
|
StartThread();
|
||||||
@@ -72,6 +77,15 @@ void MemoryCardDriverThreaded_Windows::MountThreadMain()
|
|||||||
UsbStorageDeviceEx usbd;
|
UsbStorageDeviceEx usbd;
|
||||||
usbd.sOsMountDir = sDrive;
|
usbd.sOsMountDir = sDrive;
|
||||||
usbd.bWriteTestSucceeded = TestWrite( sDrive );
|
usbd.bWriteTestSucceeded = TestWrite( sDrive );
|
||||||
|
|
||||||
|
// read name
|
||||||
|
this->Mount( &usbd, TEMP_MOUNT_POINT );
|
||||||
|
FILEMAN->FlushDirCache( TEMP_MOUNT_POINT );
|
||||||
|
Profile profile;
|
||||||
|
CString sProfileDir = TEMP_MOUNT_POINT + PREFSMAN->m_sMemoryCardProfileSubdir + '/';
|
||||||
|
profile.LoadEditableDataFromDir( sProfileDir );
|
||||||
|
usbd.sName = profile.GetDisplayName();
|
||||||
|
|
||||||
vNewStorageDevices.push_back( usbd );
|
vNewStorageDevices.push_back( usbd );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,8 +114,8 @@ void MemoryCardDriverThreaded_Windows::Mount( UsbStorageDevice* pDevice, CString
|
|||||||
{
|
{
|
||||||
if( Mounts[i].Type.CompareNoCase( "dir" ) )
|
if( Mounts[i].Type.CompareNoCase( "dir" ) )
|
||||||
continue; // wrong type
|
continue; // wrong type
|
||||||
if( Mounts[i].Root.CompareNoCase( pDevice->sOsMountDir ) )
|
if( Mounts[i].MountPoint.CompareNoCase( sMountPoint ) )
|
||||||
continue; // wrong root
|
continue; // wrong mount point
|
||||||
FILEMAN->Unmount( Mounts[i].Type, Mounts[i].Root, Mounts[i].MountPoint );
|
FILEMAN->Unmount( Mounts[i].Type, Mounts[i].Root, Mounts[i].MountPoint );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user