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:
Chris Danford
2004-04-23 04:17:02 +00:00
parent 93e9377ea2
commit 82c910711c
5 changed files with 61 additions and 15 deletions
@@ -3,6 +3,8 @@
#include "RageLog.h"
#include "RageUtil.h"
#include "RageFileManager.h"
#include "Profile.h"
#include "PrefsManager.h"
#include <cstdio>
#include <cstring>
@@ -13,6 +15,8 @@
#include <fstream>
const CString TEMP_MOUNT_POINT = "@mctemp/";
static const char *USB_DEVICE_LIST_FILE = "/proc/bus/usb/devices";
static const char *ETC_MTAB = "/etc/mtab";
@@ -144,6 +148,15 @@ void MemoryCardDriverThreaded_Linux::MountThreadMain()
bool bMountedSuccessfully = ExecuteCommand( sCommand );
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" );
}
@@ -376,8 +389,8 @@ void MemoryCardDriverThreaded_Linux::Mount( UsbStorageDevice* pDevice, CString s
{
if( Mounts[i].Type.CompareNoCase( "dir" ) )
continue; // wrong type
if( Mounts[i].Root.CompareNoCase( pDevice->sOsMountDir ) )
continue; // wrong root
if( Mounts[i].MountPoint.CompareNoCase( sMountPoint ) )
continue; // wrong mount point
FILEMAN->Unmount( Mounts[i].Type, Mounts[i].Root, Mounts[i].MountPoint );
}