mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-27 17:35:37 -04:00
[partition] Check for available partition type before creating
- Avoid situation where you make 5 or more primaries in an MSDOS partition table. FIXES #953
This commit is contained in:
parent
bd57f1f2f1
commit
90a2e482be
2 changed files with 35 additions and 0 deletions
|
@ -34,6 +34,7 @@
|
||||||
#include "ui_PartitionPage.h"
|
#include "ui_PartitionPage.h"
|
||||||
#include "ui_CreatePartitionTableDialog.h"
|
#include "ui_CreatePartitionTableDialog.h"
|
||||||
|
|
||||||
|
#include "utils/Logger.h"
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
#include "Branding.h"
|
#include "Branding.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
|
@ -178,6 +179,29 @@ PartitionPage::onNewPartitionTableClicked()
|
||||||
updateBootLoaderIndex();
|
updateBootLoaderIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
PartitionPage::checkCanCreate( Device* device )
|
||||||
|
{
|
||||||
|
auto table = device->partitionTable();
|
||||||
|
|
||||||
|
if ( table->type() == PartitionTable::msdos ||table->type() == PartitionTable::msdos_sectorbased )
|
||||||
|
{
|
||||||
|
cDebug() << "Checking MSDOS partition" << table->numPrimaries() << "primaries, max" << table->maxPrimaries();
|
||||||
|
|
||||||
|
if ( ( table->numPrimaries() >= table->maxPrimaries() ) && !table->hasExtended() )
|
||||||
|
{
|
||||||
|
QMessageBox::warning( this, tr( "Can not create new partition" ),
|
||||||
|
tr( "The partition table on %1 already has %2 primary partitions, and no more can be added. "
|
||||||
|
"Please remove one primary partition and add an extended partition, instead." ).arg( device->name() ).arg( table->numPrimaries() )
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return true; // GPT is fine
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionPage::onCreateClicked()
|
PartitionPage::onCreateClicked()
|
||||||
{
|
{
|
||||||
|
@ -188,6 +212,9 @@ PartitionPage::onCreateClicked()
|
||||||
Partition* partition = model->partitionForIndex( index );
|
Partition* partition = model->partitionForIndex( index );
|
||||||
Q_ASSERT( partition );
|
Q_ASSERT( partition );
|
||||||
|
|
||||||
|
if ( !checkCanCreate( model->device() ) )
|
||||||
|
return;
|
||||||
|
|
||||||
QPointer< CreatePartitionDialog > dlg = new CreatePartitionDialog( model->device(),
|
QPointer< CreatePartitionDialog > dlg = new CreatePartitionDialog( model->device(),
|
||||||
partition->parent(),
|
partition->parent(),
|
||||||
nullptr,
|
nullptr,
|
||||||
|
|
|
@ -62,6 +62,14 @@ private:
|
||||||
void updateFromCurrentDevice();
|
void updateFromCurrentDevice();
|
||||||
void updateBootLoaderIndex();
|
void updateBootLoaderIndex();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if a new partition can be created (as primary) on the device.
|
||||||
|
*
|
||||||
|
* Returns true if a new partition can be created on the device. Provides
|
||||||
|
* a warning popup and returns false if it cannot.
|
||||||
|
*/
|
||||||
|
bool checkCanCreate( Device* );
|
||||||
|
|
||||||
QStringList getCurrentUsedMountpoints();
|
QStringList getCurrentUsedMountpoints();
|
||||||
|
|
||||||
QMutex m_revertMutex;
|
QMutex m_revertMutex;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue