sm5svn sync: Fix compile on some systems. [Steve Checkoway]
This commit is contained in:
@@ -7,8 +7,8 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
|
|
||||||
REGISTER_INPUT_HANDLER_CLASS2( Event, Linux_Event );
|
REGISTER_INPUT_HANDLER_CLASS2( Event, Linux_Event );
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <linux/joystick.h>
|
#include <linux/joystick.h>
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
bool MemoryCardDriverThreaded_Linux::TestWrite( UsbStorageDevice* pDevice )
|
bool MemoryCardDriverThreaded_Linux::TestWrite( UsbStorageDevice* pDevice )
|
||||||
@@ -130,18 +131,20 @@ 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
|
* 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
|
* kernel has scanned the partition table, which can take a variable amount
|
||||||
* of time, sometimes over a second. Watch for the "queue" sysfs directory,
|
* of time, sometimes over a second. Watch for the "queue" sysfs directory,
|
||||||
* which is created after this, to tell when partition directories are created. */
|
* which is created after this, to tell when partition directories are created.
|
||||||
|
*/
|
||||||
RageTimer WaitUntil;
|
RageTimer WaitUntil;
|
||||||
WaitUntil += 5;
|
WaitUntil += 5;
|
||||||
RString sQueueFilePath = usbd.sSysPath + "queue";
|
RString sQueueFilePath = usbd.sSysPath + "queue";
|
||||||
@@ -166,7 +169,7 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
|
|||||||
usleep(10000);
|
usleep(10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the first partition device exists, eg. /sys/block/uba/uba1, use it.
|
/* 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");
|
LOG->Trace("OK");
|
||||||
@@ -178,7 +181,8 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
|
|||||||
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
|
||||||
@@ -193,10 +197,13 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* The full path looks like:
|
/*
|
||||||
* ../../devices/pci0000:00/0000:00:02.1/usb2/2-2/2-2.1/2-2.1:1.0
|
* The full path looks like
|
||||||
|
*
|
||||||
|
* ../../devices/pci0000:00/0000:00:02.1/usb2/2-2/2-2.1/2-2.1:1.0
|
||||||
*
|
*
|
||||||
* In newer kernels, it looks like:
|
* In newer kernels, it looks like:
|
||||||
|
*
|
||||||
* ../../../3-2.1:1.0
|
* ../../../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.
|
||||||
@@ -207,7 +214,8 @@ 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 );
|
||||||
@@ -215,12 +223,12 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
|
|||||||
RString sHostPort = asBits[asBits.size()-1];
|
RString sHostPort = asBits[asBits.size()-1];
|
||||||
if( !sHostPort.empty() )
|
if( !sHostPort.empty() )
|
||||||
{
|
{
|
||||||
// Strip off the endpoint information after the colon.
|
/* Strip off the endpoint information after the colon. */
|
||||||
size_t pos = sHostPort.find(':');
|
size_t pos = sHostPort.find(':');
|
||||||
if( pos != string::npos )
|
if( pos != string::npos )
|
||||||
sHostPort.erase( pos );
|
sHostPort.erase( pos );
|
||||||
|
|
||||||
// sHostPort is eg. 2-2.1.
|
/* sHostPort is eg. 2-2.1. */
|
||||||
sHostPort.Replace( "-", "." );
|
sHostPort.Replace( "-", "." );
|
||||||
asBits.clear();
|
asBits.clear();
|
||||||
split( sHostPort, ".", asBits );
|
split( sHostPort, ".", asBits );
|
||||||
@@ -317,7 +325,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];
|
||||||
@@ -338,8 +346,8 @@ bool MemoryCardDriverThreaded_Linux::Mount( UsbStorageDevice* pDevice )
|
|||||||
{
|
{
|
||||||
ASSERT( !pDevice->sDevice.empty() );
|
ASSERT( !pDevice->sDevice.empty() );
|
||||||
|
|
||||||
RString sCommand = "mount " + pDevice->sDevice;
|
RString sCommand = "mount " + pDevice->sDevice;
|
||||||
bool bMountedSuccessfully = ExecuteCommand( sCommand );
|
bool bMountedSuccessfully = ExecuteCommand( sCommand );
|
||||||
|
|
||||||
return bMountedSuccessfully;
|
return bMountedSuccessfully;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user