fix card readers with removable media fail to mount, but were used anyway
This commit is contained in:
@@ -46,6 +46,15 @@ static bool TestWrite( CCStringRef sDir )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool ExecuteCommand( CCStringRef sCommand )
|
||||||
|
{
|
||||||
|
LOG->Trace( "executing '%s'", sCommand.c_str() );
|
||||||
|
int ret = system(sCommand);
|
||||||
|
if( ret != 0 )
|
||||||
|
LOG->Warn( "failed to execute '%s' with error %d.", sCommand.c_str(), ret );
|
||||||
|
return ret == 0;
|
||||||
|
}
|
||||||
|
|
||||||
void MemoryCardDriverThreaded_Linux::MountThreadMain()
|
void MemoryCardDriverThreaded_Linux::MountThreadMain()
|
||||||
{
|
{
|
||||||
int fd = open(USB_DEVICE_LIST_FILE, O_RDONLY);
|
int fd = open(USB_DEVICE_LIST_FILE, O_RDONLY);
|
||||||
@@ -116,9 +125,7 @@ void MemoryCardDriverThreaded_Linux::MountThreadMain()
|
|||||||
{
|
{
|
||||||
UsbStorageDeviceEx &d = *vDisconnects[i];
|
UsbStorageDeviceEx &d = *vDisconnects[i];
|
||||||
CString sCommand = "umount " + d.sOsMountDir;
|
CString sCommand = "umount " + d.sOsMountDir;
|
||||||
LOG->Trace( "executing '%s'", sCommand.c_str() );
|
ExecuteCommand( sCommand );
|
||||||
if( system(sCommand) == -1 )
|
|
||||||
LOG->Warn( "failed to execute '%s'", sCommand.c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// mount all connects
|
// mount all connects
|
||||||
@@ -131,16 +138,12 @@ void MemoryCardDriverThreaded_Linux::MountThreadMain()
|
|||||||
// wasn't unmounted before, then our mount call will fail and the
|
// wasn't unmounted before, then our mount call will fail and the
|
||||||
// mount may contain an out-of-date view of the files on the device.
|
// mount may contain an out-of-date view of the files on the device.
|
||||||
sCommand = "umount " + d.sOsMountDir;
|
sCommand = "umount " + d.sOsMountDir;
|
||||||
LOG->Trace( "executing '%s'", sCommand.c_str() );
|
ExecuteCommand( sCommand ); // don't care if this fails
|
||||||
if( system(sCommand) == -1 )
|
|
||||||
LOG->Warn( "failed to execute '%s'", sCommand.c_str() );
|
|
||||||
|
|
||||||
sCommand = "mount " + d.sOsMountDir;
|
sCommand = "mount " + d.sOsMountDir;
|
||||||
LOG->Trace( "executing '%s'", sCommand.c_str() );
|
bool bMountedSuccessfully = ExecuteCommand( sCommand );
|
||||||
if( system(sCommand) == -1 )
|
|
||||||
LOG->Warn( "failed to execute '%s'", sCommand.c_str() );
|
|
||||||
|
|
||||||
d.bWriteTestSucceeded = TestWrite( d.sOsMountDir );
|
d.bWriteTestSucceeded = bMountedSuccessfully && TestWrite( d.sOsMountDir );
|
||||||
LOG->Trace( "write test %s", d.bWriteTestSucceeded ? "succeeded" : "failed" );
|
LOG->Trace( "write test %s", d.bWriteTestSucceeded ? "succeeded" : "failed" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,9 +383,6 @@ void MemoryCardDriverThreaded_Linux::Unmount( UsbStorageDevice* pDevice, CString
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// already unmounted by the mounting thread
|
// already unmounted by the mounting thread
|
||||||
//CString sCommand = "umount " + pDevice->sOsMountDir;
|
|
||||||
//LOG->Trace( "executing '%s'", sCommand.c_str() );
|
|
||||||
//system( sCommand );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryCardDriverThreaded_Linux::Flush( UsbStorageDevice* pDevice )
|
void MemoryCardDriverThreaded_Linux::Flush( UsbStorageDevice* pDevice )
|
||||||
@@ -395,22 +395,13 @@ void MemoryCardDriverThreaded_Linux::Flush( UsbStorageDevice* pDevice )
|
|||||||
// that the flush is completed on return. However, we can mount the filesystem
|
// that the flush is completed on return. However, we can mount the filesystem
|
||||||
// with the flag "-o sync", which forces synchronous access (but that's probably
|
// with the flag "-o sync", which forces synchronous access (but that's probably
|
||||||
// very slow.) -glenn
|
// very slow.) -glenn
|
||||||
CString sCommand = "mount -o remount " + pDevice->sOsMountDir;
|
ExecuteCommand( "mount -o remount " + pDevice->sOsMountDir );
|
||||||
LOG->Trace( "executing '%s'", sCommand.c_str() );
|
|
||||||
if( system(sCommand) == -1 )
|
|
||||||
LOG->Warn( "failed to execute '%s'", sCommand.c_str() );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryCardDriverThreaded_Linux::ResetUsbStorage()
|
void MemoryCardDriverThreaded_Linux::ResetUsbStorage()
|
||||||
{
|
{
|
||||||
CString sCommand;
|
ExecuteCommand( "rmmod usb-storage" );
|
||||||
sCommand = "rmmod usb-storage";
|
ExecuteCommand( "modprobe usb-storage" );
|
||||||
if( system(sCommand) == -1 )
|
|
||||||
LOG->Warn( "failed to execute '%s'", sCommand.c_str() );
|
|
||||||
sCommand = "modprobe usb-storage";
|
|
||||||
if( system(sCommand) == -1 )
|
|
||||||
LOG->Warn( "failed to execute '%s'", sCommand.c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user