two commits from glenn; see changelog

This commit is contained in:
AJ Kelly
2010-07-17 23:29:40 -05:00
parent 9b609911a5
commit ce6ee088b7
2 changed files with 393 additions and 349 deletions
+9
View File
@@ -16,11 +16,20 @@ sm-ssc v1.0 Release Candidate 2 | 201007xx
20100717
--------
sm4svn:
* r28385: Fix memory card port handling on newer kernels. There's got to be a
better way to parse out a USB device's connection path. [Glenn Maynard]
* r28386: Fix partitioned USB devices not always being seen correctly due to
race condition with the kernel partition scan. The sleep was a hack to work
around this issue which doesn't work in all cases. [Glenn Maynard]
sm-ssc:
* Added Menu(Left/Right/Up/Down)(P1/P2) messages to ScreenOptions.
* [ScreenSelectMusic] Add ChangeStepsWithGameButtons, PreviousDifficultyButton,
and NextDifficultyButton metrics, allowing the themer to not have to use
CodeDetector. [Daisuke Master]
20100715
--------
* Fix spacing of various pump modes. [Daisuke Master]
@@ -3,6 +3,7 @@
#include "RageLog.h"
#include "RageUtil.h"
#include "RageFile.h"
#include "RageTimer.h"
#include <cerrno>
#include <fcntl.h>
@@ -129,27 +130,55 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
RString sPath = sBlockDevicePath + sDevice + "/";
usbd.sSysPath = sPath;
/* Ignore non-removable devices. */
// Ignore non-removable devices.
RString sBuf;
if( !ReadFile( sPath + "removable", sBuf ) )
continue; // already warned
if( atoi(sBuf) != 1 )
continue;
/* The kernel isn't exposing all of /sys atomically, so we end up missing
* the partition due to it not being shown yet. It won't show up until the
* kernel has scanned the partition table, which can take a variable amount
* of time, sometimes over a second. Watch for the "queue" sysfs directory,
* which is created after this, to tell when partition directories are created. */
RageTimer WaitUntil;
WaitUntil += 5;
RString sQueueFilePath = usbd.sSysPath + "queue";
while(1)
{
if( WaitUntil.Ago() >= 0 )
{
LOG->Warn( "Timed out waiting for %s", sQueueFilePath.c_str() );
break;
}
/* HACK: The kernel isn't exposing all of /sys atomically, so we end up
* missing the partition due to it not being shown yet. The kernel should
* be exposing all of this atomically. */
usleep(50000);
if( access(usbd.sSysPath, F_OK) == -1 )
{
LOG->Warn( "Block directory %s went away while we were waiting for %s",
usbd.sSysPath.c_str(), sQueueFilePath.c_str() );
break;
}
/* If the first partition device exists, eg. /sys/block/uba/uba1, use it. */
if( access(sQueueFilePath, F_OK) != -1 )
break;
usleep(10000);
}
// If the first partition device exists, eg. /sys/block/uba/uba1, use it.
if( access(usbd.sSysPath + sDevice + "1", F_OK) != -1 )
{
LOG->Trace("OK");
usbd.sDevice = "/dev/" + sDevice + "1";
}
else
{
LOG->Trace("error %s", strerror(errno));
usbd.sDevice = "/dev/" + sDevice;
}
/*
* sPath/device should be a symlink to the actual device. For USB
/* sPath/device should be a symlink to the actual device. For USB
* devices, it looks like this:
*
* device -> ../../devices/pci0000:00/0000:00:02.1/usb2/2-1/2-1:1.0
@@ -164,10 +193,11 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
}
else
{
/*
* The full path looks like
/* The full path looks like:
* ../../devices/pci0000:00/0000:00:02.1/usb2/2-2/2-2.1/2-2.1:1.0
*
* ../../devices/pci0000:00/0000:00:02.1/usb2/2-2/2-2.1/2-2.1:1.0
* In newer kernels, it looks like:
* ../../../3-2.1:1.0
*
* Each path element refers to a new hop in the chain.
* "usb2" = second USB host
@@ -177,15 +207,20 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
* .2 ... port 2 on the next hub ...
*
* We want the bus number and the port of the last hop. The level is
* the number of hops.
*/
* the number of hops. */
szLink[iRet] = 0;
vector<RString> asBits;
split( szLink, "/", asBits );
if( strstr( szLink, "usb" ) != NULL )
RString sHostPort = asBits[asBits.size()-1];
if( !sHostPort.empty() )
{
RString sHostPort = asBits[asBits.size()-2];
// Strip off the endpoint information after the colon.
size_t pos = sHostPort.find(':');
if( pos != string::npos )
sHostPort.erase( pos );
// sHostPort is eg. 2-2.1.
sHostPort.Replace( "-", "." );
asBits.clear();
split( sHostPort, ".", asBits );
@@ -282,7 +317,7 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
usbd.sProduct.c_str(), usbd.sSerial.c_str(), usbd.sOsMountDir.c_str() );
}
/* Remove any devices that we couldn't find a mountpoint for. */
// Remove any devices that we couldn't find a mountpoint for.
for( unsigned i=0; i<vDevicesOut.size(); i++ )
{
UsbStorageDevice& usbd = vDevicesOut[i];
@@ -303,8 +338,8 @@ bool MemoryCardDriverThreaded_Linux::Mount( UsbStorageDevice* pDevice )
{
ASSERT( !pDevice->sDevice.empty() );
RString sCommand = "mount " + pDevice->sDevice;
bool bMountedSuccessfully = ExecuteCommand( sCommand );
RString sCommand = "mount " + pDevice->sDevice;
bool bMountedSuccessfully = ExecuteCommand( sCommand );
return bMountedSuccessfully;
}