OSX: fix unmounting drives that have APFS volumes

- If a drive is formatted APFS it will have a seperate disk
devices for physical drive (e.g. /dev/disk2) and volumes
(e.g. /dev/disk3).
Need to unmount all, or opening the device for
writing will subsequently fail.
(User will see an "Error running authopen" error in Imager
in that case).

- Also do not show APFS volumes seperately in the disk
selection dialog. List mount points under physical drive
instead.

Closes #501
This commit is contained in:
Floris Bos 2022-11-07 03:36:32 +01:00
parent 9d4665dbca
commit 30225187bd
5 changed files with 100 additions and 4 deletions

View file

@ -111,12 +111,29 @@ QByteArray DownloadThread::_fileGetContentsTrimmed(const QString &filename)
bool DownloadThread::_openAndPrepareDevice()
{
emit preparationStatusUpdate(tr("opening drive"));
if (_filename.startsWith("/dev/"))
{
emit preparationStatusUpdate(tr("unmounting drive"));
#ifdef Q_OS_DARWIN
/* Also unmount any APFS volumes using this physical disk */
auto l = Drivelist::ListStorageDevices();
for (const auto &i : l)
{
if (QByteArray::fromStdString(i.device) == _filename)
{
for (const auto &j : i.childDevices)
{
qDebug() << "Unmounting APFS volume:" << j.c_str();
unmount_disk(j.c_str());
}
break;
}
}
#endif
qDebug() << "Unmounting:" << _filename;
unmount_disk(_filename.constData());
}
emit preparationStatusUpdate(tr("opening drive"));
_file.setFileName(_filename);