mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-18 07:55:21 +01:00
Linux udisks2: force kernel to rescan MBR before ejection
Otherwise it may still be doing it during ejection, resulting in read IO errors in dmesg, which are harmless by themselves but may confuse users. Also tell udisks2 not to analyze disk by setting 'HintAuto' property on BlockDevice object to 'false'
This commit is contained in:
parent
9e882b31c4
commit
23b0bf6b32
1 changed files with 15 additions and 3 deletions
|
@ -250,12 +250,24 @@ void UDisks2Api::ejectDrive(const QString &device)
|
||||||
if (devpath.isEmpty())
|
if (devpath.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_unmountDrive(devpath);
|
|
||||||
::sync();
|
|
||||||
|
|
||||||
QDBusInterface blockdevice("org.freedesktop.UDisks2", devpath,
|
QDBusInterface blockdevice("org.freedesktop.UDisks2", devpath,
|
||||||
"org.freedesktop.UDisks2.Block", QDBusConnection::systemBus());
|
"org.freedesktop.UDisks2.Block", QDBusConnection::systemBus());
|
||||||
|
|
||||||
|
bool hintAuto = blockdevice.property("HintAuto").toBool();
|
||||||
|
if (hintAuto)
|
||||||
|
{
|
||||||
|
qDebug() << "Deactivating auto-mount for" << device;
|
||||||
|
blockdevice.setProperty("HintAuto", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Force kernel to rescan partitions now. Otherwise it may still be doing it
|
||||||
|
while we are ejecting, resulting in read IO errors in dmesg */
|
||||||
|
QVariantMap rescanOptions;
|
||||||
|
blockdevice.call("Rescan", rescanOptions);
|
||||||
|
|
||||||
|
_unmountDrive(devpath);
|
||||||
QString drivepath = blockdevice.property("Drive").value<QDBusObjectPath>().path();
|
QString drivepath = blockdevice.property("Drive").value<QDBusObjectPath>().path();
|
||||||
|
|
||||||
if (!drivepath.isEmpty() && drivepath != "/")
|
if (!drivepath.isEmpty() && drivepath != "/")
|
||||||
{
|
{
|
||||||
QDBusInterface drive("org.freedesktop.UDisks2", drivepath,
|
QDBusInterface drive("org.freedesktop.UDisks2", drivepath,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue