Commit 43da873c authored by Caio Jordão Carvalho's avatar Caio Jordão Carvalho

Fixing device scanning process

parent 281289df
......@@ -45,6 +45,8 @@ class LIBKPMCORE_EXPORT LvmDevice : public VolumeManagerDevice
{
Q_DISABLE_COPY(LvmDevice)
friend class VolumeManagerDevice;
public:
LvmDevice(const QString& name, const QString& iconName = QString());
~LvmDevice();
......@@ -57,8 +59,6 @@ public:
static QVector<const Partition*> s_DirtyPVs;
static QVector<const Partition*> s_OrphanPVs;
static void scanSystemLVM(QList<Device*>& devices);
static const QStringList getVGs();
static const QStringList getLVs(const QString& vgName);
......@@ -105,6 +105,9 @@ public:
protected:
std::unique_ptr<QHash<QString, qint64>>& LVSizeMap() const;
private:
static void scanSystemLVM(QList<Device*>& devices);
};
#endif
......@@ -26,6 +26,8 @@ class LIBKPMCORE_EXPORT SoftwareRAID : public VolumeManagerDevice
{
Q_DISABLE_COPY(SoftwareRAID)
friend class VolumeManagerDevice;
public:
enum class Status {
Active,
......@@ -61,8 +63,6 @@ public:
void setStatus(SoftwareRAID::Status status);
public:
static void scanSoftwareRAID(QList<Device*>& devices);
static qint32 getRaidLevel(const QString& path);
static qint64 getChunkSize(const QString& path);
static qint64 getTotalChunk(const QString& path);
......@@ -95,6 +95,8 @@ protected:
qint64 mappedSector(const QString &partitionPath, qint64 sector) const override;
private:
static void scanSoftwareRAID(QList<Device*>& devices);
static QString getDetail(const QString& path);
static QString getRAIDConfiguration(const QString& configurationPath);
......
......@@ -19,6 +19,8 @@
#include "core/device_p.h"
#include "core/volumemanagerdevice.h"
#include "core/volumemanagerdevice_p.h"
#include "core/lvmdevice.h"
#include "core/raid/softwareraid.h"
/** Constructs an abstract Volume Manager Device with an empty PartitionTable.
*
......@@ -37,6 +39,12 @@ VolumeManagerDevice::VolumeManagerDevice(std::shared_ptr<VolumeManagerDevicePriv
{
}
void VolumeManagerDevice::scanDevices(QList<Device*>& devices)
{
SoftwareRAID::scanSoftwareRAID(devices);
LvmDevice::scanSystemLVM(devices); // LVM scanner needs all other devices, so should be last
}
QString VolumeManagerDevice::prettyDeviceNodeList() const
{
return deviceNodes().join(QStringLiteral(", "));
......
......@@ -80,6 +80,8 @@ protected:
public:
static void scanDevices(QList<Device*>& devices);
/** join deviceNodes together into comma-separated list
*
* @return comma-separated list of deviceNodes
......
......@@ -117,11 +117,11 @@ QList<Device*> SfdiskBackend::scanDevices(const ScanFlags scanFlags)
result.append(device);
}
}
SoftwareRAID::scanSoftwareRAID(result);
LvmDevice::scanSystemLVM(result); // LVM scanner needs all other devices, so should be last
}
VolumeManagerDevice::scanDevices(result); // scan all types of VolumeManagerDevices
return result;
}
......@@ -224,8 +224,6 @@ Device* SfdiskBackend::scanDevice(const QString& deviceNode)
{
QList<Device *> availableDevices = scanDevices();
LvmDevice::scanSystemLVM(availableDevices);
for (Device *device : qAsConst(availableDevices))
if (device->deviceNode() == deviceNode)
return device;
......@@ -329,16 +327,15 @@ bool SfdiskBackend::updateDevicePartitionTable(Device &d, const QJsonObject &jso
QString tableType = jsonPartitionTable[QLatin1String("label")].toString();
const PartitionTable::TableType type = PartitionTable::nameToTableType(tableType);
qint64 firstUsableSector = 0, lastUsableSector;
qint64 firstUsableSector = 0;
qint64 lastUsableSector;
if ( d.type() == Device::Type::Disk_Device )
{
if (d.type() == Device::Type::Disk_Device) {
const DiskDevice* diskDevice = static_cast<const DiskDevice*>(&d);
lastUsableSector = diskDevice->totalSectors();
}
else if ( d.type() == Device::Type::SoftwareRAID_Device )
{
else if (d.type() == Device::Type::SoftwareRAID_Device) {
const SoftwareRAID* raidDevice = static_cast<const SoftwareRAID*>(&d);
lastUsableSector = raidDevice->totalLogical() - 1;
......@@ -373,6 +370,7 @@ bool SfdiskBackend::updateDevicePartitionTable(Device &d, const QJsonObject &jso
else
maxEntries = 128;
CoreBackend::setPartitionTableMaxPrimaries(*d.partitionTable(), maxEntries);
break;
}
default:
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment