Fixing device scanning process
This commit is contained in:
parent
281289dfbb
commit
43da873c36
|
@ -45,6 +45,8 @@ class LIBKPMCORE_EXPORT LvmDevice : public VolumeManagerDevice
|
||||||
{
|
{
|
||||||
Q_DISABLE_COPY(LvmDevice)
|
Q_DISABLE_COPY(LvmDevice)
|
||||||
|
|
||||||
|
friend class VolumeManagerDevice;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LvmDevice(const QString& name, const QString& iconName = QString());
|
LvmDevice(const QString& name, const QString& iconName = QString());
|
||||||
~LvmDevice();
|
~LvmDevice();
|
||||||
|
@ -57,8 +59,6 @@ public:
|
||||||
static QVector<const Partition*> s_DirtyPVs;
|
static QVector<const Partition*> s_DirtyPVs;
|
||||||
static QVector<const Partition*> s_OrphanPVs;
|
static QVector<const Partition*> s_OrphanPVs;
|
||||||
|
|
||||||
static void scanSystemLVM(QList<Device*>& devices);
|
|
||||||
|
|
||||||
static const QStringList getVGs();
|
static const QStringList getVGs();
|
||||||
static const QStringList getLVs(const QString& vgName);
|
static const QStringList getLVs(const QString& vgName);
|
||||||
|
|
||||||
|
@ -105,6 +105,9 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<QHash<QString, qint64>>& LVSizeMap() const;
|
std::unique_ptr<QHash<QString, qint64>>& LVSizeMap() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void scanSystemLVM(QList<Device*>& devices);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,6 +26,8 @@ class LIBKPMCORE_EXPORT SoftwareRAID : public VolumeManagerDevice
|
||||||
{
|
{
|
||||||
Q_DISABLE_COPY(SoftwareRAID)
|
Q_DISABLE_COPY(SoftwareRAID)
|
||||||
|
|
||||||
|
friend class VolumeManagerDevice;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class Status {
|
enum class Status {
|
||||||
Active,
|
Active,
|
||||||
|
@ -61,8 +63,6 @@ public:
|
||||||
void setStatus(SoftwareRAID::Status status);
|
void setStatus(SoftwareRAID::Status status);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void scanSoftwareRAID(QList<Device*>& devices);
|
|
||||||
|
|
||||||
static qint32 getRaidLevel(const QString& path);
|
static qint32 getRaidLevel(const QString& path);
|
||||||
static qint64 getChunkSize(const QString& path);
|
static qint64 getChunkSize(const QString& path);
|
||||||
static qint64 getTotalChunk(const QString& path);
|
static qint64 getTotalChunk(const QString& path);
|
||||||
|
@ -95,6 +95,8 @@ protected:
|
||||||
qint64 mappedSector(const QString &partitionPath, qint64 sector) const override;
|
qint64 mappedSector(const QString &partitionPath, qint64 sector) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static void scanSoftwareRAID(QList<Device*>& devices);
|
||||||
|
|
||||||
static QString getDetail(const QString& path);
|
static QString getDetail(const QString& path);
|
||||||
|
|
||||||
static QString getRAIDConfiguration(const QString& configurationPath);
|
static QString getRAIDConfiguration(const QString& configurationPath);
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#include "core/device_p.h"
|
#include "core/device_p.h"
|
||||||
#include "core/volumemanagerdevice.h"
|
#include "core/volumemanagerdevice.h"
|
||||||
#include "core/volumemanagerdevice_p.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.
|
/** 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
|
QString VolumeManagerDevice::prettyDeviceNodeList() const
|
||||||
{
|
{
|
||||||
return deviceNodes().join(QStringLiteral(", "));
|
return deviceNodes().join(QStringLiteral(", "));
|
||||||
|
|
|
@ -80,6 +80,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
static void scanDevices(QList<Device*>& devices);
|
||||||
|
|
||||||
/** join deviceNodes together into comma-separated list
|
/** join deviceNodes together into comma-separated list
|
||||||
*
|
*
|
||||||
* @return comma-separated list of deviceNodes
|
* @return comma-separated list of deviceNodes
|
||||||
|
|
|
@ -117,11 +117,11 @@ QList<Device*> SfdiskBackend::scanDevices(const ScanFlags scanFlags)
|
||||||
result.append(device);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,8 +224,6 @@ Device* SfdiskBackend::scanDevice(const QString& deviceNode)
|
||||||
{
|
{
|
||||||
QList<Device *> availableDevices = scanDevices();
|
QList<Device *> availableDevices = scanDevices();
|
||||||
|
|
||||||
LvmDevice::scanSystemLVM(availableDevices);
|
|
||||||
|
|
||||||
for (Device *device : qAsConst(availableDevices))
|
for (Device *device : qAsConst(availableDevices))
|
||||||
if (device->deviceNode() == deviceNode)
|
if (device->deviceNode() == deviceNode)
|
||||||
return device;
|
return device;
|
||||||
|
@ -329,16 +327,15 @@ bool SfdiskBackend::updateDevicePartitionTable(Device &d, const QJsonObject &jso
|
||||||
QString tableType = jsonPartitionTable[QLatin1String("label")].toString();
|
QString tableType = jsonPartitionTable[QLatin1String("label")].toString();
|
||||||
const PartitionTable::TableType type = PartitionTable::nameToTableType(tableType);
|
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);
|
const DiskDevice* diskDevice = static_cast<const DiskDevice*>(&d);
|
||||||
|
|
||||||
lastUsableSector = diskDevice->totalSectors();
|
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);
|
const SoftwareRAID* raidDevice = static_cast<const SoftwareRAID*>(&d);
|
||||||
|
|
||||||
lastUsableSector = raidDevice->totalLogical() - 1;
|
lastUsableSector = raidDevice->totalLogical() - 1;
|
||||||
|
@ -373,6 +370,7 @@ bool SfdiskBackend::updateDevicePartitionTable(Device &d, const QJsonObject &jso
|
||||||
else
|
else
|
||||||
maxEntries = 128;
|
maxEntries = 128;
|
||||||
CoreBackend::setPartitionTableMaxPrimaries(*d.partitionTable(), maxEntries);
|
CoreBackend::setPartitionTableMaxPrimaries(*d.partitionTable(), maxEntries);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue