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 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. * Added Menu(Left/Right/Up/Down)(P1/P2) messages to ScreenOptions.
* [ScreenSelectMusic] Add ChangeStepsWithGameButtons, PreviousDifficultyButton, * [ScreenSelectMusic] Add ChangeStepsWithGameButtons, PreviousDifficultyButton,
and NextDifficultyButton metrics, allowing the themer to not have to use and NextDifficultyButton metrics, allowing the themer to not have to use
CodeDetector. [Daisuke Master] CodeDetector. [Daisuke Master]
20100715 20100715
-------- --------
* Fix spacing of various pump modes. [Daisuke Master] * Fix spacing of various pump modes. [Daisuke Master]
@@ -3,6 +3,7 @@
#include "RageLog.h" #include "RageLog.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "RageFile.h" #include "RageFile.h"
#include "RageTimer.h"
#include <cerrno> #include <cerrno>
#include <fcntl.h> #include <fcntl.h>
@@ -129,27 +130,55 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
RString sPath = sBlockDevicePath + sDevice + "/"; RString sPath = sBlockDevicePath + sDevice + "/";
usbd.sSysPath = sPath; usbd.sSysPath = sPath;
/* Ignore non-removable devices. */ // Ignore non-removable devices.
RString sBuf; RString sBuf;
if( !ReadFile( sPath + "removable", sBuf ) ) if( !ReadFile( sPath + "removable", sBuf ) )
continue; // already warned continue; // already warned
if( atoi(sBuf) != 1 ) if( atoi(sBuf) != 1 )
continue; 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 if( access(usbd.sSysPath, F_OK) == -1 )
* missing the partition due to it not being shown yet. The kernel should {
* be exposing all of this atomically. */ LOG->Warn( "Block directory %s went away while we were waiting for %s",
usleep(50000); 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 ) if( access(usbd.sSysPath + sDevice + "1", F_OK) != -1 )
{
LOG->Trace("OK");
usbd.sDevice = "/dev/" + sDevice + "1"; usbd.sDevice = "/dev/" + sDevice + "1";
}
else else
{
LOG->Trace("error %s", strerror(errno));
usbd.sDevice = "/dev/" + sDevice; 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: * devices, it looks like this:
* *
* device -> ../../devices/pci0000:00/0000:00:02.1/usb2/2-1/2-1:1.0 * device -> ../../devices/pci0000:00/0000:00:02.1/usb2/2-1/2-1:1.0
@@ -164,11 +193,12 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
} }
else 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. * Each path element refers to a new hop in the chain.
* "usb2" = second USB host * "usb2" = second USB host
* 2- second USB host, * 2- second USB host,
@@ -177,15 +207,20 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
* .2 ... port 2 on the next hub ... * .2 ... port 2 on the next hub ...
* *
* We want the bus number and the port of the last hop. The level is * 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; szLink[iRet] = 0;
vector<RString> asBits; vector<RString> asBits;
split( szLink, "/", 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( "-", "." ); sHostPort.Replace( "-", "." );
asBits.clear(); asBits.clear();
split( sHostPort, ".", asBits ); 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() ); 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++ ) for( unsigned i=0; i<vDevicesOut.size(); i++ )
{ {
UsbStorageDevice& usbd = vDevicesOut[i]; UsbStorageDevice& usbd = vDevicesOut[i];