parent
0910875137
commit
034311a7cc
|
@ -251,8 +251,11 @@ Device* SfdiskBackend::scanDevice(const QString& deviceNode)
|
|||
|
||||
if ( d )
|
||||
{
|
||||
if (sfdiskJsonCommand.exitCode() != 0)
|
||||
if (sfdiskJsonCommand.exitCode() != 0) {
|
||||
scanWholeDevicePartition(*d);
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
auto s = sfdiskJsonCommand.rawOutput();
|
||||
fixInvalidJsonFromSFDisk(s);
|
||||
|
@ -283,6 +286,28 @@ Device* SfdiskBackend::scanDevice(const QString& deviceNode)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
/** Scans a Device for FileSystems spanning the whole block device
|
||||
|
||||
This method will scan a Device for a FileSystem.
|
||||
It tries to determine the FileSystem usage, reads the FileSystem label and creates
|
||||
PartitionTable of type "none" and a single Partition object.
|
||||
*/
|
||||
void SfdiskBackend::scanWholeDevicePartition(Device& d) {
|
||||
const QString partitionNode = d.deviceNode();
|
||||
constexpr qint64 firstSector = 0;
|
||||
const qint64 lastSector = d.totalLogical() - 1;
|
||||
setPartitionTableForDevice(d, new PartitionTable(PartitionTable::TableType::none, firstSector, lastSector));
|
||||
Partition *partition = scanPartition(d, partitionNode, firstSector, lastSector, QString(), false);
|
||||
|
||||
if (partition->fileSystem().type() == FileSystem::Type::Unknown) {
|
||||
setPartitionTableForDevice(d, nullptr);
|
||||
delete d.partitionTable();
|
||||
}
|
||||
|
||||
if (!partition->roles().has(PartitionRole::Luks))
|
||||
readSectorsUsed(d, *partition, partition->mountPoint());
|
||||
}
|
||||
|
||||
/** Scans a Device for Partitions.
|
||||
|
||||
This method will scan a Device for all Partitions on it, detect the FileSystem for each Partition,
|
||||
|
|
|
@ -51,6 +51,7 @@ private:
|
|||
static void readSectorsUsed(const Device& d, Partition& p, const QString& mountPoint);
|
||||
void scanDevicePartitions(Device& d, const QJsonArray& jsonPartitions);
|
||||
Partition* scanPartition(Device& d, const QString& partitionNode, const qint64 firstSector, const qint64 lastSector, const QString& partitionType, const bool bootable);
|
||||
void scanWholeDevicePartition(Device& d);
|
||||
static void setupPartitionInfo(const Device& d, Partition* partition, const QJsonObject& partitionObject);
|
||||
bool updateDevicePartitionTable(Device& d, const QJsonObject& jsonPartitionTable);
|
||||
static PartitionTable::Flags availableFlags(PartitionTable::TableType type);
|
||||
|
|
Loading…
Reference in New Issue