diff --git a/src/backend/corebackenddevice.cpp b/src/backend/corebackenddevice.cpp index d93fed0..0674c0d 100644 --- a/src/backend/corebackenddevice.cpp +++ b/src/backend/corebackenddevice.cpp @@ -17,8 +17,8 @@ #include "backend/corebackenddevice.h" -CoreBackendDevice::CoreBackendDevice(const QString& device_node) : - m_DeviceNode(device_node), +CoreBackendDevice::CoreBackendDevice(const QString& deviceNode) : + m_DeviceNode(deviceNode), m_Exclusive(false) { } diff --git a/src/backend/corebackenddevice.h b/src/backend/corebackenddevice.h index 116f46d..2928b0c 100644 --- a/src/backend/corebackenddevice.h +++ b/src/backend/corebackenddevice.h @@ -40,7 +40,7 @@ class Report; class LIBKPMCORE_EXPORT CoreBackendDevice { public: - CoreBackendDevice(const QString& device_node); + CoreBackendDevice(const QString& deviceNode); virtual ~CoreBackendDevice() {} public: diff --git a/src/plugins/dummy/dummydevice.cpp b/src/plugins/dummy/dummydevice.cpp index ebd00eb..92c2de7 100644 --- a/src/plugins/dummy/dummydevice.cpp +++ b/src/plugins/dummy/dummydevice.cpp @@ -23,8 +23,8 @@ #include "util/globallog.h" #include "util/report.h" -DummyDevice::DummyDevice(const QString& device_node) : - CoreBackendDevice(device_node) +DummyDevice::DummyDevice(const QString& deviceNode) : + CoreBackendDevice(deviceNode) { } diff --git a/src/plugins/dummy/dummydevice.h b/src/plugins/dummy/dummydevice.h index 3810fe1..9493365 100644 --- a/src/plugins/dummy/dummydevice.h +++ b/src/plugins/dummy/dummydevice.h @@ -33,7 +33,7 @@ class DummyDevice : public CoreBackendDevice Q_DISABLE_COPY(DummyDevice) public: - DummyDevice(const QString& device_node); + DummyDevice(const QString& deviceNode); ~DummyDevice(); public: diff --git a/src/plugins/sfdisk/sfdiskbackend.cpp b/src/plugins/sfdisk/sfdiskbackend.cpp index 4b96f07..addd96c 100644 --- a/src/plugins/sfdisk/sfdiskbackend.cpp +++ b/src/plugins/sfdisk/sfdiskbackend.cpp @@ -365,7 +365,7 @@ PartitionTable::Flags SfdiskBackend::availableFlags(PartitionTable::TableType ty CoreBackendDevice* SfdiskBackend::openDevice(const Device& d) { - SfdiskDevice* device = new SfdiskDevice(d.deviceNode()); + SfdiskDevice* device = new SfdiskDevice(d); if (device == nullptr || !device->open()) { delete device; @@ -377,7 +377,7 @@ CoreBackendDevice* SfdiskBackend::openDevice(const Device& d) CoreBackendDevice* SfdiskBackend::openDeviceExclusive(const Device& d) { - SfdiskDevice* device = new SfdiskDevice(d.deviceNode()); + SfdiskDevice* device = new SfdiskDevice(d); if (device == nullptr || !device->openExclusive()) { delete device; diff --git a/src/plugins/sfdisk/sfdiskdevice.cpp b/src/plugins/sfdisk/sfdiskdevice.cpp index c8d816e..f373df7 100644 --- a/src/plugins/sfdisk/sfdiskdevice.cpp +++ b/src/plugins/sfdisk/sfdiskdevice.cpp @@ -23,9 +23,9 @@ #include "util/externalcommand.h" #include "util/report.h" -SfdiskDevice::SfdiskDevice(const QString& deviceNode) : - CoreBackendDevice(deviceNode), - m_deviceNode(deviceNode) +SfdiskDevice::SfdiskDevice(const Device& d) : + CoreBackendDevice(d.deviceNode()), + m_device(&d) { } @@ -55,7 +55,7 @@ bool SfdiskDevice::close() CoreBackendPartitionTable* SfdiskDevice::openPartitionTable() { - CoreBackendPartitionTable* ptable = new SfdiskPartitionTable(m_deviceNode); + CoreBackendPartitionTable* ptable = new SfdiskPartitionTable(m_device); if (ptable == nullptr || !ptable->open()) { delete ptable; @@ -73,7 +73,7 @@ bool SfdiskDevice::createPartitionTable(Report& report, const PartitionTable& pt else tableType = ptable.typeName().toLocal8Bit(); - ExternalCommand createCommand(report, QStringLiteral("sfdisk"), { m_deviceNode } ); + ExternalCommand createCommand(report, QStringLiteral("sfdisk"), { m_device->deviceNode() } ); if ( createCommand.start(-1) && createCommand.write(QByteArrayLiteral("label: ") + tableType + QByteArrayLiteral("\nwrite\n")) && createCommand.waitFor() ) { return createCommand.output().contains(QStringLiteral("Script header accepted.")); @@ -92,7 +92,7 @@ bool SfdiskDevice::readData(QByteArray& buffer, qint64 offset, qint64 size) QStringLiteral("bs=") + QString::number(size), QStringLiteral("count=1"), QStringLiteral("iflag=skip_bytes"), - QStringLiteral("if=") + m_deviceNode }, QProcess::SeparateChannels); + QStringLiteral("if=") + m_device->deviceNode() }, QProcess::SeparateChannels); if (ddCommand.run(-1) && ddCommand.exitCode() == 0) { buffer = ddCommand.rawOutput(); return true; @@ -107,7 +107,7 @@ bool SfdiskDevice::writeData(QByteArray& buffer, qint64 offset) return false; ExternalCommand ddCommand(QStringLiteral("dd"), { - QStringLiteral("of=") + m_deviceNode, + QStringLiteral("of=") + m_device->deviceNode(), QStringLiteral("seek=") + QString::number(offset), QStringLiteral("bs=1M"), QStringLiteral("oflag=seek_bytes"), diff --git a/src/plugins/sfdisk/sfdiskdevice.h b/src/plugins/sfdisk/sfdiskdevice.h index daf0108..aeab327 100644 --- a/src/plugins/sfdisk/sfdiskdevice.h +++ b/src/plugins/sfdisk/sfdiskdevice.h @@ -20,6 +20,7 @@ #define SFDISKDEVICE__H #include "backend/corebackenddevice.h" +#include "core/device.h" #include @@ -33,7 +34,7 @@ class SfdiskDevice : public CoreBackendDevice Q_DISABLE_COPY(SfdiskDevice); public: - SfdiskDevice(const QString& deviceNode); + SfdiskDevice(const Device& d); ~SfdiskDevice(); public: @@ -49,7 +50,7 @@ public: bool writeData(QByteArray& buffer, qint64 offset) override; private: - QString m_deviceNode; + const Device *m_device; }; #endif diff --git a/src/plugins/sfdisk/sfdiskpartitiontable.cpp b/src/plugins/sfdisk/sfdiskpartitiontable.cpp index e2ceeaf..27ee0dd 100644 --- a/src/plugins/sfdisk/sfdiskpartitiontable.cpp +++ b/src/plugins/sfdisk/sfdiskpartitiontable.cpp @@ -37,9 +37,9 @@ #include -SfdiskPartitionTable::SfdiskPartitionTable(const QString& deviceNode) : +SfdiskPartitionTable::SfdiskPartitionTable(const Device* d) : CoreBackendPartitionTable(), - m_deviceNode(deviceNode) + m_device(d) { } @@ -83,7 +83,7 @@ QString SfdiskPartitionTable::createPartition(Report& report, const Partition& p return partition.devicePath() + rem.captured(1); } - report.line() << xi18nc("@info:progress", "Failed to add partition %1 to device %2.", partition.deviceNode(), m_deviceNode); + report.line() << xi18nc("@info:progress", "Failed to add partition %1 to device %2.", partition.deviceNode(), m_device->deviceNode()); return QString(); } @@ -167,20 +167,20 @@ bool SfdiskPartitionTable::setPartitionSystemType(Report& report, const Partitio bool SfdiskPartitionTable::setFlag(Report& report, const Partition& partition, PartitionTable::Flag flag, bool state) { if (flag == PartitionTable::FlagBoot && state == true) { - ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--activate"), m_deviceNode, QString::number(partition.number()) } ); + ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--activate"), m_device->deviceNode(), QString::number(partition.number()) } ); if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0) return true; else return false; } else if (flag == PartitionTable::FlagBoot && state == false) { - ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--activate"), m_deviceNode, QStringLiteral("-") } ); + ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--activate"), m_device->deviceNode(), QStringLiteral("-") } ); if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0) return true; // FIXME: Do not return false since we have no way of checking if partition table is MBR } if (flag == PartitionTable::FlagEsp && state == true) { - ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--part-type"), m_deviceNode, QString::number(partition.number()), + ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--part-type"), m_device->deviceNode(), QString::number(partition.number()), QStringLiteral("C12A7328-F81F-11D2-BA4B-00A0C93EC93B") } ); if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0) return true; @@ -191,7 +191,7 @@ bool SfdiskPartitionTable::setFlag(Report& report, const Partition& partition, P setPartitionSystemType(report, partition); if (flag == PartitionTable::FlagBiosGrub && state == true) { - ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--part-type"), m_deviceNode, QString::number(partition.number()), + ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--part-type"), m_device->deviceNode(), QString::number(partition.number()), QStringLiteral("21686148-6449-6E6F-744E-656564454649") } ); if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0) return true; diff --git a/src/plugins/sfdisk/sfdiskpartitiontable.h b/src/plugins/sfdisk/sfdiskpartitiontable.h index 11e2f03..9d0de1e 100644 --- a/src/plugins/sfdisk/sfdiskpartitiontable.h +++ b/src/plugins/sfdisk/sfdiskpartitiontable.h @@ -32,7 +32,7 @@ class Partition; class SfdiskPartitionTable : public CoreBackendPartitionTable { public: - SfdiskPartitionTable(const QString& deviceNode); + SfdiskPartitionTable(const Device *d); ~SfdiskPartitionTable(); public: @@ -50,7 +50,7 @@ public: bool setFlag(Report& report, const Partition& partition, PartitionTable::Flag flag, bool state) override; private: - QString m_deviceNode; + const Device *m_device; }; #endif