make sure not to return false when isSectorBase() is called more than once.
make the heuristic to determine if a partition table is sector aligned a little less dumb. svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1140829
This commit is contained in:
parent
a509ad8ee4
commit
fe6f80379a
|
@ -435,7 +435,7 @@ bool PartitionTable::tableTypeIsReadOnly(TableType l)
|
||||||
if its Partitions begin at sectors evenly divisable by Config::sectorAlignment().
|
if its Partitions begin at sectors evenly divisable by Config::sectorAlignment().
|
||||||
@return true if is sector aligned, otherwise false
|
@return true if is sector aligned, otherwise false
|
||||||
*/
|
*/
|
||||||
bool PartitionTable::isSectorBased() const
|
bool PartitionTable::isSectorBased(const Device& d) const
|
||||||
{
|
{
|
||||||
if (type() == PartitionTable::msdos)
|
if (type() == PartitionTable::msdos)
|
||||||
{
|
{
|
||||||
|
@ -443,17 +443,21 @@ bool PartitionTable::isSectorBased() const
|
||||||
if (numPrimaries() == 0)
|
if (numPrimaries() == 0)
|
||||||
return !Config::useCylinderAlignment();
|
return !Config::useCylinderAlignment();
|
||||||
|
|
||||||
|
quint32 numCylinderAligned = 0;
|
||||||
|
quint32 numSectorAligned = 0;
|
||||||
|
|
||||||
// if not all partitions start at a point evenly divisable by sectorAlignment it's
|
// if not all partitions start at a point evenly divisable by sectorAlignment it's
|
||||||
// a cylinder-aligned msdos partition table
|
// a cylinder-aligned msdos partition table
|
||||||
foreach(const Partition* p, children())
|
foreach(const Partition* p, children())
|
||||||
if (p->firstSector() % Config::sectorAlignment() != 0)
|
if (p->firstSector() % Config::sectorAlignment() == 0)
|
||||||
return false;
|
numSectorAligned++;
|
||||||
|
else if (p->firstSector() % d.cylinderSize() == 0)
|
||||||
|
numCylinderAligned++;
|
||||||
|
|
||||||
// must be sector aligned
|
return numSectorAligned >= numCylinderAligned;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return type() == PartitionTable::msdos_sectorbased;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartitionTable::setType(const Device& d, TableType t)
|
void PartitionTable::setType(const Device& d, TableType t)
|
||||||
|
|
|
@ -126,7 +126,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT PartitionTable : public PartitionNode
|
||||||
void updateUnallocated(const Device& d);
|
void updateUnallocated(const Device& d);
|
||||||
void insertUnallocated(const Device& d, PartitionNode* p, qint64 start) const;
|
void insertUnallocated(const Device& d, PartitionNode* p, qint64 start) const;
|
||||||
|
|
||||||
bool isSectorBased() const;
|
bool isSectorBased(const Device& d) const;
|
||||||
|
|
||||||
static QList<Flag> flagList();
|
static QList<Flag> flagList();
|
||||||
static QString flagName(Flag f);
|
static QString flagName(Flag f);
|
||||||
|
|
|
@ -912,7 +912,7 @@ void MainWindow::onImportPartitionTable()
|
||||||
Log(Log::warning) << i18nc("@info/plain", "Could not parse line %1 from import file. Ignoring it.", lineNo);
|
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);
|
ptable->setType(device, PartitionTable::msdos_sectorbased);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -366,7 +366,7 @@ void LibPartedBackend::scanDevicePartitions(PedDevice*, Device& d, PedDisk* pedD
|
||||||
|
|
||||||
d.partitionTable()->updateUnallocated(d);
|
d.partitionTable()->updateUnallocated(d);
|
||||||
|
|
||||||
if (d.partitionTable()->isSectorBased())
|
if (d.partitionTable()->isSectorBased(d))
|
||||||
d.partitionTable()->setType(d, PartitionTable::msdos_sectorbased);
|
d.partitionTable()->setType(d, PartitionTable::msdos_sectorbased);
|
||||||
|
|
||||||
foreach(const Partition* part, partitions)
|
foreach(const Partition* part, partitions)
|
||||||
|
|
Loading…
Reference in New Issue