rename msdos_vista to msdos and make sure to use sector-based-alignment instead

of vista. also use cylinder based instead of msdos legacy.

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1097441
This commit is contained in:
Volker Lanz 2010-03-01 12:00:07 +00:00
parent c7bc3368e4
commit 856ef859eb
11 changed files with 44 additions and 43 deletions

View File

@ -322,8 +322,8 @@ static void scanDevicePartitions(PedDevice* pedDevice, Device& d, PedDisk* pedDi
d.partitionTable()->updateUnallocated(d); d.partitionTable()->updateUnallocated(d);
if (d.partitionTable()->isVistaTableType()) if (d.partitionTable()->isSectorBased())
d.partitionTable()->setType(d, PartitionTable::msdos_vista); d.partitionTable()->setType(d, PartitionTable::msdos_sectorbased);
foreach(const Partition* part, partitions) foreach(const Partition* part, partitions)
PartitionTable::isAligned(d, *part); PartitionTable::isAligned(d, *part);

View File

@ -19,7 +19,7 @@
<entry name="sectorAlignment" type="Int"> <entry name="sectorAlignment" type="Int">
<default>2048</default> <default>2048</default>
</entry> </entry>
<entry name="useLegacyMsDosAlignment" type="Bool"> <entry name="useCylinderAlignment" type="Bool">
<default>false</default> <default>false</default>
</entry> </entry>
<entry name="allowApplyOperationsAsNonRoot" type="Bool"> <entry name="allowApplyOperationsAsNonRoot" type="Bool">

View File

@ -461,7 +461,8 @@ Partition* createUnallocated(const Device& device, PartitionNode& parent, qint64
return NULL; return NULL;
} }
// Leave a track (msdos) or sector alignment sectors (vista) free at the start for a new partition's metadata // Leave a track (cylinder aligned) or sector alignment sectors (sector based) free at the
// start for a new partition's metadata
start += device.partitionTable()->type() == PartitionTable::msdos ? device.sectorsPerTrack() : sectorAlignment(device); start += device.partitionTable()->type() == PartitionTable::msdos ? device.sectorsPerTrack() : sectorAlignment(device);
// .. and also at the end for the metadata for a partition to follow us, if we're not // .. and also at the end for the metadata for a partition to follow us, if we're not
@ -567,7 +568,7 @@ void PartitionTable::updateUnallocated(const Device& d)
qint64 PartitionTable::defaultFirstUsable(const Device& d, TableType t) qint64 PartitionTable::defaultFirstUsable(const Device& d, TableType t)
{ {
if (t == msdos && Config::useLegacyMsDosAlignment()) if (t == msdos && Config::useCylinderAlignment())
return d.sectorsPerTrack(); return d.sectorsPerTrack();
return Config::sectorAlignment(); return Config::sectorAlignment();
@ -594,7 +595,7 @@ static struct
{ "bsd", 8, false, true, PartitionTable::bsd }, { "bsd", 8, false, true, PartitionTable::bsd },
{ "dasd", 1, false, true, PartitionTable::dasd }, { "dasd", 1, false, true, PartitionTable::dasd },
{ "msdos", 4, true, false, PartitionTable::msdos }, { "msdos", 4, true, false, PartitionTable::msdos },
{ "msdos (vista)", 4, true, false, PartitionTable::msdos_vista }, { "msdos", 4, true, false, PartitionTable::msdos_sectorbased },
{ "dvh", 16, true, true, PartitionTable::dvh }, { "dvh", 16, true, true, PartitionTable::dvh },
{ "gpt", 128, false, false, PartitionTable::gpt }, { "gpt", 128, false, false, PartitionTable::gpt },
{ "loop", 1, false, true, PartitionTable::loop }, { "loop", 1, false, true, PartitionTable::loop },
@ -649,25 +650,25 @@ bool PartitionTable::tableTypeIsReadOnly(TableType l)
return false; return false;
} }
/** Simple heuristic to determine if the PartitionTable is MS Vista compatible (i.e. /** Simple heuristic to determine if the PartitionTable is sector aligned (i.e.
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 msdos_vista, otherwise false @return true if is sector aligned, otherwise false
*/ */
bool PartitionTable::isVistaTableType() const bool PartitionTable::isSectorBased() const
{ {
if (type() == PartitionTable::msdos) if (type() == PartitionTable::msdos)
{ {
// user has turned ms dos legacy off and partition table is empty // user has turned cylinder based alignment off and partition table is empty
if (Config::useLegacyMsDosAlignment() == false && children().size() == 0) if (Config::useCylinderAlignment() == false && children().size() == 0)
return true; return true;
// 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 legacy 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; return false;
// must be vista // must be sector aligned
return true; return true;
} }

View File

@ -56,7 +56,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT PartitionTable : public PartitionNode
bsd, bsd,
dasd, dasd,
msdos, msdos,
msdos_vista, msdos_sectorbased,
dvh, dvh,
gpt, gpt,
loop, loop,
@ -123,7 +123,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 isVistaTableType() const; bool isSectorBased() const;
static QList<Flag> flagList(); static QList<Flag> flagList();
static QString flagName(Flag f); static QString flagName(Flag f);

View File

@ -15,9 +15,9 @@
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="kcfg_useLegacyMsDosAlignment"> <widget class="QCheckBox" name="kcfg_useCylinderAlignment">
<property name="text"> <property name="text">
<string>Use Legacy MS-Dos Partition Alignment (Windows XP compatible)</string> <string>Use Cylinder Based MS-Dos Partition Alignment (Windows XP compatible)</string>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>

View File

@ -42,8 +42,8 @@ PartitionTable::TableType CreatePartitionTableDialog::type() const
if (widget().radioGPT().isChecked()) if (widget().radioGPT().isChecked())
return PartitionTable::gpt; return PartitionTable::gpt;
if (widget().radioMSDOS().isChecked() && Config::useLegacyMsDosAlignment() == true) if (widget().radioMSDOS().isChecked() && Config::useCylinderAlignment() == true)
return PartitionTable::msdos; return PartitionTable::msdos;
return PartitionTable::msdos_vista; return PartitionTable::msdos_sectorbased;
} }

View File

@ -83,9 +83,9 @@ void DevicePropsDialog::setupDialog()
dialogWidget().type().setText(type); dialogWidget().type().setText(type);
if (device().partitionTable()->type() == PartitionTable::msdos) if (device().partitionTable()->type() == PartitionTable::msdos)
dialogWidget().radioLegacy().setChecked(true); dialogWidget().radioCylinderBased().setChecked(true);
else if (device().partitionTable()->type() == PartitionTable::msdos_vista) else if (device().partitionTable()->type() == PartitionTable::msdos_sectorbased)
dialogWidget().radioVista().setChecked(true); dialogWidget().radioSectorBased().setChecked(true);
else else
dialogWidget().hideTypeRadioButtons(); dialogWidget().hideTypeRadioButtons();
@ -95,8 +95,8 @@ void DevicePropsDialog::setupDialog()
void DevicePropsDialog::setupConnections() void DevicePropsDialog::setupConnections()
{ {
connect(&dialogWidget().radioVista(), SIGNAL(toggled(bool)), SLOT(setDirty(bool))); connect(&dialogWidget().radioSectorBased(), SIGNAL(toggled(bool)), SLOT(setDirty(bool)));
connect(&dialogWidget().radioLegacy(), SIGNAL(toggled(bool)), SLOT(setDirty(bool))); connect(&dialogWidget().radioCylinderBased(), SIGNAL(toggled(bool)), SLOT(setDirty(bool)));
} }
void DevicePropsDialog::setDirty(bool) void DevicePropsDialog::setDirty(bool)
@ -105,12 +105,12 @@ void DevicePropsDialog::setDirty(bool)
enableButtonOk(true); enableButtonOk(true);
} }
bool DevicePropsDialog::legacyAlignment() const bool DevicePropsDialog::cylinderBasedAlignment() const
{ {
return dialogWidget().radioLegacy().isChecked(); return dialogWidget().radioCylinderBased().isChecked();
} }
bool DevicePropsDialog::vistaAlignment() const bool DevicePropsDialog::sectorBasedAlignment() const
{ {
return dialogWidget().radioVista().isChecked(); return dialogWidget().radioSectorBased().isChecked();
} }

View File

