forked from len0rd/rockbox
Fix autodetection based on rockbox-info.txt which I broke when fixing X5 detection. Replace mountpoint detection to use getmntent api on linux.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14573 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
58b9a12216
commit
84f8f3dd1b
1 changed files with 22 additions and 18 deletions
|
|
@ -19,6 +19,11 @@
|
||||||
|
|
||||||
#include "autodetection.h"
|
#include "autodetection.h"
|
||||||
|
|
||||||
|
#if defined(Q_OS_LINUX)
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <mntent.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
Autodetection::Autodetection(QObject* parent): QObject(parent)
|
Autodetection::Autodetection(QObject* parent): QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -45,6 +50,7 @@ bool Autodetection::detect()
|
||||||
if(!log.value("platform").toString().isEmpty()) {
|
if(!log.value("platform").toString().isEmpty()) {
|
||||||
m_device = log.value("platform").toString();
|
m_device = log.value("platform").toString();
|
||||||
m_mountpoint = mountpoints.at(i);
|
m_mountpoint = mountpoints.at(i);
|
||||||
|
qDebug() << "rbutil.log detected:" << m_device << m_mountpoint;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -58,14 +64,16 @@ bool Autodetection::detect()
|
||||||
if(line.startsWith("Target: "))
|
if(line.startsWith("Target: "))
|
||||||
{
|
{
|
||||||
line.remove("Target: ");
|
line.remove("Target: ");
|
||||||
m_device = line;
|
m_device = line.trimmed(); // trim whitespaces
|
||||||
m_mountpoint = mountpoints.at(i);
|
m_mountpoint = mountpoints.at(i);
|
||||||
|
qDebug() << "rockbox-info.txt detected:" << m_device << m_mountpoint;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
//try ipodpatcher
|
//try ipodpatcher
|
||||||
|
|
@ -129,24 +137,20 @@ QStringList Autodetection::getMountpoints()
|
||||||
QString Autodetection::resolveMountPoint(QString device)
|
QString Autodetection::resolveMountPoint(QString device)
|
||||||
{
|
{
|
||||||
qDebug() << "Autodetection::resolveMountPoint(QString)" << device;
|
qDebug() << "Autodetection::resolveMountPoint(QString)" << device;
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
FILE *fp = fopen( "/proc/mounts", "r" );
|
FILE *mn = setmntent("/etc/mtab", "r");
|
||||||
if( !fp ) return QString("");
|
if(!mn)
|
||||||
char *dev, *dir;
|
return QString("");
|
||||||
while( fscanf( fp, "%as %as %*s %*s %*s %*s", &dev, &dir ) != EOF )
|
|
||||||
{
|
struct mntent *ent;
|
||||||
if( QString(dev).startsWith(device) )
|
while((ent = getmntent(mn))) {
|
||||||
{
|
if(QString(ent->mnt_fsname).startsWith(device)) {
|
||||||
QString directory = dir;
|
endmntent(mn);
|
||||||
free( dev );
|
return QString(ent->mnt_dir);
|
||||||
free( dir );
|
|
||||||
fclose(fp);
|
|
||||||
return directory;
|
|
||||||
}
|
}
|
||||||
free( dev );
|
|
||||||
free( dir );
|
|
||||||
}
|
}
|
||||||
fclose( fp );
|
endmntent(mn);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return QString("");
|
return QString("");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue