sfdisk: Make FlagEsp alias for FlagBoot
This commit is contained in:
parent
7853424a62
commit
046f17fa68
|
@ -225,12 +225,14 @@ void SfdiskBackend::scanDevicePartitions(Device& d, const QJsonArray& jsonPartit
|
|||
const qint64 start = partitionObject[QLatin1String("start")].toVariant().toLongLong();
|
||||
const qint64 size = partitionObject[QLatin1String("size")].toVariant().toLongLong();
|
||||
const QString partitionType = partitionObject[QLatin1String("type")].toString();
|
||||
PartitionTable::Flag activeFlags = partitionObject[QLatin1String("bootable")].toBool() ? PartitionTable::FlagBoot : PartitionTable::FlagNone;
|
||||
PartitionTable::Flags activeFlags = partitionObject[QLatin1String("bootable")].toBool() ? PartitionTable::FlagBoot : PartitionTable::FlagNone;
|
||||
|
||||
if (partitionType == QStringLiteral("C12A7328-F81F-11D2-BA4B-00A0C93EC93B"))
|
||||
activeFlags = PartitionTable::FlagEsp;
|
||||
if (partitionType == QStringLiteral("C12A7328-F81F-11D2-BA4B-00A0C93EC93B")) {
|
||||
activeFlags |= PartitionTable::FlagBoot;
|
||||
activeFlags |= PartitionTable::FlagEsp;
|
||||
}
|
||||
else if (partitionType == QStringLiteral("21686148-6449-6E6F-744E-656564454649"))
|
||||
activeFlags = PartitionTable::FlagBiosGrub;
|
||||
activeFlags |= PartitionTable::FlagBiosGrub;
|
||||
|
||||
FileSystem::Type type = FileSystem::Type::Unknown;
|
||||
type = detectFileSystem(partitionNode);
|
||||
|
@ -476,8 +478,9 @@ PartitionTable::Flags SfdiskBackend::availableFlags(PartitionTable::TableType ty
|
|||
if (type == PartitionTable::gpt) {
|
||||
// These are not really flags but for now keep them for compatibility
|
||||
// We should implement changing partition type
|
||||
flags = PartitionTable::FlagBiosGrub |
|
||||
PartitionTable::FlagEsp;
|
||||
flags = PartitionTable::Flag::FlagBiosGrub |
|
||||
PartitionTable::Flag::FlagEsp |
|
||||
PartitionTable::Flag::FlagBoot;
|
||||
}
|
||||
else if (type == PartitionTable::msdos || type == PartitionTable::msdos_sectorbased)
|
||||
flags = PartitionTable::FlagBoot;
|
||||
|
|
|
@ -195,11 +195,11 @@ static QLatin1String getPartitionType(FileSystem::Type t, PartitionTable::TableT
|
|||
{
|
||||
quint8 type;
|
||||
switch (tableType) {
|
||||
case PartitionTable::gpt:
|
||||
case PartitionTable::TableType::gpt:
|
||||
type = 0;
|
||||
break;
|
||||
case PartitionTable::msdos:
|
||||
case PartitionTable::msdos_sectorbased:
|
||||
case PartitionTable::TableType::msdos:
|
||||
case PartitionTable::TableType::msdos_sectorbased:
|
||||
type = 1;
|
||||
break;
|
||||
default:;
|
||||
|
@ -225,20 +225,22 @@ bool SfdiskPartitionTable::setPartitionSystemType(Report& report, const Partitio
|
|||
bool SfdiskPartitionTable::setFlag(Report& report, const Partition& partition, PartitionTable::Flag flag, bool state)
|
||||
{
|
||||
// We only allow setting one active partition per device
|
||||
if (flag == PartitionTable::FlagBoot && state == true) {
|
||||
if ((m_device->partitionTable()->type() == PartitionTable::TableType::msdos ||
|
||||
m_device->partitionTable()->type() == PartitionTable::TableType::msdos_sectorbased) &&
|
||||
flag == PartitionTable::Flag::FlagBoot && state == true) {
|
||||
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) {
|
||||
} else if (flag == PartitionTable::Flag::FlagBoot && state == false) {
|
||||
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) {
|
||||
if ((flag == PartitionTable::Flag::FlagEsp || flag == PartitionTable::Flag::FlagBoot) && state == true) {
|
||||
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)
|
||||
|
@ -246,10 +248,10 @@ bool SfdiskPartitionTable::setFlag(Report& report, const Partition& partition, P
|
|||
else
|
||||
return false;
|
||||
}
|
||||
if (flag == PartitionTable::FlagEsp && state == false)
|
||||
if ((flag == PartitionTable::Flag::FlagEsp || flag == PartitionTable::Flag::FlagBoot) && state == false)
|
||||
setPartitionSystemType(report, partition);
|
||||
|
||||
if (flag == PartitionTable::FlagBiosGrub && state == true) {
|
||||
if (flag == PartitionTable::Flag::FlagBiosGrub && state == true) {
|
||||
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)
|
||||
|
@ -257,7 +259,7 @@ bool SfdiskPartitionTable::setFlag(Report& report, const Partition& partition, P
|
|||
else
|
||||
return false;
|
||||
}
|
||||
if (flag == PartitionTable::FlagBiosGrub && state == false)
|
||||
if (flag == PartitionTable::Flag::FlagBiosGrub && state == false)
|
||||
setPartitionSystemType(report, partition);
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue