sysfs fixes
This commit is contained in:
@@ -101,7 +101,6 @@ static bool ReadFile( const CString &sPath, CString &sBuf )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG->Trace("got '%s'", sBuf.c_str());
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -261,17 +260,12 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
|
|||||||
// read name
|
// read name
|
||||||
this->Mount( &d, TEMP_MOUNT_POINT );
|
this->Mount( &d, TEMP_MOUNT_POINT );
|
||||||
FILEMAN->FlushDirCache( TEMP_MOUNT_POINT );
|
FILEMAN->FlushDirCache( TEMP_MOUNT_POINT );
|
||||||
#if 1
|
|
||||||
Profile profile;
|
Profile profile;
|
||||||
CString sProfileDir = TEMP_MOUNT_POINT + PREFSMAN->m_sMemoryCardProfileSubdir + '/';
|
CString sProfileDir = TEMP_MOUNT_POINT + PREFSMAN->m_sMemoryCardProfileSubdir + '/';
|
||||||
profile.LoadEditableDataFromDir( sProfileDir );
|
profile.LoadEditableDataFromDir( sProfileDir );
|
||||||
d.sName = profile.GetDisplayName();
|
d.sName = profile.GetDisplayName();
|
||||||
#else
|
|
||||||
/* XXX read a file anyway */
|
|
||||||
CString sProfileDir = TEMP_MOUNT_POINT + PREFSMAN->m_sMemoryCardProfileSubdir + '/';
|
|
||||||
|
|
||||||
d.sName = "foo";
|
|
||||||
#endif
|
|
||||||
UnmountMountPoint( TEMP_MOUNT_POINT );
|
UnmountMountPoint( TEMP_MOUNT_POINT );
|
||||||
|
|
||||||
LOG->Trace( "WriteTest: %s, Name: %s", d.bWriteTestSucceeded ? "succeeded" : "failed", d.sName.c_str() );
|
LOG->Trace( "WriteTest: %s, Name: %s", d.bWriteTestSucceeded ? "succeeded" : "failed", d.sName.c_str() );
|
||||||
@@ -377,25 +371,43 @@ void GetNewStorageDevices( vector<UsbStorageDevice>& vDevicesOut )
|
|||||||
* "2-1" is "bus-port".
|
* "2-1" is "bus-port".
|
||||||
*/
|
*/
|
||||||
char szLink[256];
|
char szLink[256];
|
||||||
if( readlink( sPath + "device", szLink, sizeof(szLink) ) == -1 )
|
int iRet = readlink( sPath + "device", szLink, sizeof(szLink) );
|
||||||
|
if( iRet == -1 )
|
||||||
{
|
{
|
||||||
// XXX warn
|
LOG->Warn( "readlink(\"%s\"): %s", (sPath + "device").c_str(), strerror(errno) );
|
||||||
}
|
}
|
||||||
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
|
||||||
|
*
|
||||||
|
* Each path element refers to a new hop in the chain.
|
||||||
|
* "usb2" = second USB host
|
||||||
|
* 2- second USB host,
|
||||||
|
* -2 port 1 on the host,
|
||||||
|
* .1 port 1 on an attached hub
|
||||||
|
* .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.
|
||||||
|
*/
|
||||||
|
szLink[iRet] = 0;
|
||||||
vector<CString> asBits;
|
vector<CString> asBits;
|
||||||
split( szLink, "/", asBits );
|
split( szLink, "/", asBits );
|
||||||
|
|
||||||
// const CString &sHostPort = asBits[asBits.size()-3];
|
if( strstr( szLink, "usb" ) != NULL )
|
||||||
if( asBits.size() > 3 && asBits[asBits.size()-3].Left(3) == "usb" )
|
|
||||||
{
|
{
|
||||||
CString sHostPort = asBits[asBits.size()-2];
|
CString sHostPort = asBits[asBits.size()-2];
|
||||||
|
sHostPort.Replace( "-", "." );
|
||||||
asBits.clear();
|
asBits.clear();
|
||||||
split( sHostPort, "-", asBits );
|
split( sHostPort, ".", asBits );
|
||||||
if( asBits.size() == 2 )
|
if( asBits.size() > 1 )
|
||||||
{
|
{
|
||||||
usbd.iBus = atoi(asBits[0]);
|
usbd.iBus = atoi( asBits[0] );
|
||||||
usbd.iPort = atoi(asBits[1]);
|
usbd.iPort = atoi( asBits[asBits.size()-1] );
|
||||||
|
usbd.iLevel = asBits.size() - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user