@ -45,8 +45,8 @@ class DevicePropsDialog : public KDialog
~DevicePropsDialog(); ~DevicePropsDialog();
public: public:
bool legacyAlignment() const; bool cylinderBasedAlignment() const;
bool vistaAlignment() const; bool sectorBasedAlignment() const;
protected: protected:
void setupDialog(); void setupDialog();

View File

@ -44,18 +44,18 @@ class DevicePropsWidget : public QWidget, public Ui::DevicePropsWidgetBase
QLabel& totalSectors() { Q_ASSERT(m_LabelTotalSectors); return *m_LabelTotalSectors; } QLabel& totalSectors() { Q_ASSERT(m_LabelTotalSectors); return *m_LabelTotalSectors; }
QLabel& type() { Q_ASSERT(m_LabelType); return *m_LabelType; } QLabel& type() { Q_ASSERT(m_LabelType); return *m_LabelType; }
QRadioButton& radioLegacy() { Q_ASSERT(m_RadioLegacy); return *m_RadioLegacy; } QRadioButton& radioCylinderBased() { Q_ASSERT(m_RadioCylinderBased); return *m_RadioCylinderBased; }
const QRadioButton& radioLegacy() const { Q_ASSERT(m_RadioLegacy); return *m_RadioLegacy; } const QRadioButton& radioCylinderBased() const { Q_ASSERT(m_RadioCylinderBased); return *m_RadioCylinderBased; }
QRadioButton& radioVista() { Q_ASSERT(m_RadioVista); return *m_RadioVista; } QRadioButton& radioSectorBased() { Q_ASSERT(m_RadioSectorBased); return *m_RadioSectorBased; }
const QRadioButton& radioVista() const { Q_ASSERT(m_RadioVista); return *m_RadioVista; } const QRadioButton& radioSectorBased() const { Q_ASSERT(m_RadioSectorBased); return *m_RadioSectorBased; }
QSpacerItem& spacerType() { Q_ASSERT(m_SpacerType); return *m_SpacerType; } QSpacerItem& spacerType() { Q_ASSERT(m_SpacerType); return *m_SpacerType; }
void hideTypeRadioButtons() void hideTypeRadioButtons()
{ {
radioVista().setVisible(false); radioSectorBased().setVisible(false);
radioLegacy().setVisible(false); radioCylinderBased().setVisible(false);
} }
}; };

View File

@ -81,16 +81,16 @@
<item row="3" column="1"> <item row="3" column="1">
<layout class="QHBoxLayout" name="m_TypeLayout"> <layout class="QHBoxLayout" name="m_TypeLayout">
<item> <item>
<widget class="QRadioButton" name="m_RadioLegacy"> <widget class="QRadioButton" name="m_RadioCylinderBased">
<property name="text"> <property name="text">
<string>Legacy Alignment</string> <string>Cylinder Alignment</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="m_RadioVista"> <widget class="QRadioButton" name="m_RadioSectorBased">
<property name="text"> <property name="text">
<string>Vista Compatible Alignment</string> <string>Sector Based Alignment</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -688,9 +688,9 @@ void MainWindow::onPropertiesDevice(const QString&)
QPointer<DevicePropsDialog> dlg = new DevicePropsDialog(this, d); QPointer<DevicePropsDialog> dlg = new DevicePropsDialog(this, d);
if (dlg->exec() == KDialog::Accepted) if (dlg->exec() == KDialog::Accepted)
{ {
if (d.partitionTable()->type() == PartitionTable::msdos && dlg->vistaAlignment()) if (d.partitionTable()->type() == PartitionTable::msdos && dlg->sectorBasedAlignment())
d.partitionTable()->setType(d, PartitionTable::msdos_vista); d.partitionTable()->setType(d, PartitionTable::msdos_sectorbased);
else if (d.partitionTable()->type() == PartitionTable::msdos_vista && dlg->legacyAlignment()) else if (d.partitionTable()->type() == PartitionTable::msdos_sectorbased && dlg->cylinderBasedAlignment())
d.partitionTable()->setType(d, PartitionTable::msdos); d.partitionTable()->setType(d, PartitionTable::msdos);
on_m_OperationStack_devicesChanged(); on_m_OperationStack_devicesChanged();