Handle device name resolving failures.

Improve tracing of device name resolving. Explicitly fail if resolving the
device name from the mountpoint failed during ipod / sansa bootloader
installation. Fixes bootloader installation trying to use an empty device name
in some cases which can happen if the mountpoint to get resolved uses an
incompatible file system.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25743 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dominik Riebeling 2010-04-27 21:43:14 +00:00
parent b6e1f1c0ad
commit 34e60dde60
3 changed files with 18 additions and 11 deletions

View file

@ -339,13 +339,14 @@ QString Autodetection::resolveMountPoint(QString device)
for(letter = 'A'; letter <= 'Z'; letter++) {
if(resolveDevicename(QString(letter)).toUInt() == driveno) {
result = letter;
qDebug() << "[Autodetect] resolved mountpoint is:" << result;
break;
}
}
qDebug() << "[Autodetect] resolved mountpoint is:" << result;
if(!result.isEmpty())
return result + ":/";
#endif
qDebug() << "[Autodetect] resolving mountpoint failed!";
return QString("");
}

View file

@ -226,17 +226,19 @@ BootloaderInstallBase::Capabilities BootloaderInstallIpod::capabilities(void)
bool BootloaderInstallIpod::ipodInitialize(struct ipod_t *ipod)
{
if(!m_blfile.isEmpty()) {
QString devicename = Autodetection::resolveDevicename(m_blfile);
if(devicename.isEmpty()) {
emit logItem(tr("Error: could not retrieve device name"), LOGERROR);
return false;
}
#if defined(Q_OS_WIN32)
sprintf(ipod->diskname, "\\\\.\\PhysicalDrive%i",
Autodetection::resolveDevicename(m_blfile).toInt());
sprintf(ipod->diskname, "\\\\.\\PhysicalDrive%i", diskname.toInt());
#elif defined(Q_OS_MACX)
sprintf(ipod->diskname, "%s",
qPrintable(Autodetection::resolveDevicename(m_blfile)
.remove(QRegExp("s[0-9]+$"))));
qPrintable(devicename.remove(QRegExp("s[0-9]+$"))));
#else
sprintf(ipod->diskname, "%s",
qPrintable(Autodetection::resolveDevicename(m_blfile)
.remove(QRegExp("[0-9]+$"))));
qPrintable(devicename.remove(QRegExp("[0-9]+$"))));
#endif
qDebug() << "[BootloaderInstallIpod] ipodpatcher: overriding scan, using"
<< ipod->diskname;

View file

@ -242,15 +242,19 @@ BootloaderInstallBase::BootloaderType BootloaderInstallSansa::installed(void)
bool BootloaderInstallSansa::sansaInitialize(struct sansa_t *sansa)
{
if(!m_blfile.isEmpty()) {
QString devicename = Autodetection::resolveDevicename(m_blfile);
if(devicename.isEmpty()) {
emit logItem(tr("Error: could not retrieve device name"), LOGERROR);
return false;
}
#if defined(Q_OS_WIN32)
sprintf(sansa->diskname, "\\\\.\\PhysicalDrive%i",
Autodetection::resolveDevicename(m_blfile).toInt());
sprintf(sansa->diskname, "\\\\.\\PhysicalDrive%i", devicename.toInt());
#elif defined(Q_OS_MACX)
sprintf(sansa->diskname,
qPrintable(Autodetection::resolveDevicename(m_blfile).remove(QRegExp("s[0-9]+$"))));
qPrintable(devicename.remove(QRegExp("s[0-9]+$"))));
#else
sprintf(sansa->diskname,
qPrintable(Autodetection::resolveDevicename(m_blfile).remove(QRegExp("[0-9]+$"))));
qPrintable(devicename.remove(QRegExp("[0-9]+$"))));
#endif
qDebug() << "[BootloaderInstallSansa] sansapatcher: overriding scan, using"
<< sansa->diskname;