summaryrefslogtreecommitdiffstats
path: root/rbutil
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2007-09-02 08:49:08 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2007-09-02 08:49:08 +0000
commit84f8f3dd1b4d9f4386f88b83860a200e259dfb2e (patch)
tree7961240490c0c8483c512504dfd34cb4df779a5d /rbutil
parent58b9a1221611308def32d48b2d6ca753e9836ae8 (diff)
downloadrockbox-84f8f3dd1b4d9f4386f88b83860a200e259dfb2e.tar.gz
rockbox-84f8f3dd1b4d9f4386f88b83860a200e259dfb2e.zip
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
Diffstat (limited to 'rbutil')
-rw-r--r--rbutil/rbutilqt/autodetection.cpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/rbutil/rbutilqt/autodetection.cpp b/rbutil/rbutilqt/autodetection.cpp
index 2300a1bba1..a359b91afd 100644
--- a/rbutil/rbutilqt/autodetection.cpp
+++ b/rbutil/rbutilqt/autodetection.cpp
@@ -19,6 +19,11 @@
#include "autodetection.h"
+#if defined(Q_OS_LINUX)
+#include <stdio.h>
+#include <mntent.h>
+#endif
+
Autodetection::Autodetection(QObject* parent): QObject(parent)
{
@@ -45,6 +50,7 @@ bool Autodetection::detect()
if(!log.value("platform").toString().isEmpty()) {
m_device = log.value("platform").toString();
m_mountpoint = mountpoints.at(i);
+ qDebug() << "rbutil.log detected:" << m_device << m_mountpoint;
return true;
}
}
@@ -58,14 +64,16 @@ bool Autodetection::detect()
if(line.startsWith("Target: "))
{
line.remove("Target: ");
- m_device = line;
+ m_device = line.trimmed(); // trim whitespaces
m_mountpoint = mountpoints.at(i);
+ qDebug() << "rockbox-info.txt detected:" << m_device << m_mountpoint;
return true;
}
}
}
}
+
int n;
//try ipodpatcher
@@ -129,25 +137,21 @@ QStringList Autodetection::getMountpoints()
QString Autodetection::resolveMountPoint(QString device)
{
qDebug() << "Autodetection::resolveMountPoint(QString)" << device;
+
#if defined(Q_OS_LINUX)
- FILE *fp = fopen( "/proc/mounts", "r" );
- if( !fp ) return QString("");
- char *dev, *dir;
- while( fscanf( fp, "%as %as %*s %*s %*s %*s", &dev, &dir ) != EOF )
- {
- if( QString(dev).startsWith(device) )
- {
- QString directory = dir;
- free( dev );
- free( dir );
- fclose(fp);
- return directory;
+ FILE *mn = setmntent("/etc/mtab", "r");
+ if(!mn)
+ return QString("");
+
+ struct mntent *ent;
+ while((ent = getmntent(mn))) {
+ if(QString(ent->mnt_fsname).startsWith(device)) {
+ endmntent(mn);
+ return QString(ent->mnt_dir);
}
- free( dev );
- free( dir );
}
- fclose( fp );
-
+ endmntent(mn);
+
#endif
return QString("");