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:
Floris Bos 2023-03-30 16:26:26 +02:00
parent 9e882b31c4
commit 23b0bf6b32

View file

@ -250,12 +250,24 @@ void UDisks2Api::ejectDrive(const QString &device)
if (devpath.isEmpty())
return;
_unmountDrive(devpath);
::sync();
QDBusInterface blockdevice("org.freedesktop.UDisks2", devpath,
"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();
if (!drivepath.isEmpty() && drivepath != "/")
{
QDBusInterface drive("org.freedesktop.UDisks2", drivepath,