diff --git a/src/core/partitiontable.cpp b/src/core/partitiontable.cpp index 39d1d22..c9f3b51 100644 --- a/src/core/partitiontable.cpp +++ b/src/core/partitiontable.cpp @@ -435,7 +435,7 @@ bool PartitionTable::tableTypeIsReadOnly(TableType l) if its Partitions begin at sectors evenly divisable by Config::sectorAlignment(). @return true if is sector aligned, otherwise false */ -bool PartitionTable::isSectorBased() const +bool PartitionTable::isSectorBased(const Device& d) const { if (type() == PartitionTable::msdos) { @@ -443,17 +443,21 @@ bool PartitionTable::isSectorBased() const if (numPrimaries() == 0) return !Config::useCylinderAlignment(); + quint32 numCylinderAligned = 0; + quint32 numSectorAligned = 0; + // if not all partitions start at a point evenly divisable by sectorAlignment it's // a cylinder-aligned msdos partition table foreach(const Partition* p, children()) - if (p->firstSector() % Config::sectorAlignment() != 0) - return false; + if (p->firstSector() % Config::sectorAlignment() == 0) + numSectorAligned++; + else if (p->firstSector() % d.cylinderSize() == 0) + numCylinderAligned++; - // must be sector aligned - return true; + return numSectorAligned >= numCylinderAligned; } - return false; + return type() == PartitionTable::msdos_sectorbased; } void PartitionTable::setType(const Device& d, TableType t) diff --git a/src/core/partitiontable.h b/src/core/partitiontable.h index be1b13f..a57e2a1 100644 --- a/src/core/partitiontable.h +++ b/src/core/partitiontable.h @@ -126,7 +126,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT PartitionTable : public PartitionNode void updateUnallocated(const Device& d); void insertUnallocated(const Device& d, PartitionNode* p, qint64 start) const; - bool isSectorBased() const; + bool isSectorBased(const Device& d) const; static QList flagList(); static QString flagName(Flag f); diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 365b3ca..bf64cae 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -912,7 +912,7 @@ void MainWindow::onImportPartitionTable() Log(Log::warning) << i18nc("@info/plain", "Could not parse line %1 from import file. Ignoring it.", lineNo); } - if (ptable->type() == PartitionTable::msdos && ptable->isSectorBased()) + if (ptable->type() == PartitionTable::msdos && ptable->isSectorBased(device)) ptable->setType(device, PartitionTable::msdos_sectorbased); } diff --git a/src/plugins/libparted/libpartedbackend.cpp b/src/plugins/libparted/libpartedbackend.cpp index 1bba4ee..bbe7c76 100644 --- a/src/plugins/libparted/libpartedbackend.cpp +++ b/src/plugins/libparted/libpartedbackend.cpp @@ -366,7 +366,7 @@ void LibPartedBackend::scanDevicePartitions(PedDevice*, Device& d, PedDisk* pedD d.partitionTable()->updateUnallocated(d); - if (d.partitionTable()->isSectorBased()) + if (d.partitionTable()->isSectorBased(d)) d.partitionTable()->setType(d, PartitionTable::msdos_sectorbased); foreach(const Partition* part, partitions)