Add support for GTP partition labels.
This commit is contained in:
parent
9c7db501bf
commit
28fa6ac5a4
|
@ -141,14 +141,18 @@ public:
|
|||
const Partitions& children() const override {
|
||||
return m_Children; /**< @return the Partition's children. empty for non-extended. */
|
||||
}
|
||||
|
||||
const QString& devicePath() const {
|
||||
return m_DevicePath; /**< @return the Partition's device path, e.g. /dev/sdd */
|
||||
}
|
||||
const QString& partitionPath() const {
|
||||
return m_PartitionPath; /**< @return the Partition's path, e.g. /dev/sdd1 */
|
||||
}
|
||||
|
||||
const QString& label() const {
|
||||
return m_Label; /**< @return the GPT Partition label */
|
||||
}
|
||||
const QString& uuid() const {
|
||||
return m_UUID; /**< @return the GPT Partition UUID */
|
||||
}
|
||||
qint64 firstSector() const {
|
||||
return m_FirstSector; /**< @return the Partition's first sector on the Device */
|
||||
}
|
||||
|
@ -192,18 +196,15 @@ public:
|
|||
PartitionTable::Flags availableFlags() const {
|
||||
return m_AvailableFlags; /**< @return the flags available for this Partition */
|
||||
}
|
||||
|
||||
bool isMounted() const {
|
||||
return m_IsMounted; /**< @return true if Partition is mounted */
|
||||
}
|
||||
|
||||
FileSystem& fileSystem() {
|
||||
return *m_FileSystem; /**< @return the Partition's FileSystem */
|
||||
}
|
||||
const FileSystem& fileSystem() const {
|
||||
return *m_FileSystem; /**< @return the Partition's FileSystem */
|
||||
}
|
||||
|
||||
State state() const {
|
||||
return m_State; /**< @return the Partition's state */
|
||||
}
|
||||
|
@ -225,6 +226,13 @@ public:
|
|||
m_LastSector = s;
|
||||
}
|
||||
|
||||
void setLabel(const QString& s) {
|
||||
m_Label = s; /**< @param s the new label */
|
||||
}
|
||||
void setUUID(const QString& s) {
|
||||
m_UUID = s; /**< @param s the new UUID */
|
||||
}
|
||||
|
||||
protected:
|
||||
void append(Partition* p) override {
|
||||
m_Children.append(p);
|
||||
|
@ -277,6 +285,8 @@ private:
|
|||
qint64 m_FirstSector;
|
||||
qint64 m_LastSector;
|
||||
QString m_DevicePath;
|
||||
QString m_Label;
|
||||
QString m_UUID;
|
||||
QString m_PartitionPath;
|
||||
QString m_MountPoint;
|
||||
PartitionTable::Flags m_AvailableFlags;
|
||||
|
|
|
@ -61,7 +61,8 @@ ActionReply Scan::scandevice(const QVariantMap& args)
|
|||
pedDisk->dev->bios_geom.heads *
|
||||
pedDisk->dev->bios_geom.cylinders - 1;
|
||||
|
||||
if (strcmp(pedDisk->type->name, "gpt") == 0) {
|
||||
bool isGPT = strcmp(pedDisk->type->name, "gpt") == 0;
|
||||
if (isGPT) {
|
||||
GPTDiskData* gpt_disk_data = reinterpret_cast<GPTDiskData*>(pedDisk->disk_specific);
|
||||
PedGeometry* geom = reinterpret_cast<PedGeometry*>(&gpt_disk_data->data_area);
|
||||
|
||||
|
@ -85,6 +86,7 @@ ActionReply Scan::scandevice(const QVariantMap& args)
|
|||
QList<QVariant> partitionStart;
|
||||
QList<QVariant> partitionEnd;
|
||||
QList<QVariant> partitionBusy;
|
||||
QList<QVariant> partitionLabel;
|
||||
QList<QVariant> availableFlags;
|
||||
QList<QVariant> activeFlags;
|
||||
|
||||
|
@ -97,6 +99,10 @@ ActionReply Scan::scandevice(const QVariantMap& args)
|
|||
partitionStart.append(pedPartition->geom.start);
|
||||
partitionEnd.append(pedPartition->geom.end);
|
||||
partitionBusy.append(ped_partition_is_busy(pedPartition));
|
||||
if (isGPT)
|
||||
partitionLabel.append(QLatin1String(ped_partition_get_name(pedPartition)));
|
||||
else
|
||||
partitionLabel.append(QLatin1String());
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Get list of available flags
|
||||
|
@ -135,6 +141,7 @@ ActionReply Scan::scandevice(const QVariantMap& args)
|
|||
reply.addData(QStringLiteral("partitionStart"), partitionStart);
|
||||
reply.addData(QStringLiteral("partitionEnd"), partitionEnd);
|
||||
reply.addData(QStringLiteral("partitionBusy"), partitionBusy);
|
||||
reply.addData(QStringLiteral("partitionLabel"), partitionLabel);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
|
|
@ -185,8 +185,8 @@ Device* LibPartedBackend::scanDevice(const QString& deviceNode)
|
|||
quint64 firstUsableSector = job->data()[QLatin1String("firstUsableSector")].toULongLong();
|
||||
quint64 lastUsableSector = job->data()[QLatin1String("lastUsableSector")].toULongLong();
|
||||
|
||||
const PartitionTable::TableType type = PartitionTable::nameToTableType(typeName);
|
||||
CoreBackend::setPartitionTableForDevice(*d, new PartitionTable(type, firstUsableSector, lastUsableSector));
|
||||
const PartitionTable::TableType tableType = PartitionTable::nameToTableType(typeName);
|
||||
CoreBackend::setPartitionTableForDevice(*d, new PartitionTable(tableType, firstUsableSector, lastUsableSector));
|
||||
CoreBackend::setPartitionTableMaxPrimaries(*d->partitionTable(), maxPrimaryPartitionCount);
|
||||
|
||||
QList<QVariant> partitionPath = job->data()[QLatin1String("partitionPath")].toList();
|
||||
|
@ -194,6 +194,8 @@ Device* LibPartedBackend::scanDevice(const QString& deviceNode)
|
|||
QList<QVariant> partitionStart = job->data()[QLatin1String("partitionStart")].toList();
|
||||
QList<QVariant> partitionEnd = job->data()[QLatin1String("partitionEnd")].toList();
|
||||
QList<QVariant> partitionBusy = job->data()[QLatin1String("partitionBusy")].toList();
|
||||
QList<QVariant> partitionLabel;
|
||||
partitionLabel = job->data()[QLatin1String("partitionLabel")].toList();
|
||||
|
||||
quint32 totalPartitions = partitionPath.size();
|
||||
QList<Partition*> partitions;
|
||||
|
@ -261,6 +263,10 @@ Device* LibPartedBackend::scanDevice(const QString& deviceNode)
|
|||
if (fs->supportGetLabel() != FileSystem::cmdSupportNone)
|
||||
fs->setLabel(fs->readLabel(part->deviceNode()));
|
||||
|
||||
// GPT partitions support partition labels and partition UUIDs
|
||||
if(tableType == PartitionTable::TableType::gpt)
|
||||
part->setLabel(partitionLabel[i].toString());
|
||||
|
||||
if (fs->supportGetUUID() != FileSystem::cmdSupportNone)
|
||||
fs->setUUID(fs->readUUID(part->deviceNode()));
|
||||
|
||||
|
|
Loading…
Reference in New Issue