sm5svn sync: Fix compile on some systems. [Steve Checkoway]
This commit is contained in:
@@ -7,8 +7,8 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <linux/input.h>
|
||||
|
||||
REGISTER_INPUT_HANDLER_CLASS2( Event, Linux_Event );
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <linux/joystick.h>
|
||||
|
||||
#include <set>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <cerrno>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
bool MemoryCardDriverThreaded_Linux::TestWrite( UsbStorageDevice* pDevice )
|
||||
@@ -130,18 +131,20 @@ 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 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. */
|
||||
* which is created after this, to tell when partition directories are created.
|
||||
*/
|
||||
RageTimer WaitUntil;
|
||||
WaitUntil += 5;
|
||||
RString sQueueFilePath = usbd.sSysPath + "queue";
|
||||
@@ -166,7 +169,7 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
|
||||
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 )
|
||||
{
|
||||
LOG->Trace("OK");
|
||||
@@ -178,7 +181,8 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
|
||||
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
|
||||
@@ -193,10 +197,13 @@ 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
|
||||
*
|
||||
* In newer kernels, it looks like:
|
||||
*
|
||||
* ../../../3-2.1:1.0
|
||||
*
|
||||
* 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 ...
|
||||
*
|
||||
* 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 );
|
||||
@@ -215,12 +223,12 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
|
||||
RString sHostPort = asBits[asBits.size()-1];
|
||||
if( !sHostPort.empty() )
|
||||
{
|
||||
// Strip off the endpoint information after the colon.
|
||||
/* 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 is eg. 2-2.1. */
|
||||
sHostPort.Replace( "-", "." );
|
||||
asBits.clear();
|
||||
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() );
|
||||
}
|
||||
|
||||
// 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];
|
||||
|
||||
Reference in New Issue
Block a user