summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/base/autodetection.cpp
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2010-02-20 22:46:58 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2010-02-20 22:46:58 +0000
commitb1cc087a6718c027a7d34fde503d3378b753e086 (patch)
tree7f15f50fec89bbf888da16f5e79ac5b7ec3ee7a0 /rbutil/rbutilqt/base/autodetection.cpp
parent7709113b6a13bc77d17bacaa743a8b628305cd0c (diff)
downloadrockbox-b1cc087a6718c027a7d34fde503d3378b753e086.tar.gz
rockbox-b1cc087a6718c027a7d34fde503d3378b753e086.tar.bz2
rockbox-b1cc087a6718c027a7d34fde503d3378b753e086.zip
Be more strict when when resolving devices and allow hfs too.
On OS X HFS is a valid filesystem on an Ipod. When resolving device node to mountpoints and vice versa also check mounts of hfs partitions. This results in trying to install the bootloader on a MacPod to show the (intended) MacPod warning instead of failing with a "could not open ipod" error because no valid device node could be retrieved. Also, be more strict on matching to prevent problems with one name being a subset of another. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24802 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/base/autodetection.cpp')
-rw-r--r--rbutil/rbutilqt/base/autodetection.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp
index 8e91dc32b1..bafa88d8bf 100644
--- a/rbutil/rbutilqt/base/autodetection.cpp
+++ b/rbutil/rbutilqt/base/autodetection.cpp
@@ -265,8 +265,11 @@ QString Autodetection::resolveMountPoint(QString device)
struct mntent *ent;
while((ent = getmntent(mn))) {
- if(QString(ent->mnt_fsname).startsWith(device)
- && QString(ent->mnt_type).contains("vfat", Qt::CaseInsensitive)) {
+ // Check for valid filesystem. Allow hfs too, as an Ipod might be a
+ // MacPod.
+ if(QString(ent->mnt_fsname) == device
+ && (QString(ent->mnt_type).contains("vfat", Qt::CaseInsensitive)
+ || QString(ent->mnt_type).contains("hfs", Qt::CaseInsensitive))) {
endmntent(mn);
qDebug() << "[Autodetect] resolved mountpoint is:" << ent->mnt_dir;
return QString(ent->mnt_dir);
@@ -282,8 +285,11 @@ QString Autodetection::resolveMountPoint(QString device)
num = getmntinfo(&mntinf, MNT_WAIT);
while(num--) {
- if(QString(mntinf->f_mntfromname).startsWith(device)
- && QString(mntinf->f_fstypename).contains("msdos", Qt::CaseInsensitive)) {
+ // Check for valid filesystem. Allow hfs too, as an Ipod might be a
+ // MacPod.
+ if(QString(mntinf->f_mntfromname) == device
+ && (QString(mntinf->f_fstypename).contains("msdos", Qt::CaseInsensitive)
+ || QString(mntinf->f_fstypename).contains("hfs", Qt::CaseInsensitive))) {
qDebug() << "[Autodetect] resolved mountpoint is:" << mntinf->f_mntonname;
return QString(mntinf->f_mntonname);
}
@@ -324,8 +330,13 @@ QString Autodetection::resolveDevicename(QString path)
struct mntent *ent;
while((ent = getmntent(mn))) {
- if(QString(ent->mnt_dir).startsWith(path)
- && QString(ent->mnt_type).contains("vfat", Qt::CaseInsensitive)) {
+ // check for valid filesystem type.
+ // Linux can handle hfs (and hfsplus), so consider it a valid file
+ // system. Otherwise resolving the device name would fail, which in
+ // turn would make it impossible to warn about a MacPod.
+ if(QString(ent->mnt_dir) == path
+ && (QString(ent->mnt_type).contains("vfat", Qt::CaseInsensitive)
+ || QString(ent->mnt_type).contains("hfs", Qt::CaseInsensitive))) {
endmntent(mn);
qDebug() << "[Autodetect] device name is" << ent->mnt_fsname;
return QString(ent->mnt_fsname);
@@ -341,8 +352,11 @@ QString Autodetection::resolveDevicename(QString path)
num = getmntinfo(&mntinf, MNT_WAIT);
while(num--) {
- if(QString(mntinf->f_mntonname).startsWith(path)
- && QString(mntinf->f_fstypename).contains("msdos", Qt::CaseInsensitive)) {
+ // check for valid filesystem type. OS X can handle hfs (hfs+ is
+ // treated as hfs), BSD should be the same.
+ if(QString(mntinf->f_mntonname) == path
+ && (QString(mntinf->f_fstypename).contains("msdos", Qt::CaseInsensitive)
+ || QString(mntinf->f_fstypename).contains("hfs", Qt::CaseInsensitive))) {
qDebug() << "[Autodetect] device name is" << mntinf->f_mntfromname;
return QString(mntinf->f_mntfromname);
}