From 984a4e9acee45dca1aa5bcc69294b536930a20c2 Mon Sep 17 00:00:00 2001 From: Harald Sitter Date: Wed, 28 Jun 2017 10:11:33 +0200 Subject: [PATCH] fix device RO check Summary: - mark deviceNode const - copy it as deviceName - mutate deviceName by removing `/dev/` - use the new deviceName for the read-only check this makes sure we emit the unmodified deviceNode (e.g. /dev/vda) rather than the name (e.g. vda). unbreaks for example calamares which doesn't know what to do with "vda". CCBUG: 378607 Test Plan: - without fix clamares fails to list devices - with the fix calamares lists devices Reviewers: stikonas Reviewed By: stikonas Differential Revision: https://phabricator.kde.org/D6414 --- src/plugins/libparted/libpartedbackend.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/libparted/libpartedbackend.cpp b/src/plugins/libparted/libpartedbackend.cpp index b6e1bb3..194f467 100644 --- a/src/plugins/libparted/libpartedbackend.cpp +++ b/src/plugins/libparted/libpartedbackend.cpp @@ -429,9 +429,11 @@ QList LibPartedBackend::scanDevices(bool excludeReadOnly) const QStringList output=cmd.output().split(QStringLiteral("\n")).filter(QRegularExpression(QStringLiteral("^disk "))); quint32 totalDevices = output.length(); for (quint32 i = 0; i < totalDevices; ++i) { - QString deviceNode = output[i].split(QStringLiteral(" ")).last(); + const QString deviceNode = output[i].split(QStringLiteral(" ")).last(); if (excludeReadOnly) { - QFile f(QStringLiteral("/sys/block/%1/ro").arg(deviceNode.remove(QStringLiteral("/dev/")))); + auto deviceName = deviceNode; + deviceName.remove(QStringLiteral("/dev/")); + QFile f(QStringLiteral("/sys/block/%1/ro").arg(deviceName)); if (f.open(QIODevice::ReadOnly)) if (f.readLine().trimmed().toInt() == 1) continue;