[partition] Apply coding style to core/ subdir
Because this is a giant code change, with no functional effect, I've been saving this until the end of the kpmcore-manager branch.
This commit is contained in:
parent
2bc296b468
commit
7f295d9565
@ -20,8 +20,8 @@
|
|||||||
|
|
||||||
#include "core/BootLoaderModel.h"
|
#include "core/BootLoaderModel.h"
|
||||||
|
|
||||||
#include "core/PartitionInfo.h"
|
|
||||||
#include "core/KPMHelpers.h"
|
#include "core/KPMHelpers.h"
|
||||||
|
#include "core/PartitionInfo.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
@ -44,9 +44,7 @@ BootLoaderModel::BootLoaderModel( QObject* parent )
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BootLoaderModel::~BootLoaderModel()
|
BootLoaderModel::~BootLoaderModel() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BootLoaderModel::init( const QList< Device* >& devices )
|
BootLoaderModel::init( const QList< Device* >& devices )
|
||||||
@ -67,11 +65,8 @@ BootLoaderModel::createMbrItems()
|
|||||||
{
|
{
|
||||||
for ( auto device : m_devices )
|
for ( auto device : m_devices )
|
||||||
{
|
{
|
||||||
QString text = tr( "Master Boot Record of %1" )
|
QString text = tr( "Master Boot Record of %1" ).arg( device->name() );
|
||||||
.arg( device->name() );
|
appendRow( createBootLoaderItem( text, device->deviceNode(), false ) );
|
||||||
appendRow(
|
|
||||||
createBootLoaderItem( text, device->deviceNode(), false )
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,23 +85,29 @@ BootLoaderModel::update()
|
|||||||
void
|
void
|
||||||
BootLoaderModel::updateInternal()
|
BootLoaderModel::updateInternal()
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&m_lock);
|
QMutexLocker lock( &m_lock );
|
||||||
clear();
|
clear();
|
||||||
createMbrItems();
|
createMbrItems();
|
||||||
|
|
||||||
// An empty model is possible if you don't havee permissions: don't crash though.
|
// An empty model is possible if you don't havee permissions: don't crash though.
|
||||||
if ( rowCount() < 1 )
|
if ( rowCount() < 1 )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QString partitionText;
|
QString partitionText;
|
||||||
Partition* partition = KPMHelpers::findPartitionByMountPoint( m_devices, "/boot" );
|
Partition* partition = KPMHelpers::findPartitionByMountPoint( m_devices, "/boot" );
|
||||||
if ( partition )
|
if ( partition )
|
||||||
|
{
|
||||||
partitionText = tr( "Boot Partition" );
|
partitionText = tr( "Boot Partition" );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
partition = KPMHelpers::findPartitionByMountPoint( m_devices, "/" );
|
partition = KPMHelpers::findPartitionByMountPoint( m_devices, "/" );
|
||||||
if ( partition )
|
if ( partition )
|
||||||
|
{
|
||||||
partitionText = tr( "System Partition" );
|
partitionText = tr( "System Partition" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_ASSERT( rowCount() > 0 );
|
Q_ASSERT( rowCount() > 0 );
|
||||||
@ -117,7 +118,9 @@ BootLoaderModel::updateInternal()
|
|||||||
if ( !partition )
|
if ( !partition )
|
||||||
{
|
{
|
||||||
if ( lastIsPartition )
|
if ( lastIsPartition )
|
||||||
|
{
|
||||||
takeRow( rowCount() - 1 );
|
takeRow( rowCount() - 1 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -129,15 +132,11 @@ BootLoaderModel::updateInternal()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendRow(
|
appendRow( createBootLoaderItem( partitionText, PartitionInfo::mountPoint( partition ), true ) );
|
||||||
createBootLoaderItem( partitionText, PartitionInfo::mountPoint( partition ), true )
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create "don't install bootloader" item
|
// Create "don't install bootloader" item
|
||||||
appendRow(
|
appendRow( createBootLoaderItem( tr( "Do not install a boot loader" ), QString(), false ) );
|
||||||
createBootLoaderItem( tr( "Do not install a boot loader" ), QString(), false )
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,13 +144,15 @@ BootLoaderModel::updateInternal()
|
|||||||
QVariant
|
QVariant
|
||||||
BootLoaderModel::data( const QModelIndex& index, int role ) const
|
BootLoaderModel::data( const QModelIndex& index, int role ) const
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&m_lock);
|
QMutexLocker lock( &m_lock );
|
||||||
if ( role == Qt::DisplayRole )
|
if ( role == Qt::DisplayRole )
|
||||||
{
|
{
|
||||||
QString displayRole = QStandardItemModel::data( index, Qt::DisplayRole ).toString();
|
QString displayRole = QStandardItemModel::data( index, Qt::DisplayRole ).toString();
|
||||||
QString pathRole = QStandardItemModel::data( index, BootLoaderModel::BootLoaderPathRole ).toString();
|
QString pathRole = QStandardItemModel::data( index, BootLoaderModel::BootLoaderPathRole ).toString();
|
||||||
if ( pathRole.isEmpty() )
|
if ( pathRole.isEmpty() )
|
||||||
|
{
|
||||||
return displayRole;
|
return displayRole;
|
||||||
|
}
|
||||||
|
|
||||||
return tr( "%1 (%2)" ).arg( displayRole, pathRole );
|
return tr( "%1 (%2)" ).arg( displayRole, pathRole );
|
||||||
}
|
}
|
||||||
@ -163,14 +164,18 @@ namespace Calamares
|
|||||||
int
|
int
|
||||||
findBootloader( const QAbstractItemModel* model, const QString& path )
|
findBootloader( const QAbstractItemModel* model, const QString& path )
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < model->rowCount(); ++i)
|
for ( int i = 0; i < model->rowCount(); ++i )
|
||||||
{
|
{
|
||||||
const auto index = model->index( i, 0, QModelIndex() );
|
const auto index = model->index( i, 0, QModelIndex() );
|
||||||
if ( !index.isValid() )
|
if ( !index.isValid() )
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
QVariant var = model->data( index, BootLoaderModel::BootLoaderPathRole );
|
QVariant var = model->data( index, BootLoaderModel::BootLoaderPathRole );
|
||||||
if ( var.isValid() && var.toString() == path )
|
if ( var.isValid() && var.toString() == path )
|
||||||
|
{
|
||||||
return i;
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
@ -191,7 +196,7 @@ restoreSelectedBootLoader( QComboBox& combo, const QString& path )
|
|||||||
{
|
{
|
||||||
combo.setCurrentIndex( 0 );
|
combo.setCurrentIndex( 0 );
|
||||||
}
|
}
|
||||||
else if ( (r = findBootloader( model, path )) >= 0 )
|
else if ( ( r = findBootloader( model, path ) ) >= 0 )
|
||||||
{
|
{
|
||||||
combo.setCurrentIndex( r );
|
combo.setCurrentIndex( r );
|
||||||
}
|
}
|
||||||
@ -201,4 +206,4 @@ restoreSelectedBootLoader( QComboBox& combo, const QString& path )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace Calamares
|
||||||
|
@ -66,18 +66,18 @@ private:
|
|||||||
|
|
||||||
namespace Calamares
|
namespace Calamares
|
||||||
{
|
{
|
||||||
/** @brief Returns the row number of boot-loader @p path (e.g. /dev/sda)
|
/** @brief Returns the row number of boot-loader @p path (e.g. /dev/sda)
|
||||||
*
|
*
|
||||||
* Assuming the @p model is a BootLoaderModel, will return a row number
|
* Assuming the @p model is a BootLoaderModel, will return a row number
|
||||||
* in the model. Returns -1 otherwise.
|
* in the model. Returns -1 otherwise.
|
||||||
*/
|
*/
|
||||||
int findBootloader( const QAbstractItemModel* model, const QString& path );
|
int findBootloader( const QAbstractItemModel* model, const QString& path );
|
||||||
|
|
||||||
/** @brief Tries to set @p path as selected item in @p combo
|
/** @brief Tries to set @p path as selected item in @p combo
|
||||||
*
|
*
|
||||||
* Matches a boot-loader install path (e.g. /dev/sda) with a model
|
* Matches a boot-loader install path (e.g. /dev/sda) with a model
|
||||||
* row and sets that as the current row.
|
* row and sets that as the current row.
|
||||||
*/
|
*/
|
||||||
void restoreSelectedBootLoader( QComboBox& combo, const QString& path );
|
void restoreSelectedBootLoader( QComboBox& combo, const QString& path );
|
||||||
} // namespace
|
} // namespace Calamares
|
||||||
#endif /* BOOTLOADERMODEL_H */
|
#endif /* BOOTLOADERMODEL_H */
|
||||||
|
@ -33,27 +33,25 @@
|
|||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
using CalamaresUtils::Partition::PartitionIterator;
|
|
||||||
using CalamaresUtils::Partition::isPartitionFreeSpace;
|
using CalamaresUtils::Partition::isPartitionFreeSpace;
|
||||||
using CalamaresUtils::Partition::isPartitionNew;
|
using CalamaresUtils::Partition::isPartitionNew;
|
||||||
|
using CalamaresUtils::Partition::PartitionIterator;
|
||||||
|
|
||||||
static const int NUM_PARTITION_COLORS = 5;
|
static const int NUM_PARTITION_COLORS = 5;
|
||||||
static const int NUM_NEW_PARTITION_COLORS = 4;
|
static const int NUM_NEW_PARTITION_COLORS = 4;
|
||||||
//Let's try to use the Breeze palette
|
//Let's try to use the Breeze palette
|
||||||
static const QColor PARTITION_COLORS[ NUM_PARTITION_COLORS ] =
|
static const QColor PARTITION_COLORS[ NUM_PARTITION_COLORS ] = {
|
||||||
{
|
"#2980b9", //Dark Plasma Blue
|
||||||
"#2980b9", //Dark Plasma Blue
|
"#27ae60", //Dark Icon Green
|
||||||
"#27ae60", //Dark Icon Green
|
"#c9ce3b", //Dirty Yellow
|
||||||
"#c9ce3b", //Dirty Yellow
|
"#3daee9", //Plasma Blue
|
||||||
"#3daee9", //Plasma Blue
|
"#9b59b6", //Purple
|
||||||
"#9b59b6", //Purple
|
|
||||||
};
|
};
|
||||||
static const QColor NEW_PARTITION_COLORS[ NUM_NEW_PARTITION_COLORS ] =
|
static const QColor NEW_PARTITION_COLORS[ NUM_NEW_PARTITION_COLORS ] = {
|
||||||
{
|
"#c0392b", //Dark Icon Red
|
||||||
"#c0392b", //Dark Icon Red
|
"#f39c1f", //Dark Icon Yellow
|
||||||
"#f39c1f", //Dark Icon Yellow
|
"#f1b7bc", //Light Salmon
|
||||||
"#f1b7bc", //Light Salmon
|
"#fed999", //Light Orange
|
||||||
"#fed999", //Light Orange
|
|
||||||
};
|
};
|
||||||
static QColor FREE_SPACE_COLOR = "#777777";
|
static QColor FREE_SPACE_COLOR = "#777777";
|
||||||
static QColor EXTENDED_COLOR = "#aaaaaa";
|
static QColor EXTENDED_COLOR = "#aaaaaa";
|
||||||
@ -65,12 +63,14 @@ static QMap< QString, QColor > s_partitionColorsCache;
|
|||||||
namespace ColorUtils
|
namespace ColorUtils
|
||||||
{
|
{
|
||||||
|
|
||||||
QColor freeSpaceColor()
|
QColor
|
||||||
|
freeSpaceColor()
|
||||||
{
|
{
|
||||||
return FREE_SPACE_COLOR;
|
return FREE_SPACE_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor unknownDisklabelColor()
|
QColor
|
||||||
|
unknownDisklabelColor()
|
||||||
{
|
{
|
||||||
return UNKNOWN_DISKLABEL_COLOR;
|
return UNKNOWN_DISKLABEL_COLOR;
|
||||||
}
|
}
|
||||||
@ -78,9 +78,10 @@ QColor unknownDisklabelColor()
|
|||||||
PartitionNode*
|
PartitionNode*
|
||||||
_findRootForPartition( PartitionNode* partition )
|
_findRootForPartition( PartitionNode* partition )
|
||||||
{
|
{
|
||||||
if ( partition->isRoot() ||
|
if ( partition->isRoot() || !partition->parent() )
|
||||||
!partition->parent() )
|
{
|
||||||
return partition;
|
return partition;
|
||||||
|
}
|
||||||
|
|
||||||
return _findRootForPartition( partition->parent() );
|
return _findRootForPartition( partition->parent() );
|
||||||
}
|
}
|
||||||
@ -95,23 +96,30 @@ colorForPartition( Partition* partition )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( isPartitionFreeSpace( partition ) )
|
if ( isPartitionFreeSpace( partition ) )
|
||||||
|
{
|
||||||
return FREE_SPACE_COLOR;
|
return FREE_SPACE_COLOR;
|
||||||
|
}
|
||||||
if ( partition->roles().has( PartitionRole::Extended ) )
|
if ( partition->roles().has( PartitionRole::Extended ) )
|
||||||
|
{
|
||||||
return EXTENDED_COLOR;
|
return EXTENDED_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone &&
|
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone
|
||||||
!partition->fileSystem().uuid().isEmpty() )
|
&& !partition->fileSystem().uuid().isEmpty() )
|
||||||
{
|
{
|
||||||
if ( partition->fileSystem().type() == FileSystem::Luks )
|
if ( partition->fileSystem().type() == FileSystem::Luks )
|
||||||
{
|
{
|
||||||
FS::luks& luksFs = dynamic_cast< FS::luks& >( partition->fileSystem() );
|
FS::luks& luksFs = dynamic_cast< FS::luks& >( partition->fileSystem() );
|
||||||
if ( !luksFs.outerUuid().isEmpty() &&
|
if ( !luksFs.outerUuid().isEmpty() && s_partitionColorsCache.contains( luksFs.outerUuid() ) )
|
||||||
s_partitionColorsCache.contains( luksFs.outerUuid() ) )
|
{
|
||||||
return s_partitionColorsCache[ luksFs.outerUuid() ];
|
return s_partitionColorsCache[ luksFs.outerUuid() ];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( s_partitionColorsCache.contains( partition->fileSystem().uuid() ) )
|
if ( s_partitionColorsCache.contains( partition->fileSystem().uuid() ) )
|
||||||
|
{
|
||||||
return s_partitionColorsCache[ partition->fileSystem().uuid() ];
|
return s_partitionColorsCache[ partition->fileSystem().uuid() ];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// No partition-specific color needed, pick one from our list, but skip
|
// No partition-specific color needed, pick one from our list, but skip
|
||||||
@ -122,27 +130,30 @@ colorForPartition( Partition* partition )
|
|||||||
Q_ASSERT( table );
|
Q_ASSERT( table );
|
||||||
int colorIdx = 0;
|
int colorIdx = 0;
|
||||||
int newColorIdx = 0;
|
int newColorIdx = 0;
|
||||||
for ( PartitionIterator it = PartitionIterator::begin( table );
|
for ( PartitionIterator it = PartitionIterator::begin( table ); it != PartitionIterator::end( table ); ++it )
|
||||||
it != PartitionIterator::end( table );
|
|
||||||
++it )
|
|
||||||
{
|
{
|
||||||
Partition* child = *it;
|
Partition* child = *it;
|
||||||
if ( child == partition )
|
if ( child == partition )
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
if ( !isPartitionFreeSpace( child ) &&
|
}
|
||||||
!child->hasChildren() )
|
if ( !isPartitionFreeSpace( child ) && !child->hasChildren() )
|
||||||
{
|
{
|
||||||
if ( isPartitionNew( child ) )
|
if ( isPartitionNew( child ) )
|
||||||
|
{
|
||||||
++newColorIdx;
|
++newColorIdx;
|
||||||
|
}
|
||||||
++colorIdx;
|
++colorIdx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isPartitionNew( partition ) )
|
if ( isPartitionNew( partition ) )
|
||||||
|
{
|
||||||
return NEW_PARTITION_COLORS[ newColorIdx % NUM_NEW_PARTITION_COLORS ];
|
return NEW_PARTITION_COLORS[ newColorIdx % NUM_NEW_PARTITION_COLORS ];
|
||||||
|
}
|
||||||
|
|
||||||
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone &&
|
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone
|
||||||
!partition->fileSystem().uuid().isEmpty() )
|
&& !partition->fileSystem().uuid().isEmpty() )
|
||||||
{
|
{
|
||||||
if ( partition->fileSystem().type() == FileSystem::Luks )
|
if ( partition->fileSystem().type() == FileSystem::Luks )
|
||||||
{
|
{
|
||||||
@ -168,17 +179,17 @@ colorForPartitionInFreeSpace( Partition* partition )
|
|||||||
PartitionTable* table = dynamic_cast< PartitionTable* >( parent );
|
PartitionTable* table = dynamic_cast< PartitionTable* >( parent );
|
||||||
Q_ASSERT( table );
|
Q_ASSERT( table );
|
||||||
int newColorIdx = 0;
|
int newColorIdx = 0;
|
||||||
for ( PartitionIterator it = PartitionIterator::begin( table );
|
for ( PartitionIterator it = PartitionIterator::begin( table ); it != PartitionIterator::end( table ); ++it )
|
||||||
it != PartitionIterator::end( table );
|
|
||||||
++it )
|
|
||||||
{
|
{
|
||||||
Partition* child = *it;
|
Partition* child = *it;
|
||||||
if ( child == partition )
|
if ( child == partition )
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
if ( !isPartitionFreeSpace( child ) &&
|
}
|
||||||
!child->hasChildren() &&
|
if ( !isPartitionFreeSpace( child ) && !child->hasChildren() && isPartitionNew( child ) )
|
||||||
isPartitionNew( child ) )
|
{
|
||||||
++newColorIdx;
|
++newColorIdx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NEW_PARTITION_COLORS[ newColorIdx % NUM_NEW_PARTITION_COLORS ];
|
return NEW_PARTITION_COLORS[ newColorIdx % NUM_NEW_PARTITION_COLORS ];
|
||||||
}
|
}
|
||||||
@ -190,4 +201,4 @@ invalidateCache()
|
|||||||
s_partitionColorsCache.clear();
|
s_partitionColorsCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace ColorUtils
|
||||||
|
@ -53,6 +53,6 @@ QColor colorForPartitionInFreeSpace( Partition* freeSpacePartition );
|
|||||||
*/
|
*/
|
||||||
void invalidateCache();
|
void invalidateCache();
|
||||||
|
|
||||||
}
|
} // namespace ColorUtils
|
||||||
|
|
||||||
#endif /* COLORUTILS_H */
|
#endif /* COLORUTILS_H */
|
||||||
|
@ -50,7 +50,9 @@ hasRootPartition( Device* device )
|
|||||||
{
|
{
|
||||||
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
|
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
|
||||||
if ( ( *it )->mountPoint() == "/" )
|
if ( ( *it )->mountPoint() == "/" )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,17 +71,22 @@ isIso9660( const Device* device )
|
|||||||
{
|
{
|
||||||
const QString path = device->deviceNode();
|
const QString path = device->deviceNode();
|
||||||
if ( path.isEmpty() )
|
if ( path.isEmpty() )
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
if ( blkIdCheckIso9660( path ) )
|
if ( blkIdCheckIso9660( path ) )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if ( device->partitionTable() &&
|
if ( device->partitionTable() && !device->partitionTable()->children().isEmpty() )
|
||||||
!device->partitionTable()->children().isEmpty() )
|
|
||||||
{
|
{
|
||||||
for ( const Partition* partition : device->partitionTable()->children() )
|
for ( const Partition* partition : device->partitionTable()->children() )
|
||||||
{
|
{
|
||||||
if ( blkIdCheckIso9660( partition->partitionPath() ) )
|
if ( blkIdCheckIso9660( partition->partitionPath() ) )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -87,7 +94,7 @@ isIso9660( const Device* device )
|
|||||||
|
|
||||||
|
|
||||||
static inline QDebug&
|
static inline QDebug&
|
||||||
operator <<( QDebug& s, QList< Device* >::iterator& it )
|
operator<<( QDebug& s, QList< Device* >::iterator& it )
|
||||||
{
|
{
|
||||||
s << ( ( *it ) ? ( *it )->deviceNode() : QString( "<null device>" ) );
|
s << ( ( *it ) ? ( *it )->deviceNode() : QString( "<null device>" ) );
|
||||||
return s;
|
return s;
|
||||||
@ -96,7 +103,7 @@ operator <<( QDebug& s, QList< Device* >::iterator& it )
|
|||||||
using DeviceList = QList< Device* >;
|
using DeviceList = QList< Device* >;
|
||||||
|
|
||||||
static inline DeviceList::iterator
|
static inline DeviceList::iterator
|
||||||
erase(DeviceList& l, DeviceList::iterator& it)
|
erase( DeviceList& l, DeviceList::iterator& it )
|
||||||
{
|
{
|
||||||
Device* p = *it;
|
Device* p = *it;
|
||||||
auto r = l.erase( it );
|
auto r = l.erase( it );
|
||||||
@ -104,13 +111,14 @@ erase(DeviceList& l, DeviceList::iterator& it)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList< Device* > getDevices( DeviceType which, qint64 minimumSize )
|
QList< Device* >
|
||||||
|
getDevices( DeviceType which, qint64 minimumSize )
|
||||||
{
|
{
|
||||||
bool writableOnly = (which == DeviceType::WritableOnly);
|
bool writableOnly = ( which == DeviceType::WritableOnly );
|
||||||
|
|
||||||
CoreBackend* backend = CoreBackendManager::self()->backend();
|
CoreBackend* backend = CoreBackendManager::self()->backend();
|
||||||
#if defined( WITH_KPMCORE4API )
|
#if defined( WITH_KPMCORE4API )
|
||||||
DeviceList devices = backend->scanDevices( /* not includeReadOnly, not includeLoopback */ ScanFlag(0) );
|
DeviceList devices = backend->scanDevices( /* not includeReadOnly, not includeLoopback */ ScanFlag( 0 ) );
|
||||||
#else
|
#else
|
||||||
DeviceList devices = backend->scanDevices( /* excludeReadOnly */ true );
|
DeviceList devices = backend->scanDevices( /* excludeReadOnly */ true );
|
||||||
#endif
|
#endif
|
||||||
@ -128,14 +136,12 @@ QList< Device* > getDevices( DeviceType which, qint64 minimumSize )
|
|||||||
if ( !( *it ) )
|
if ( !( *it ) )
|
||||||
{
|
{
|
||||||
cDebug() << Logger::SubEntry << "Skipping nullptr device";
|
cDebug() << Logger::SubEntry << "Skipping nullptr device";
|
||||||
it = erase( devices, it);
|
it = erase( devices, it );
|
||||||
}
|
}
|
||||||
else if ( ( *it )->deviceNode().startsWith( "/dev/zram" )
|
else if ( ( *it )->deviceNode().startsWith( "/dev/zram" ) )
|
||||||
)
|
|
||||||
{
|
{
|
||||||
cDebug() << Logger::SubEntry << "Removing zram" << it;
|
cDebug() << Logger::SubEntry << "Removing zram" << it;
|
||||||
it = erase( devices, it );
|
it = erase( devices, it );
|
||||||
|
|
||||||
}
|
}
|
||||||
else if ( writableOnly && hasRootPartition( *it ) )
|
else if ( writableOnly && hasRootPartition( *it ) )
|
||||||
{
|
{
|
||||||
@ -147,13 +153,15 @@ QList< Device* > getDevices( DeviceType which, qint64 minimumSize )
|
|||||||
cDebug() << Logger::SubEntry << "Removing device with iso9660 filesystem (probably a CD) on it" << it;
|
cDebug() << Logger::SubEntry << "Removing device with iso9660 filesystem (probably a CD) on it" << it;
|
||||||
it = erase( devices, it );
|
it = erase( devices, it );
|
||||||
}
|
}
|
||||||
else if ( (minimumSize >= 0) && !( (*it)->capacity() > minimumSize ) )
|
else if ( ( minimumSize >= 0 ) && !( ( *it )->capacity() > minimumSize ) )
|
||||||
{
|
{
|
||||||
cDebug() << Logger::SubEntry << "Removing too-small" << it;
|
cDebug() << Logger::SubEntry << "Removing too-small" << it;
|
||||||
it = erase( devices, it );
|
it = erase( devices, it );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
++it;
|
++it;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return devices;
|
return devices;
|
||||||
|
@ -28,7 +28,11 @@ class Device;
|
|||||||
namespace PartUtils
|
namespace PartUtils
|
||||||
{
|
{
|
||||||
|
|
||||||
enum class DeviceType { All, WritableOnly };
|
enum class DeviceType
|
||||||
|
{
|
||||||
|
All,
|
||||||
|
WritableOnly
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets a list of storage devices.
|
* @brief Gets a list of storage devices.
|
||||||
@ -43,6 +47,6 @@ enum class DeviceType { All, WritableOnly };
|
|||||||
*/
|
*/
|
||||||
QList< Device* > getDevices( DeviceType which = DeviceType::All, qint64 minimumSize = -1 );
|
QList< Device* > getDevices( DeviceType which = DeviceType::All, qint64 minimumSize = -1 );
|
||||||
|
|
||||||
}
|
} // namespace PartUtils
|
||||||
|
|
||||||
#endif // DEVICELIST_H
|
#endif // DEVICELIST_H
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
// KF5
|
// KF5
|
||||||
#include <KFormat>
|
#include <KFormat>
|
||||||
|
|
||||||
#include <QStandardItemModel>
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
// STL
|
// STL
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -39,8 +39,7 @@
|
|||||||
static void
|
static void
|
||||||
sortDevices( DeviceModel::DeviceList& l )
|
sortDevices( DeviceModel::DeviceList& l )
|
||||||
{
|
{
|
||||||
std::sort( l.begin(), l.end(), []( const Device* dev1, const Device* dev2 )
|
std::sort( l.begin(), l.end(), []( const Device* dev1, const Device* dev2 ) {
|
||||||
{
|
|
||||||
return dev1->deviceNode() < dev2->deviceNode();
|
return dev1->deviceNode() < dev2->deviceNode();
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
@ -50,9 +49,7 @@ DeviceModel::DeviceModel( QObject* parent )
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceModel::~DeviceModel()
|
DeviceModel::~DeviceModel() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DeviceModel::init( const DeviceList& devices )
|
DeviceModel::init( const DeviceList& devices )
|
||||||
@ -74,7 +71,9 @@ DeviceModel::data( const QModelIndex& index, int role ) const
|
|||||||
{
|
{
|
||||||
int row = index.row();
|
int row = index.row();
|
||||||
if ( row < 0 || row >= m_devices.count() )
|
if ( row < 0 || row >= m_devices.count() )
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
Device* device = m_devices.at( row );
|
Device* device = m_devices.at( row );
|
||||||
|
|
||||||
@ -83,16 +82,18 @@ DeviceModel::data( const QModelIndex& index, int role ) const
|
|||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
if ( device->name().isEmpty() )
|
if ( device->name().isEmpty() )
|
||||||
|
{
|
||||||
return device->deviceNode();
|
return device->deviceNode();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( device->logicalSize() >= 0 && device->totalLogical() >= 0 )
|
if ( device->logicalSize() >= 0 && device->totalLogical() >= 0 )
|
||||||
{
|
{
|
||||||
//: device[name] - size[number] (device-node[name])
|
//: device[name] - size[number] (device-node[name])
|
||||||
return tr( "%1 - %2 (%3)" )
|
return tr( "%1 - %2 (%3)" )
|
||||||
.arg( device->name() )
|
.arg( device->name() )
|
||||||
.arg( KFormat().formatByteSize( device->capacity() ) )
|
.arg( KFormat().formatByteSize( device->capacity() ) )
|
||||||
.arg( device->deviceNode() );
|
.arg( device->deviceNode() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -100,16 +101,14 @@ DeviceModel::data( const QModelIndex& index, int role ) const
|
|||||||
// always has 1B capacity), so don't show it for a while.
|
// always has 1B capacity), so don't show it for a while.
|
||||||
//
|
//
|
||||||
//: device[name] - (device-node[name])
|
//: device[name] - (device-node[name])
|
||||||
return tr( "%1 - (%2)" )
|
return tr( "%1 - (%2)" ).arg( device->name() ).arg( device->deviceNode() );
|
||||||
.arg( device->name() )
|
|
||||||
.arg( device->deviceNode() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
return CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionDisk,
|
return CalamaresUtils::defaultPixmap(
|
||||||
CalamaresUtils::Original,
|
CalamaresUtils::PartitionDisk,
|
||||||
QSize( CalamaresUtils::defaultIconSize().width() * 3,
|
CalamaresUtils::Original,
|
||||||
CalamaresUtils::defaultIconSize().height() * 3 ) );
|
QSize( CalamaresUtils::defaultIconSize().width() * 3, CalamaresUtils::defaultIconSize().height() * 3 ) );
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -121,7 +120,9 @@ DeviceModel::deviceForIndex( const QModelIndex& index ) const
|
|||||||
{
|
{
|
||||||
int row = index.row();
|
int row = index.row();
|
||||||
if ( row < 0 || row >= m_devices.count() )
|
if ( row < 0 || row >= m_devices.count() )
|
||||||
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
return m_devices.at( row );
|
return m_devices.at( row );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +135,9 @@ DeviceModel::swapDevice( Device* oldDevice, Device* newDevice )
|
|||||||
|
|
||||||
int indexOfOldDevice = m_devices.indexOf( oldDevice );
|
int indexOfOldDevice = m_devices.indexOf( oldDevice );
|
||||||
if ( indexOfOldDevice < 0 )
|
if ( indexOfOldDevice < 0 )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_devices[ indexOfOldDevice ] = newDevice;
|
m_devices[ indexOfOldDevice ] = newDevice;
|
||||||
|
|
||||||
@ -142,7 +145,7 @@ DeviceModel::swapDevice( Device* oldDevice, Device* newDevice )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DeviceModel::addDevice( Device *device )
|
DeviceModel::addDevice( Device* device )
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_devices << device;
|
m_devices << device;
|
||||||
@ -151,7 +154,7 @@ DeviceModel::addDevice( Device *device )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DeviceModel::removeDevice( Device *device )
|
DeviceModel::removeDevice( Device* device )
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_devices.removeAll( device );
|
m_devices.removeAll( device );
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
#define DEVICEMODEL_H
|
#define DEVICEMODEL_H
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QScopedPointer>
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
class Device;
|
class Device;
|
||||||
class PartitionModel;
|
class PartitionModel;
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
// KPMcore
|
// KPMcore
|
||||||
|
#include <kpmcore/backend/corebackendmanager.h>
|
||||||
#include <kpmcore/core/device.h>
|
#include <kpmcore/core/device.h>
|
||||||
#include <kpmcore/core/partition.h>
|
#include <kpmcore/core/partition.h>
|
||||||
#include <kpmcore/fs/filesystemfactory.h>
|
#include <kpmcore/fs/filesystemfactory.h>
|
||||||
#include <kpmcore/backend/corebackendmanager.h>
|
|
||||||
#include <kpmcore/fs/luks.h>
|
#include <kpmcore/fs/luks.h>
|
||||||
|
|
||||||
using CalamaresUtils::Partition::PartitionIterator;
|
using CalamaresUtils::Partition::PartitionIterator;
|
||||||
@ -43,7 +43,9 @@ findPartitionByMountPoint( const QList< Device* >& devices, const QString& mount
|
|||||||
for ( auto device : devices )
|
for ( auto device : devices )
|
||||||
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
|
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
|
||||||
if ( PartitionInfo::mountPoint( *it ) == mountPoint )
|
if ( PartitionInfo::mountPoint( *it ) == mountPoint )
|
||||||
|
{
|
||||||
return *it;
|
return *it;
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,21 +59,19 @@ createNewPartition( PartitionNode* parent,
|
|||||||
qint64 lastSector,
|
qint64 lastSector,
|
||||||
PartitionTable::Flags flags )
|
PartitionTable::Flags flags )
|
||||||
{
|
{
|
||||||
FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector
|
FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector, device.logicalSize() );
|
||||||
,device.logicalSize()
|
return new Partition( parent,
|
||||||
);
|
device,
|
||||||
return new Partition(
|
role,
|
||||||
parent,
|
fs,
|
||||||
device,
|
fs->firstSector(),
|
||||||
role,
|
fs->lastSector(),
|
||||||
fs, fs->firstSector(), fs->lastSector(),
|
QString() /* path */,
|
||||||
QString() /* path */,
|
KPM_PARTITION_FLAG( None ) /* availableFlags */,
|
||||||
KPM_PARTITION_FLAG(None) /* availableFlags */,
|
QString() /* mountPoint */,
|
||||||
QString() /* mountPoint */,
|
false /* mounted */,
|
||||||
false /* mounted */,
|
flags /* activeFlags */,
|
||||||
flags /* activeFlags */,
|
KPM_PARTITION_STATE( New ) );
|
||||||
KPM_PARTITION_STATE(New)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -87,14 +87,12 @@ createNewEncryptedPartition( PartitionNode* parent,
|
|||||||
{
|
{
|
||||||
PartitionRole::Roles newRoles = role.roles();
|
PartitionRole::Roles newRoles = role.roles();
|
||||||
if ( !role.has( PartitionRole::Luks ) )
|
if ( !role.has( PartitionRole::Luks ) )
|
||||||
|
{
|
||||||
newRoles |= PartitionRole::Luks;
|
newRoles |= PartitionRole::Luks;
|
||||||
|
}
|
||||||
|
|
||||||
FS::luks* fs = dynamic_cast< FS::luks* >(
|
FS::luks* fs = dynamic_cast< FS::luks* >(
|
||||||
FileSystemFactory::create( FileSystem::Luks,
|
FileSystemFactory::create( FileSystem::Luks, firstSector, lastSector, device.logicalSize() ) );
|
||||||
firstSector,
|
|
||||||
lastSector
|
|
||||||
,device.logicalSize()
|
|
||||||
) );
|
|
||||||
if ( !fs )
|
if ( !fs )
|
||||||
{
|
{
|
||||||
cError() << "cannot create LUKS filesystem. Giving up.";
|
cError() << "cannot create LUKS filesystem. Giving up.";
|
||||||
@ -106,13 +104,15 @@ createNewEncryptedPartition( PartitionNode* parent,
|
|||||||
Partition* p = new Partition( parent,
|
Partition* p = new Partition( parent,
|
||||||
device,
|
device,
|
||||||
PartitionRole( newRoles ),
|
PartitionRole( newRoles ),
|
||||||
fs, fs->firstSector(), fs->lastSector(),
|
fs,
|
||||||
|
fs->firstSector(),
|
||||||
|
fs->lastSector(),
|
||||||
QString() /* path */,
|
QString() /* path */,
|
||||||
KPM_PARTITION_FLAG(None) /* availableFlags */,
|
KPM_PARTITION_FLAG( None ) /* availableFlags */,
|
||||||
QString() /* mountPoint */,
|
QString() /* mountPoint */,
|
||||||
false /* mounted */,
|
false /* mounted */,
|
||||||
flags /* activeFlags */,
|
flags /* activeFlags */,
|
||||||
KPM_PARTITION_STATE(New) );
|
KPM_PARTITION_STATE( New ) );
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,11 +121,7 @@ Partition*
|
|||||||
clonePartition( Device* device, Partition* partition )
|
clonePartition( Device* device, Partition* partition )
|
||||||
{
|
{
|
||||||
FileSystem* fs = FileSystemFactory::create(
|
FileSystem* fs = FileSystemFactory::create(
|
||||||
partition->fileSystem().type(),
|
partition->fileSystem().type(), partition->firstSector(), partition->lastSector(), device->logicalSize() );
|
||||||
partition->firstSector(),
|
|
||||||
partition->lastSector()
|
|
||||||
,device->logicalSize()
|
|
||||||
);
|
|
||||||
return new Partition( partition->parent(),
|
return new Partition( partition->parent(),
|
||||||
*device,
|
*device,
|
||||||
partition->roles(),
|
partition->roles(),
|
||||||
@ -136,4 +132,4 @@ clonePartition( Device* device, Partition* partition )
|
|||||||
partition->activeFlags() );
|
partition->activeFlags() );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace KPMHelpers
|
||||||
|
@ -35,12 +35,12 @@ class PartitionNode;
|
|||||||
class PartitionRole;
|
class PartitionRole;
|
||||||
|
|
||||||
#if defined( WITH_KPMCORE4API )
|
#if defined( WITH_KPMCORE4API )
|
||||||
#define KPM_PARTITION_FLAG(x) PartitionTable::Flag::x
|
#define KPM_PARTITION_FLAG( x ) PartitionTable::Flag::x
|
||||||
#define KPM_PARTITION_STATE(x) Partition::State::x
|
#define KPM_PARTITION_STATE( x ) Partition::State::x
|
||||||
#define KPM_PARTITION_FLAG_ESP PartitionTable::Flag::Boot
|
#define KPM_PARTITION_FLAG_ESP PartitionTable::Flag::Boot
|
||||||
#else
|
#else
|
||||||
#define KPM_PARTITION_FLAG(x) PartitionTable::Flag##x
|
#define KPM_PARTITION_FLAG( x ) PartitionTable::Flag##x
|
||||||
#define KPM_PARTITION_STATE(x) Partition::State##x
|
#define KPM_PARTITION_STATE( x ) Partition::State##x
|
||||||
#define KPM_PARTITION_FLAG_ESP PartitionTable::FlagEsp
|
#define KPM_PARTITION_FLAG_ESP PartitionTable::FlagEsp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -79,6 +79,6 @@ Partition* createNewEncryptedPartition( PartitionNode* parent,
|
|||||||
|
|
||||||
Partition* clonePartition( Device* device, Partition* partition );
|
Partition* clonePartition( Device* device, Partition* partition );
|
||||||
|
|
||||||
}
|
} // namespace KPMHelpers
|
||||||
|
|
||||||
#endif /* KPMHELPERS_H */
|
#endif /* KPMHELPERS_H */
|
||||||
|
@ -32,7 +32,7 @@ struct FstabEntry
|
|||||||
int pass;
|
int pass;
|
||||||
|
|
||||||
/// Does this entry make sense and is it complete?
|
/// Does this entry make sense and is it complete?
|
||||||
bool isValid() const; // implemented in Partutils.cpp
|
bool isValid() const; // implemented in Partutils.cpp
|
||||||
|
|
||||||
/** @brief Create an entry from a live of /etc/fstab
|
/** @brief Create an entry from a live of /etc/fstab
|
||||||
*
|
*
|
||||||
@ -41,7 +41,7 @@ struct FstabEntry
|
|||||||
* If the string isn't valid (e.g. comment-line, or broken
|
* If the string isn't valid (e.g. comment-line, or broken
|
||||||
* fstab entry) then the entry that is returned is invalid.
|
* fstab entry) then the entry that is returned is invalid.
|
||||||
*/
|
*/
|
||||||
static FstabEntry fromEtcFstab( const QString& ); // implemented in Partutils.cpp
|
static FstabEntry fromEtcFstab( const QString& ); // implemented in Partutils.cpp
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QList< FstabEntry > FstabEntryList;
|
typedef QList< FstabEntry > FstabEntryList;
|
||||||
@ -59,4 +59,4 @@ struct OsproberEntry
|
|||||||
|
|
||||||
typedef QList< OsproberEntry > OsproberEntryList;
|
typedef QList< OsproberEntry > OsproberEntryList;
|
||||||
|
|
||||||
#endif // OSPROBERENTRY_H
|
#endif // OSPROBERENTRY_H
|
||||||
|
@ -52,17 +52,25 @@ QString
|
|||||||
convenienceName( const Partition* const candidate )
|
convenienceName( const Partition* const candidate )
|
||||||
{
|
{
|
||||||
if ( !candidate->mountPoint().isEmpty() )
|
if ( !candidate->mountPoint().isEmpty() )
|
||||||
|
{
|
||||||
return candidate->mountPoint();
|
return candidate->mountPoint();
|
||||||
|
}
|
||||||
if ( !candidate->partitionPath().isEmpty() )
|
if ( !candidate->partitionPath().isEmpty() )
|
||||||
|
{
|
||||||
return candidate->partitionPath();
|
return candidate->partitionPath();
|
||||||
|
}
|
||||||
if ( !candidate->devicePath().isEmpty() )
|
if ( !candidate->devicePath().isEmpty() )
|
||||||
|
{
|
||||||
return candidate->devicePath();
|
return candidate->devicePath();
|
||||||
|
}
|
||||||
if ( !candidate->deviceNode().isEmpty() )
|
if ( !candidate->deviceNode().isEmpty() )
|
||||||
|
{
|
||||||
return candidate->devicePath();
|
return candidate->devicePath();
|
||||||
|
}
|
||||||
|
|
||||||
QString p;
|
QString p;
|
||||||
QTextStream s( &p );
|
QTextStream s( &p );
|
||||||
s << (void *)candidate;
|
s << (void*)candidate;
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -111,9 +119,9 @@ canBeReplaced( Partition* candidate )
|
|||||||
Logger::CDebug deb;
|
Logger::CDebug deb;
|
||||||
deb << Logger::SubEntry << "NO, insufficient storage";
|
deb << Logger::SubEntry << "NO, insufficient storage";
|
||||||
deb << Logger::Continuation << "Required storage B:" << requiredStorageB
|
deb << Logger::Continuation << "Required storage B:" << requiredStorageB
|
||||||
<< QString( "(%1GiB)" ).arg( requiredStorageGiB );
|
<< QString( "(%1GiB)" ).arg( requiredStorageGiB );
|
||||||
deb << Logger::Continuation << "Available storage B:" << availableStorageB
|
deb << Logger::Continuation << "Available storage B:" << availableStorageB
|
||||||
<< QString( "(%1GiB)" ).arg( CalamaresUtils::BytesToGiB( availableStorageB ) );
|
<< QString( "(%1GiB)" ).arg( CalamaresUtils::BytesToGiB( availableStorageB ) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,11 +137,10 @@ canBeResized( Partition* candidate )
|
|||||||
}
|
}
|
||||||
|
|
||||||
cDebug() << "Checking if" << convenienceName( candidate ) << "can be resized.";
|
cDebug() << "Checking if" << convenienceName( candidate ) << "can be resized.";
|
||||||
if ( !candidate->fileSystem().supportGrow() ||
|
if ( !candidate->fileSystem().supportGrow() || !candidate->fileSystem().supportShrink() )
|
||||||
!candidate->fileSystem().supportShrink() )
|
|
||||||
{
|
{
|
||||||
cDebug() << Logger::SubEntry << "NO, filesystem" << candidate->fileSystem().name()
|
cDebug() << Logger::SubEntry << "NO, filesystem" << candidate->fileSystem().name()
|
||||||
<< "does not support resize.";
|
<< "does not support resize.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,8 +167,8 @@ canBeResized( Partition* candidate )
|
|||||||
|
|
||||||
if ( table->numPrimaries() >= table->maxPrimaries() )
|
if ( table->numPrimaries() >= table->maxPrimaries() )
|
||||||
{
|
{
|
||||||
cDebug() << Logger::SubEntry << "NO, partition table already has"
|
cDebug() << Logger::SubEntry << "NO, partition table already has" << table->maxPrimaries()
|
||||||
<< table->maxPrimaries() << "primary partitions.";
|
<< "primary partitions.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,11 +196,11 @@ canBeResized( Partition* candidate )
|
|||||||
Logger::CDebug deb;
|
Logger::CDebug deb;
|
||||||
deb << Logger::SubEntry << "NO, insufficient storage";
|
deb << Logger::SubEntry << "NO, insufficient storage";
|
||||||
deb << Logger::Continuation << "Required storage B:" << advisedStorageB
|
deb << Logger::Continuation << "Required storage B:" << advisedStorageB
|
||||||
<< QString( "(%1GiB)" ).arg( advisedStorageGiB );
|
<< QString( "(%1GiB)" ).arg( advisedStorageGiB );
|
||||||
deb << Logger::Continuation << "Available storage B:" << availableStorageB
|
deb << Logger::Continuation << "Available storage B:" << availableStorageB
|
||||||
<< QString( "(%1GiB)" ).arg( CalamaresUtils::BytesToGiB( availableStorageB ) )
|
<< QString( "(%1GiB)" ).arg( CalamaresUtils::BytesToGiB( availableStorageB ) ) << "for"
|
||||||
<< "for" << convenienceName( candidate ) << "length:" << candidate->length()
|
<< convenienceName( candidate ) << "length:" << candidate->length()
|
||||||
<< "sectorsUsed:" << candidate->sectorsUsed() << "fsType:" << candidate->fileSystem().name();
|
<< "sectorsUsed:" << candidate->sectorsUsed() << "fsType:" << candidate->fileSystem().name();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,27 +234,28 @@ canBeResized( PartitionCoreModule* core, const QString& partitionPath )
|
|||||||
static FstabEntryList
|
static FstabEntryList
|
||||||
lookForFstabEntries( const QString& partitionPath )
|
lookForFstabEntries( const QString& partitionPath )
|
||||||
{
|
{
|
||||||
QStringList mountOptions{ "ro" };
|
QStringList mountOptions { "ro" };
|
||||||
|
|
||||||
auto r = CalamaresUtils::System::runCommand(
|
auto r = CalamaresUtils::System::runCommand( CalamaresUtils::System::RunLocation::RunInHost,
|
||||||
CalamaresUtils::System::RunLocation::RunInHost,
|
{ "blkid", "-s", "TYPE", "-o", "value", partitionPath } );
|
||||||
{ "blkid", "-s", "TYPE", "-o", "value", partitionPath }
|
|
||||||
);
|
|
||||||
if ( r.getExitCode() )
|
if ( r.getExitCode() )
|
||||||
|
{
|
||||||
cWarning() << "blkid on" << partitionPath << "failed.";
|
cWarning() << "blkid on" << partitionPath << "failed.";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString fstype = r.getOutput().trimmed();
|
QString fstype = r.getOutput().trimmed();
|
||||||
if ( ( fstype == "ext3" ) || ( fstype == "ext4" ) )
|
if ( ( fstype == "ext3" ) || ( fstype == "ext4" ) )
|
||||||
|
{
|
||||||
mountOptions.append( "noload" );
|
mountOptions.append( "noload" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cDebug() << "Checking device" << partitionPath
|
cDebug() << "Checking device" << partitionPath << "for fstab (fs=" << r.getOutput() << ')';
|
||||||
<< "for fstab (fs=" << r.getOutput() << ')';
|
|
||||||
|
|
||||||
FstabEntryList fstabEntries;
|
FstabEntryList fstabEntries;
|
||||||
|
|
||||||
CalamaresUtils::Partition::TemporaryMount mount( partitionPath, QString(), mountOptions.join(',') );
|
CalamaresUtils::Partition::TemporaryMount mount( partitionPath, QString(), mountOptions.join( ',' ) );
|
||||||
if ( mount.isValid() )
|
if ( mount.isValid() )
|
||||||
{
|
{
|
||||||
QFile fstabFile( mount.path() + "/etc/fstab" );
|
QFile fstabFile( mount.path() + "/etc/fstab" );
|
||||||
@ -256,32 +264,39 @@ lookForFstabEntries( const QString& partitionPath )
|
|||||||
|
|
||||||
if ( fstabFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
if ( fstabFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
||||||
{
|
{
|
||||||
const QStringList fstabLines = QString::fromLocal8Bit( fstabFile.readAll() )
|
const QStringList fstabLines = QString::fromLocal8Bit( fstabFile.readAll() ).split( '\n' );
|
||||||
.split( '\n' );
|
|
||||||
|
|
||||||
for ( const QString& rawLine : fstabLines )
|
for ( const QString& rawLine : fstabLines )
|
||||||
|
{
|
||||||
fstabEntries.append( FstabEntry::fromEtcFstab( rawLine ) );
|
fstabEntries.append( FstabEntry::fromEtcFstab( rawLine ) );
|
||||||
|
}
|
||||||
fstabFile.close();
|
fstabFile.close();
|
||||||
cDebug() << Logger::SubEntry << "got" << fstabEntries.count() << "lines.";
|
cDebug() << Logger::SubEntry << "got" << fstabEntries.count() << "lines.";
|
||||||
std::remove_if( fstabEntries.begin(), fstabEntries.end(), [](const FstabEntry& x) { return !x.isValid(); } );
|
std::remove_if(
|
||||||
|
fstabEntries.begin(), fstabEntries.end(), []( const FstabEntry& x ) { return !x.isValid(); } );
|
||||||
cDebug() << Logger::SubEntry << "got" << fstabEntries.count() << "fstab entries.";
|
cDebug() << Logger::SubEntry << "got" << fstabEntries.count() << "fstab entries.";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
cWarning() << "Could not read fstab from mounted fs";
|
cWarning() << "Could not read fstab from mounted fs";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
cWarning() << "Could not mount existing fs";
|
cWarning() << "Could not mount existing fs";
|
||||||
|
}
|
||||||
|
|
||||||
return fstabEntries;
|
return fstabEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static QString
|
static QString
|
||||||
findPartitionPathForMountPoint( const FstabEntryList& fstab,
|
findPartitionPathForMountPoint( const FstabEntryList& fstab, const QString& mountPoint )
|
||||||
const QString& mountPoint )
|
|
||||||
{
|
{
|
||||||
if ( fstab.isEmpty() )
|
if ( fstab.isEmpty() )
|
||||||
|
{
|
||||||
return QString();
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
for ( const FstabEntry& entry : fstab )
|
for ( const FstabEntry& entry : fstab )
|
||||||
{
|
{
|
||||||
@ -290,7 +305,7 @@ findPartitionPathForMountPoint( const FstabEntryList& fstab,
|
|||||||
QProcess readlink;
|
QProcess readlink;
|
||||||
QString partPath;
|
QString partPath;
|
||||||
|
|
||||||
if ( entry.partitionNode.startsWith( "/dev" ) ) // plain dev node
|
if ( entry.partitionNode.startsWith( "/dev" ) ) // plain dev node
|
||||||
{
|
{
|
||||||
partPath = entry.partitionNode;
|
partPath = entry.partitionNode;
|
||||||
}
|
}
|
||||||
@ -325,17 +340,22 @@ findPartitionPathForMountPoint( const FstabEntryList& fstab,
|
|||||||
|
|
||||||
// At this point we either have /dev/sda1, or /dev/disk/by-something/...
|
// At this point we either have /dev/sda1, or /dev/disk/by-something/...
|
||||||
|
|
||||||
if ( partPath.startsWith( "/dev/disk/by-" ) ) // we got a fancy node
|
if ( partPath.startsWith( "/dev/disk/by-" ) ) // we got a fancy node
|
||||||
{
|
{
|
||||||
readlink.start( "readlink", { "-en", partPath });
|
readlink.start( "readlink", { "-en", partPath } );
|
||||||
if ( !readlink.waitForStarted( 1000 ) )
|
if ( !readlink.waitForStarted( 1000 ) )
|
||||||
|
{
|
||||||
return QString();
|
return QString();
|
||||||
|
}
|
||||||
if ( !readlink.waitForFinished( 1000 ) )
|
if ( !readlink.waitForFinished( 1000 ) )
|
||||||
|
{
|
||||||
return QString();
|
return QString();
|
||||||
|
}
|
||||||
if ( readlink.exitCode() != 0 || readlink.exitStatus() != QProcess::NormalExit )
|
if ( readlink.exitCode() != 0 || readlink.exitStatus() != QProcess::NormalExit )
|
||||||
|
{
|
||||||
return QString();
|
return QString();
|
||||||
partPath = QString::fromLocal8Bit(
|
}
|
||||||
readlink.readAllStandardOutput() ).trimmed();
|
partPath = QString::fromLocal8Bit( readlink.readAllStandardOutput() ).trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
return partPath;
|
return partPath;
|
||||||
@ -364,9 +384,7 @@ runOsprober( PartitionCoreModule* core )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
osproberOutput.append(
|
osproberOutput.append( QString::fromLocal8Bit( osprober.readAllStandardOutput() ).trimmed() );
|
||||||
QString::fromLocal8Bit(
|
|
||||||
osprober.readAllStandardOutput() ).trimmed() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList osproberCleanLines;
|
QStringList osproberCleanLines;
|
||||||
@ -379,32 +397,37 @@ runOsprober( PartitionCoreModule* core )
|
|||||||
QStringList lineColumns = line.split( ':' );
|
QStringList lineColumns = line.split( ':' );
|
||||||
QString prettyName;
|
QString prettyName;
|
||||||
if ( !lineColumns.value( 1 ).simplified().isEmpty() )
|
if ( !lineColumns.value( 1 ).simplified().isEmpty() )
|
||||||
|
{
|
||||||
prettyName = lineColumns.value( 1 ).simplified();
|
prettyName = lineColumns.value( 1 ).simplified();
|
||||||
|
}
|
||||||
else if ( !lineColumns.value( 2 ).simplified().isEmpty() )
|
else if ( !lineColumns.value( 2 ).simplified().isEmpty() )
|
||||||
|
{
|
||||||
prettyName = lineColumns.value( 2 ).simplified();
|
prettyName = lineColumns.value( 2 ).simplified();
|
||||||
|
}
|
||||||
|
|
||||||
QString path = lineColumns.value( 0 ).simplified();
|
QString path = lineColumns.value( 0 ).simplified();
|
||||||
if ( !path.startsWith( "/dev/" ) ) //basic sanity check
|
if ( !path.startsWith( "/dev/" ) ) //basic sanity check
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
FstabEntryList fstabEntries = lookForFstabEntries( path );
|
FstabEntryList fstabEntries = lookForFstabEntries( path );
|
||||||
QString homePath = findPartitionPathForMountPoint( fstabEntries, "/home" );
|
QString homePath = findPartitionPathForMountPoint( fstabEntries, "/home" );
|
||||||
|
|
||||||
osproberEntries.append( { prettyName,
|
osproberEntries.append(
|
||||||
path,
|
{ prettyName, path, QString(), canBeResized( core, path ), lineColumns, fstabEntries, homePath } );
|
||||||
QString(),
|
|
||||||
canBeResized( core, path ),
|
|
||||||
lineColumns,
|
|
||||||
fstabEntries,
|
|
||||||
homePath } );
|
|
||||||
osproberCleanLines.append( line );
|
osproberCleanLines.append( line );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( osproberCleanLines.count() > 0 )
|
if ( osproberCleanLines.count() > 0 )
|
||||||
|
{
|
||||||
cDebug() << "os-prober lines after cleanup:" << Logger::DebugList( osproberCleanLines );
|
cDebug() << "os-prober lines after cleanup:" << Logger::DebugList( osproberCleanLines );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
cDebug() << "os-prober gave no output.";
|
cDebug() << "os-prober gave no output.";
|
||||||
|
}
|
||||||
|
|
||||||
Calamares::JobQueue::instance()->globalStorage()->insert( "osproberLines", osproberCleanLines );
|
Calamares::JobQueue::instance()->globalStorage()->insert( "osproberLines", osproberCleanLines );
|
||||||
|
|
||||||
@ -427,24 +450,28 @@ isEfiBootable( const Partition* candidate )
|
|||||||
|
|
||||||
/* If bit 17 is set, old-style Esp flag, it's OK */
|
/* If bit 17 is set, old-style Esp flag, it's OK */
|
||||||
if ( flags.testFlag( KPM_PARTITION_FLAG_ESP ) )
|
if ( flags.testFlag( KPM_PARTITION_FLAG_ESP ) )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Otherwise, if it's a GPT table, Boot (bit 0) is the same as Esp */
|
/* Otherwise, if it's a GPT table, Boot (bit 0) is the same as Esp */
|
||||||
const PartitionNode* root = candidate;
|
const PartitionNode* root = candidate;
|
||||||
while ( root && !root->isRoot() )
|
while ( root && !root->isRoot() )
|
||||||
{
|
{
|
||||||
root = root->parent();
|
root = root->parent();
|
||||||
cDebug() << Logger::SubEntry << "moved towards root" << (void *)root;
|
cDebug() << Logger::SubEntry << "moved towards root" << (void*)root;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strange case: no root found, no partition table node?
|
// Strange case: no root found, no partition table node?
|
||||||
if ( !root )
|
if ( !root )
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const PartitionTable* table = dynamic_cast<const PartitionTable*>( root );
|
const PartitionTable* table = dynamic_cast< const PartitionTable* >( root );
|
||||||
cDebug() << Logger::SubEntry << "partition table" << (void *)table << "type" << ( table ? table->type() : PartitionTable::TableType::unknownTableType );
|
cDebug() << Logger::SubEntry << "partition table" << (void*)table << "type"
|
||||||
return table && ( table->type() == PartitionTable::TableType::gpt ) &&
|
<< ( table ? table->type() : PartitionTable::TableType::unknownTableType );
|
||||||
flags.testFlag( KPM_PARTITION_FLAG(Boot) );
|
return table && ( table->type() == PartitionTable::TableType::gpt ) && flags.testFlag( KPM_PARTITION_FLAG( Boot ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
@ -452,14 +479,18 @@ findFS( QString fsName, FileSystem::Type* fsType )
|
|||||||
{
|
{
|
||||||
QStringList fsLanguage { QLatin1String( "C" ) }; // Required language list to turn off localization
|
QStringList fsLanguage { QLatin1String( "C" ) }; // Required language list to turn off localization
|
||||||
if ( fsName.isEmpty() )
|
if ( fsName.isEmpty() )
|
||||||
|
{
|
||||||
fsName = QStringLiteral( "ext4" );
|
fsName = QStringLiteral( "ext4" );
|
||||||
|
}
|
||||||
|
|
||||||
FileSystem::Type tmpType = FileSystem::typeForName( fsName, fsLanguage );
|
FileSystem::Type tmpType = FileSystem::typeForName( fsName, fsLanguage );
|
||||||
if ( tmpType != FileSystem::Unknown )
|
if ( tmpType != FileSystem::Unknown )
|
||||||
{
|
{
|
||||||
cDebug() << "Found filesystem" << fsName;
|
cDebug() << "Found filesystem" << fsName;
|
||||||
if ( fsType )
|
if ( fsType )
|
||||||
|
{
|
||||||
*fsType = tmpType;
|
*fsType = tmpType;
|
||||||
|
}
|
||||||
return fsName;
|
return fsName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,7 +503,9 @@ findFS( QString fsName, FileSystem::Type* fsType )
|
|||||||
QString fsRealName = FileSystem::nameForType( t, fsLanguage );
|
QString fsRealName = FileSystem::nameForType( t, fsLanguage );
|
||||||
cDebug() << "Filesystem name" << fsName << "translated to" << fsRealName;
|
cDebug() << "Filesystem name" << fsName << "translated to" << fsRealName;
|
||||||
if ( fsType )
|
if ( fsType )
|
||||||
|
{
|
||||||
*fsType = t;
|
*fsType = t;
|
||||||
|
}
|
||||||
return fsRealName;
|
return fsRealName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -480,8 +513,10 @@ findFS( QString fsName, FileSystem::Type* fsType )
|
|||||||
cDebug() << "Filesystem" << fsName << "not found, using ext4";
|
cDebug() << "Filesystem" << fsName << "not found, using ext4";
|
||||||
fsName = QStringLiteral( "ext4" );
|
fsName = QStringLiteral( "ext4" );
|
||||||
// fsType can be used to check whether fsName was a valid filesystem.
|
// fsType can be used to check whether fsName was a valid filesystem.
|
||||||
if (fsType)
|
if ( fsType )
|
||||||
|
{
|
||||||
*fsType = FileSystem::Unknown;
|
*fsType = FileSystem::Unknown;
|
||||||
|
}
|
||||||
#ifdef DEBUG_FILESYSTEMS
|
#ifdef DEBUG_FILESYSTEMS
|
||||||
// This bit is for distro's debugging their settings, and shows
|
// This bit is for distro's debugging their settings, and shows
|
||||||
// all the strings that KPMCore is matching against for FS type.
|
// all the strings that KPMCore is matching against for FS type.
|
||||||
@ -491,13 +526,15 @@ findFS( QString fsName, FileSystem::Type* fsType )
|
|||||||
const auto fstypes = FileSystem::types();
|
const auto fstypes = FileSystem::types();
|
||||||
d << "Available types (" << fstypes.count() << ')';
|
d << "Available types (" << fstypes.count() << ')';
|
||||||
for ( FileSystem::Type t : fstypes )
|
for ( FileSystem::Type t : fstypes )
|
||||||
d << TR( static_cast<int>( t ), FileSystem::nameForType( t, fsLanguage ) );
|
{
|
||||||
|
d << TR( static_cast< int >( t ), FileSystem::nameForType( t, fsLanguage ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return fsName;
|
return fsName;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // nmamespace PartUtils
|
} // namespace PartUtils
|
||||||
|
|
||||||
/* Implementation of methods for FstabEntry, from OsproberEntry.h */
|
/* Implementation of methods for FstabEntry, from OsproberEntry.h */
|
||||||
|
|
||||||
@ -512,17 +549,18 @@ FstabEntry::fromEtcFstab( const QString& rawLine )
|
|||||||
{
|
{
|
||||||
QString line = rawLine.simplified();
|
QString line = rawLine.simplified();
|
||||||
if ( line.startsWith( '#' ) )
|
if ( line.startsWith( '#' ) )
|
||||||
return FstabEntry{ QString(), QString(), QString(), QString(), 0, 0 };
|
return FstabEntry { QString(), QString(), QString(), QString(), 0, 0 };
|
||||||
|
|
||||||
QStringList splitLine = line.split( ' ' );
|
QStringList splitLine = line.split( ' ' );
|
||||||
if ( splitLine.length() != 6 )
|
if ( splitLine.length() != 6 )
|
||||||
return FstabEntry{ QString(), QString(), QString(), QString(), 0, 0 };
|
return FstabEntry { QString(), QString(), QString(), QString(), 0, 0 };
|
||||||
|
|
||||||
return FstabEntry{ splitLine.at( 0 ), // path, or UUID, or LABEL, etc.
|
return FstabEntry {
|
||||||
splitLine.at( 1 ), // mount point
|
splitLine.at( 0 ), // path, or UUID, or LABEL, etc.
|
||||||
splitLine.at( 2 ), // fs type
|
splitLine.at( 1 ), // mount point
|
||||||
splitLine.at( 3 ), // options
|
splitLine.at( 2 ), // fs type
|
||||||
splitLine.at( 4 ).toInt(), //dump
|
splitLine.at( 3 ), // options
|
||||||
splitLine.at( 5 ).toInt() //pass
|
splitLine.at( 4 ).toInt(), //dump
|
||||||
};
|
splitLine.at( 5 ).toInt() //pass
|
||||||
}
|
};
|
||||||
|
}
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
#define PARTUTILS_H
|
#define PARTUTILS_H
|
||||||
|
|
||||||
#include "OsproberEntry.h"
|
#include "OsproberEntry.h"
|
||||||
#include "utils/Units.h"
|
|
||||||
#include "utils/NamedSuffix.h"
|
#include "utils/NamedSuffix.h"
|
||||||
|
#include "utils/Units.h"
|
||||||
|
|
||||||
// KPMcore
|
// KPMcore
|
||||||
#include <kpmcore/fs/filesystem.h>
|
#include <kpmcore/fs/filesystem.h>
|
||||||
@ -99,6 +99,6 @@ bool isEfiBootable( const Partition* candidate );
|
|||||||
*/
|
*/
|
||||||
QString findFS( QString fsName, FileSystem::Type* fsType );
|
QString findFS( QString fsName, FileSystem::Type* fsType );
|
||||||
|
|
||||||
}
|
} // namespace PartUtils
|
||||||
|
|
||||||
#endif // PARTUTILS_H
|
#endif // PARTUTILS_H
|
||||||
|
@ -21,13 +21,13 @@
|
|||||||
#include "PartitionActions.h"
|
#include "PartitionActions.h"
|
||||||
|
|
||||||
#include "core/KPMHelpers.h"
|
#include "core/KPMHelpers.h"
|
||||||
#include "core/PartitionInfo.h"
|
|
||||||
#include "core/PartitionCoreModule.h"
|
|
||||||
#include "core/PartUtils.h"
|
#include "core/PartUtils.h"
|
||||||
|
#include "core/PartitionCoreModule.h"
|
||||||
|
#include "core/PartitionInfo.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
#include "utils/Units.h"
|
|
||||||
#include "utils/NamedEnum.h"
|
#include "utils/NamedEnum.h"
|
||||||
|
#include "utils/Units.h"
|
||||||
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
@ -47,7 +47,9 @@ qint64
|
|||||||
swapSuggestion( const qint64 availableSpaceB, Choices::SwapChoice swap )
|
swapSuggestion( const qint64 availableSpaceB, Choices::SwapChoice swap )
|
||||||
{
|
{
|
||||||
if ( ( swap != Choices::SmallSwap ) && ( swap != Choices::FullSwap ) )
|
if ( ( swap != Choices::SmallSwap ) && ( swap != Choices::FullSwap ) )
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// See partition.conf for explanation
|
// See partition.conf for explanation
|
||||||
qint64 suggestedSwapSizeB = 0;
|
qint64 suggestedSwapSizeB = 0;
|
||||||
@ -59,15 +61,23 @@ swapSuggestion( const qint64 availableSpaceB, Choices::SwapChoice swap )
|
|||||||
|
|
||||||
// Ramp up quickly to 8GiB, then follow memory size
|
// Ramp up quickly to 8GiB, then follow memory size
|
||||||
if ( availableRamB <= 4_GiB )
|
if ( availableRamB <= 4_GiB )
|
||||||
|
{
|
||||||
suggestedSwapSizeB = availableRamB * 2;
|
suggestedSwapSizeB = availableRamB * 2;
|
||||||
|
}
|
||||||
else if ( availableRamB <= 8_GiB )
|
else if ( availableRamB <= 8_GiB )
|
||||||
|
{
|
||||||
suggestedSwapSizeB = 8_GiB;
|
suggestedSwapSizeB = 8_GiB;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
suggestedSwapSizeB = availableRamB;
|
suggestedSwapSizeB = availableRamB;
|
||||||
|
}
|
||||||
|
|
||||||
// .. top out at 8GiB if we don't care about suspend
|
// .. top out at 8GiB if we don't care about suspend
|
||||||
if ( !ensureSuspendToDisk )
|
if ( !ensureSuspendToDisk )
|
||||||
|
{
|
||||||
suggestedSwapSizeB = qMin( 8_GiB, suggestedSwapSizeB );
|
suggestedSwapSizeB = qMin( 8_GiB, suggestedSwapSizeB );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Allow for a fudge factor
|
// Allow for a fudge factor
|
||||||
@ -75,7 +85,9 @@ swapSuggestion( const qint64 availableSpaceB, Choices::SwapChoice swap )
|
|||||||
|
|
||||||
// don't use more than 10% of available space
|
// don't use more than 10% of available space
|
||||||
if ( !ensureSuspendToDisk )
|
if ( !ensureSuspendToDisk )
|
||||||
|
{
|
||||||
suggestedSwapSizeB = qMin( suggestedSwapSizeB, qint64( 0.10 * availableSpaceB ) );
|
suggestedSwapSizeB = qMin( suggestedSwapSizeB, qint64( 0.10 * availableSpaceB ) );
|
||||||
|
}
|
||||||
|
|
||||||
cDebug() << "Suggested swap size:" << suggestedSwapSizeB / 1024. / 1024. / 1024. << "GiB";
|
cDebug() << "Suggested swap size:" << suggestedSwapSizeB / 1024. / 1024. / 1024. << "GiB";
|
||||||
|
|
||||||
@ -88,7 +100,9 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
|
|||||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
QString defaultFsType = o.defaultFsType;
|
QString defaultFsType = o.defaultFsType;
|
||||||
if ( FileSystem::typeForName( defaultFsType ) == FileSystem::Unknown )
|
if ( FileSystem::typeForName( defaultFsType ) == FileSystem::Unknown )
|
||||||
|
{
|
||||||
defaultFsType = "ext4";
|
defaultFsType = "ext4";
|
||||||
|
}
|
||||||
|
|
||||||
bool isEfi = PartUtils::isEfiSystem();
|
bool isEfi = PartUtils::isEfiSystem();
|
||||||
|
|
||||||
@ -103,8 +117,8 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
|
|||||||
{
|
{
|
||||||
if ( gs->contains( "efiSystemPartitionSize" ) )
|
if ( gs->contains( "efiSystemPartitionSize" ) )
|
||||||
{
|
{
|
||||||
CalamaresUtils::Partition::PartitionSize part_size = CalamaresUtils::Partition::PartitionSize(
|
CalamaresUtils::Partition::PartitionSize part_size
|
||||||
gs->value( "efiSystemPartitionSize" ).toString() );
|
= CalamaresUtils::Partition::PartitionSize( gs->value( "efiSystemPartitionSize" ).toString() );
|
||||||
uefisys_part_sizeB = part_size.toBytes( dev->capacity() );
|
uefisys_part_sizeB = part_size.toBytes( dev->capacity() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -128,15 +142,13 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
|
|||||||
// firstFreeSector..firstFreeSector+efiSectorCount-1.
|
// firstFreeSector..firstFreeSector+efiSectorCount-1.
|
||||||
qint64 lastSector = firstFreeSector + efiSectorCount - 1;
|
qint64 lastSector = firstFreeSector + efiSectorCount - 1;
|
||||||
core->createPartitionTable( dev, PartitionTable::gpt );
|
core->createPartitionTable( dev, PartitionTable::gpt );
|
||||||
Partition* efiPartition = KPMHelpers::createNewPartition(
|
Partition* efiPartition = KPMHelpers::createNewPartition( dev->partitionTable(),
|
||||||
dev->partitionTable(),
|
*dev,
|
||||||
*dev,
|
PartitionRole( PartitionRole::Primary ),
|
||||||
PartitionRole( PartitionRole::Primary ),
|
FileSystem::Fat32,
|
||||||
FileSystem::Fat32,
|
firstFreeSector,
|
||||||
firstFreeSector,
|
lastSector,
|
||||||
lastSector,
|
KPM_PARTITION_FLAG( None ) );
|
||||||
KPM_PARTITION_FLAG(None)
|
|
||||||
);
|
|
||||||
PartitionInfo::setFormat( efiPartition, true );
|
PartitionInfo::setFormat( efiPartition, true );
|
||||||
PartitionInfo::setMountPoint( efiPartition, o.efiPartitionMountPoint );
|
PartitionInfo::setMountPoint( efiPartition, o.efiPartitionMountPoint );
|
||||||
core->createPartition( dev, efiPartition, KPM_PARTITION_FLAG_ESP );
|
core->createPartition( dev, efiPartition, KPM_PARTITION_FLAG_ESP );
|
||||||
@ -164,7 +176,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
|
|||||||
shouldCreateSwap = availableSpaceB > requiredSpaceB;
|
shouldCreateSwap = availableSpaceB > requiredSpaceB;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 lastSectorForRoot = dev->totalLogical() - 1; //last sector of the device
|
qint64 lastSectorForRoot = dev->totalLogical() - 1; //last sector of the device
|
||||||
if ( shouldCreateSwap )
|
if ( shouldCreateSwap )
|
||||||
{
|
{
|
||||||
lastSectorForRoot -= suggestedSwapSizeB / dev->logicalSize() + 1;
|
lastSectorForRoot -= suggestedSwapSizeB / dev->logicalSize() + 1;
|
||||||
@ -177,28 +189,24 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
|
|||||||
Partition* swapPartition = nullptr;
|
Partition* swapPartition = nullptr;
|
||||||
if ( o.luksPassphrase.isEmpty() )
|
if ( o.luksPassphrase.isEmpty() )
|
||||||
{
|
{
|
||||||
swapPartition = KPMHelpers::createNewPartition(
|
swapPartition = KPMHelpers::createNewPartition( dev->partitionTable(),
|
||||||
dev->partitionTable(),
|
*dev,
|
||||||
*dev,
|
PartitionRole( PartitionRole::Primary ),
|
||||||
PartitionRole( PartitionRole::Primary ),
|
FileSystem::LinuxSwap,
|
||||||
FileSystem::LinuxSwap,
|
lastSectorForRoot + 1,
|
||||||
lastSectorForRoot + 1,
|
dev->totalLogical() - 1,
|
||||||
dev->totalLogical() - 1,
|
KPM_PARTITION_FLAG( None ) );
|
||||||
KPM_PARTITION_FLAG(None)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
swapPartition = KPMHelpers::createNewEncryptedPartition(
|
swapPartition = KPMHelpers::createNewEncryptedPartition( dev->partitionTable(),
|
||||||
dev->partitionTable(),
|
*dev,
|
||||||
*dev,
|
PartitionRole( PartitionRole::Primary ),
|
||||||
PartitionRole( PartitionRole::Primary ),
|
FileSystem::LinuxSwap,
|
||||||
FileSystem::LinuxSwap,
|
lastSectorForRoot + 1,
|
||||||
lastSectorForRoot + 1,
|
dev->totalLogical() - 1,
|
||||||
dev->totalLogical() - 1,
|
o.luksPassphrase,
|
||||||
o.luksPassphrase,
|
KPM_PARTITION_FLAG( None ) );
|
||||||
KPM_PARTITION_FLAG(None)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
PartitionInfo::setFormat( swapPartition, true );
|
PartitionInfo::setFormat( swapPartition, true );
|
||||||
core->createPartition( dev, swapPartition );
|
core->createPartition( dev, swapPartition );
|
||||||
@ -209,10 +217,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
doReplacePartition( PartitionCoreModule* core,
|
doReplacePartition( PartitionCoreModule* core, Device* dev, Partition* partition, Choices::ReplacePartitionOptions o )
|
||||||
Device* dev,
|
|
||||||
Partition* partition,
|
|
||||||
Choices::ReplacePartitionOptions o )
|
|
||||||
{
|
{
|
||||||
qint64 firstSector, lastSector;
|
qint64 firstSector, lastSector;
|
||||||
|
|
||||||
@ -220,11 +225,15 @@ doReplacePartition( PartitionCoreModule* core,
|
|||||||
|
|
||||||
QString defaultFsType = o.defaultFsType;
|
QString defaultFsType = o.defaultFsType;
|
||||||
if ( FileSystem::typeForName( defaultFsType ) == FileSystem::Unknown )
|
if ( FileSystem::typeForName( defaultFsType ) == FileSystem::Unknown )
|
||||||
|
{
|
||||||
defaultFsType = "ext4";
|
defaultFsType = "ext4";
|
||||||
|
}
|
||||||
|
|
||||||
PartitionRole newRoles( partition->roles() );
|
PartitionRole newRoles( partition->roles() );
|
||||||
if ( partition->roles().has( PartitionRole::Extended ) )
|
if ( partition->roles().has( PartitionRole::Extended ) )
|
||||||
|
{
|
||||||
newRoles = PartitionRole( PartitionRole::Primary );
|
newRoles = PartitionRole( PartitionRole::Primary );
|
||||||
|
}
|
||||||
|
|
||||||
if ( partition->roles().has( PartitionRole::Unallocated ) )
|
if ( partition->roles().has( PartitionRole::Unallocated ) )
|
||||||
{
|
{
|
||||||
@ -234,7 +243,9 @@ doReplacePartition( PartitionCoreModule* core,
|
|||||||
{
|
{
|
||||||
Partition* parent = dynamic_cast< Partition* >( partition->parent() );
|
Partition* parent = dynamic_cast< Partition* >( partition->parent() );
|
||||||
if ( parent && parent->roles().has( PartitionRole::Extended ) )
|
if ( parent && parent->roles().has( PartitionRole::Extended ) )
|
||||||
|
{
|
||||||
newRoles = PartitionRole( PartitionRole::Logical );
|
newRoles = PartitionRole( PartitionRole::Logical );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +253,9 @@ doReplacePartition( PartitionCoreModule* core,
|
|||||||
firstSector = partition->firstSector();
|
firstSector = partition->firstSector();
|
||||||
lastSector = partition->lastSector();
|
lastSector = partition->lastSector();
|
||||||
if ( !partition->roles().has( PartitionRole::Unallocated ) )
|
if ( !partition->roles().has( PartitionRole::Unallocated ) )
|
||||||
|
{
|
||||||
core->deletePartition( dev, partition );
|
core->deletePartition( dev, partition );
|
||||||
|
}
|
||||||
|
|
||||||
core->layoutApply( dev, firstSector, lastSector, o.luksPassphrase );
|
core->layoutApply( dev, firstSector, lastSector, o.luksPassphrase );
|
||||||
|
|
||||||
@ -251,16 +264,14 @@ doReplacePartition( PartitionCoreModule* core,
|
|||||||
|
|
||||||
namespace Choices
|
namespace Choices
|
||||||
{
|
{
|
||||||
static const NamedEnumTable<SwapChoice>&
|
static const NamedEnumTable< SwapChoice >&
|
||||||
nameTable()
|
nameTable()
|
||||||
{
|
{
|
||||||
static const NamedEnumTable<SwapChoice> names{
|
static const NamedEnumTable< SwapChoice > names { { QStringLiteral( "none" ), SwapChoice::NoSwap },
|
||||||
{ QStringLiteral( "none" ), SwapChoice::NoSwap },
|
{ QStringLiteral( "small" ), SwapChoice::SmallSwap },
|
||||||
{ QStringLiteral( "small" ), SwapChoice::SmallSwap },
|
{ QStringLiteral( "suspend" ), SwapChoice::FullSwap },
|
||||||
{ QStringLiteral( "suspend" ), SwapChoice::FullSwap },
|
{ QStringLiteral( "reuse" ), SwapChoice::ReuseSwap },
|
||||||
{ QStringLiteral( "reuse" ), SwapChoice::ReuseSwap },
|
{ QStringLiteral( "file" ), SwapChoice::SwapFile } };
|
||||||
{ QStringLiteral( "file" ), SwapChoice::SwapFile }
|
|
||||||
};
|
|
||||||
|
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
@ -33,45 +33,49 @@ namespace PartitionActions
|
|||||||
*/
|
*/
|
||||||
namespace Choices
|
namespace Choices
|
||||||
{
|
{
|
||||||
/** @brief Ccchoice of swap (size and type) */
|
/** @brief Ccchoice of swap (size and type) */
|
||||||
enum SwapChoice
|
enum SwapChoice
|
||||||
|
{
|
||||||
|
NoSwap, // don't create any swap, don't use any
|
||||||
|
ReuseSwap, // don't create, but do use existing
|
||||||
|
SmallSwap, // up to 8GiB of swap
|
||||||
|
FullSwap, // ensureSuspendToDisk -- at least RAM size
|
||||||
|
SwapFile // use a file (if supported)
|
||||||
|
};
|
||||||
|
|
||||||
|
SwapChoice nameToChoice( QString name, bool& ok );
|
||||||
|
QString choiceToName( SwapChoice );
|
||||||
|
|
||||||
|
struct ReplacePartitionOptions
|
||||||
|
{
|
||||||
|
QString defaultFsType; // e.g. "ext4" or "btrfs"
|
||||||
|
QString luksPassphrase; // optional
|
||||||
|
|
||||||
|
ReplacePartitionOptions( const QString& fs, const QString& luks )
|
||||||
|
: defaultFsType( fs )
|
||||||
|
, luksPassphrase( luks )
|
||||||
{
|
{
|
||||||
NoSwap, // don't create any swap, don't use any
|
}
|
||||||
ReuseSwap, // don't create, but do use existing
|
};
|
||||||
SmallSwap, // up to 8GiB of swap
|
|
||||||
FullSwap, // ensureSuspendToDisk -- at least RAM size
|
|
||||||
SwapFile // use a file (if supported)
|
|
||||||
};
|
|
||||||
|
|
||||||
SwapChoice nameToChoice( QString name, bool& ok );
|
struct AutoPartitionOptions : ReplacePartitionOptions
|
||||||
QString choiceToName( SwapChoice );
|
{
|
||||||
|
QString efiPartitionMountPoint; // optional, e.g. "/boot"
|
||||||
|
quint64 requiredSpaceB; // estimated required space for root partition
|
||||||
|
SwapChoice swap;
|
||||||
|
|
||||||
struct ReplacePartitionOptions
|
AutoPartitionOptions( const QString& fs,
|
||||||
|
const QString& luks,
|
||||||
|
const QString& efi,
|
||||||
|
qint64 requiredBytes,
|
||||||
|
SwapChoice s )
|
||||||
|
: ReplacePartitionOptions( fs, luks )
|
||||||
|
, efiPartitionMountPoint( efi )
|
||||||
|
, requiredSpaceB( requiredBytes > 0 ? static_cast< quint64 >( requiredBytes ) : 0 )
|
||||||
|
, swap( s )
|
||||||
{
|
{
|
||||||
QString defaultFsType; // e.g. "ext4" or "btrfs"
|
}
|
||||||
QString luksPassphrase; // optional
|
};
|
||||||
|
|
||||||
ReplacePartitionOptions( const QString& fs, const QString& luks )
|
|
||||||
: defaultFsType( fs )
|
|
||||||
, luksPassphrase( luks )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct AutoPartitionOptions : ReplacePartitionOptions
|
|
||||||
{
|
|
||||||
QString efiPartitionMountPoint; // optional, e.g. "/boot"
|
|
||||||
quint64 requiredSpaceB; // estimated required space for root partition
|
|
||||||
SwapChoice swap;
|
|
||||||
|
|
||||||
AutoPartitionOptions( const QString& fs, const QString& luks, const QString& efi, qint64 requiredBytes, SwapChoice s )
|
|
||||||
: ReplacePartitionOptions( fs, luks )
|
|
||||||
, efiPartitionMountPoint( efi )
|
|
||||||
, requiredSpaceB( requiredBytes > 0 ? static_cast<quint64>( requiredBytes ) : 0 )
|
|
||||||
, swap( s )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Choices
|
} // namespace Choices
|
||||||
|
|
||||||
@ -81,9 +85,7 @@ namespace Choices
|
|||||||
* @param dev the device to wipe.
|
* @param dev the device to wipe.
|
||||||
* @param options settings for autopartitioning.
|
* @param options settings for autopartitioning.
|
||||||
*/
|
*/
|
||||||
void doAutopartition( PartitionCoreModule* core,
|
void doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionOptions options );
|
||||||
Device* dev,
|
|
||||||
Choices::AutoPartitionOptions options );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief doReplacePartition sets up replace-partitioning with the given partition.
|
* @brief doReplacePartition sets up replace-partitioning with the given partition.
|
||||||
@ -100,4 +102,4 @@ void doReplacePartition( PartitionCoreModule* core,
|
|||||||
Choices::ReplacePartitionOptions options );
|
Choices::ReplacePartitionOptions options );
|
||||||
} // namespace PartitionActions
|
} // namespace PartitionActions
|
||||||
|
|
||||||
#endif // PARTITIONACTIONS_H
|
#endif // PARTITIONACTIONS_H
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
#include "core/ColorUtils.h"
|
#include "core/ColorUtils.h"
|
||||||
#include "core/DeviceList.h"
|
#include "core/DeviceList.h"
|
||||||
#include "core/DeviceModel.h"
|
#include "core/DeviceModel.h"
|
||||||
#include "core/PartitionInfo.h"
|
|
||||||
#include "core/PartitionModel.h"
|
|
||||||
#include "core/KPMHelpers.h"
|
#include "core/KPMHelpers.h"
|
||||||
#include "core/PartUtils.h"
|
#include "core/PartUtils.h"
|
||||||
|
#include "core/PartitionInfo.h"
|
||||||
|
#include "core/PartitionModel.h"
|
||||||
#include "jobs/ClearMountsJob.h"
|
#include "jobs/ClearMountsJob.h"
|
||||||
#include "jobs/ClearTempMountsJob.h"
|
#include "jobs/ClearTempMountsJob.h"
|
||||||
#include "jobs/CreatePartitionJob.h"
|
#include "jobs/CreatePartitionJob.h"
|
||||||
@ -53,28 +53,28 @@
|
|||||||
#include "utils/Variant.h"
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
// KPMcore
|
// KPMcore
|
||||||
|
#include <kpmcore/backend/corebackend.h>
|
||||||
|
#include <kpmcore/backend/corebackendmanager.h>
|
||||||
#include <kpmcore/core/device.h>
|
#include <kpmcore/core/device.h>
|
||||||
#include <kpmcore/core/lvmdevice.h>
|
#include <kpmcore/core/lvmdevice.h>
|
||||||
#include <kpmcore/core/partition.h>
|
#include <kpmcore/core/partition.h>
|
||||||
#include <kpmcore/core/volumemanagerdevice.h>
|
#include <kpmcore/core/volumemanagerdevice.h>
|
||||||
#include <kpmcore/backend/corebackend.h>
|
|
||||||
#include <kpmcore/backend/corebackendmanager.h>
|
|
||||||
#include <kpmcore/fs/filesystemfactory.h>
|
#include <kpmcore/fs/filesystemfactory.h>
|
||||||
#include <kpmcore/fs/luks.h>
|
#include <kpmcore/fs/luks.h>
|
||||||
#include <kpmcore/fs/lvm2_pv.h>
|
#include <kpmcore/fs/lvm2_pv.h>
|
||||||
|
|
||||||
// Qt
|
// Qt
|
||||||
#include <QStandardItemModel>
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QProcess>
|
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QStandardItemModel>
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
|
||||||
using CalamaresUtils::Partition::PartitionIterator;
|
|
||||||
using CalamaresUtils::Partition::isPartitionFreeSpace;
|
using CalamaresUtils::Partition::isPartitionFreeSpace;
|
||||||
using CalamaresUtils::Partition::isPartitionNew;
|
using CalamaresUtils::Partition::isPartitionNew;
|
||||||
|
using CalamaresUtils::Partition::PartitionIterator;
|
||||||
|
|
||||||
PartitionCoreModule::RefreshHelper::RefreshHelper(PartitionCoreModule* module)
|
PartitionCoreModule::RefreshHelper::RefreshHelper( PartitionCoreModule* module )
|
||||||
: m_module( module )
|
: m_module( module )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ private:
|
|||||||
// called in *reverse* order of declaration in this class.
|
// called in *reverse* order of declaration in this class.
|
||||||
PartitionCoreModule::RefreshHelper m_coreHelper;
|
PartitionCoreModule::RefreshHelper m_coreHelper;
|
||||||
PartitionModel::ResetHelper m_modelHelper;
|
PartitionModel::ResetHelper m_modelHelper;
|
||||||
} ;
|
};
|
||||||
|
|
||||||
|
|
||||||
//- DeviceInfo ---------------------------------------------
|
//- DeviceInfo ---------------------------------------------
|
||||||
@ -111,19 +111,20 @@ PartitionCoreModule::DeviceInfo::DeviceInfo( Device* _device )
|
|||||||
, partitionModel( new PartitionModel )
|
, partitionModel( new PartitionModel )
|
||||||
, immutableDevice( new Device( *_device ) )
|
, immutableDevice( new Device( *_device ) )
|
||||||
, isAvailable( true )
|
, isAvailable( true )
|
||||||
{}
|
|
||||||
|
|
||||||
PartitionCoreModule::DeviceInfo::~DeviceInfo()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PartitionCoreModule::DeviceInfo::~DeviceInfo() {}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionCoreModule::DeviceInfo::forgetChanges()
|
PartitionCoreModule::DeviceInfo::forgetChanges()
|
||||||
{
|
{
|
||||||
jobs.clear();
|
jobs.clear();
|
||||||
for ( auto it = PartitionIterator::begin( device.data() ); it != PartitionIterator::end( device.data() ); ++it )
|
for ( auto it = PartitionIterator::begin( device.data() ); it != PartitionIterator::end( device.data() ); ++it )
|
||||||
|
{
|
||||||
PartitionInfo::reset( *it );
|
PartitionInfo::reset( *it );
|
||||||
|
}
|
||||||
partitionModel->revert();
|
partitionModel->revert();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,11 +133,15 @@ bool
|
|||||||
PartitionCoreModule::DeviceInfo::isDirty() const
|
PartitionCoreModule::DeviceInfo::isDirty() const
|
||||||
{
|
{
|
||||||
if ( !jobs.isEmpty() )
|
if ( !jobs.isEmpty() )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
for ( auto it = PartitionIterator::begin( device.data() ); it != PartitionIterator::end( device.data() ); ++it )
|
for ( auto it = PartitionIterator::begin( device.data() ); it != PartitionIterator::end( device.data() ); ++it )
|
||||||
if ( PartitionInfo::isDirty( *it ) )
|
if ( PartitionInfo::isDirty( *it ) )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -148,7 +153,9 @@ PartitionCoreModule::PartitionCoreModule( QObject* parent )
|
|||||||
, m_bootLoaderModel( new BootLoaderModel( this ) )
|
, m_bootLoaderModel( new BootLoaderModel( this ) )
|
||||||
{
|
{
|
||||||
if ( !m_kpmcore )
|
if ( !m_kpmcore )
|
||||||
|
{
|
||||||
qFatal( "Failed to initialize KPMcore backend" );
|
qFatal( "Failed to initialize KPMcore backend" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -197,33 +204,39 @@ PartitionCoreModule::doInit()
|
|||||||
for ( auto deviceInfo : m_deviceInfos )
|
for ( auto deviceInfo : m_deviceInfos )
|
||||||
{
|
{
|
||||||
for ( auto it = PartitionIterator::begin( deviceInfo->device.data() );
|
for ( auto it = PartitionIterator::begin( deviceInfo->device.data() );
|
||||||
it != PartitionIterator::end( deviceInfo->device.data() ); ++it )
|
it != PartitionIterator::end( deviceInfo->device.data() );
|
||||||
|
++it )
|
||||||
{
|
{
|
||||||
Partition* partition = *it;
|
Partition* partition = *it;
|
||||||
for ( auto jt = m_osproberLines.begin();
|
for ( auto jt = m_osproberLines.begin(); jt != m_osproberLines.end(); ++jt )
|
||||||
jt != m_osproberLines.end(); ++jt )
|
|
||||||
{
|
{
|
||||||
if ( jt->path == partition->partitionPath() &&
|
if ( jt->path == partition->partitionPath()
|
||||||
partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone &&
|
&& partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone
|
||||||
!partition->fileSystem().uuid().isEmpty() )
|
&& !partition->fileSystem().uuid().isEmpty() )
|
||||||
|
{
|
||||||
jt->uuid = partition->fileSystem().uuid();
|
jt->uuid = partition->fileSystem().uuid();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( auto deviceInfo : m_deviceInfos )
|
for ( auto deviceInfo : m_deviceInfos )
|
||||||
|
{
|
||||||
deviceInfo->partitionModel->init( deviceInfo->device.data(), m_osproberLines );
|
deviceInfo->partitionModel->init( deviceInfo->device.data(), m_osproberLines );
|
||||||
|
}
|
||||||
|
|
||||||
DeviceList bootLoaderDevices;
|
DeviceList bootLoaderDevices;
|
||||||
|
|
||||||
for ( DeviceList::Iterator it = devices.begin(); it != devices.end(); ++it)
|
for ( DeviceList::Iterator it = devices.begin(); it != devices.end(); ++it )
|
||||||
if ( (*it)->type() != Device::Type::Disk_Device )
|
if ( ( *it )->type() != Device::Type::Disk_Device )
|
||||||
{
|
{
|
||||||
cDebug() << "Ignoring device that is not Disk_Device to bootLoaderDevices list.";
|
cDebug() << "Ignoring device that is not Disk_Device to bootLoaderDevices list.";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
bootLoaderDevices.append(*it);
|
{
|
||||||
|
bootLoaderDevices.append( *it );
|
||||||
|
}
|
||||||
|
|
||||||
m_bootLoaderModel->init( bootLoaderDevices );
|
m_bootLoaderModel->init( bootLoaderDevices );
|
||||||
|
|
||||||
@ -232,7 +245,9 @@ PartitionCoreModule::doInit()
|
|||||||
//FIXME: this should be removed in favor of
|
//FIXME: this should be removed in favor of
|
||||||
// proper KPM support for EFI
|
// proper KPM support for EFI
|
||||||
if ( PartUtils::isEfiSystem() )
|
if ( PartUtils::isEfiSystem() )
|
||||||
|
{
|
||||||
scanForEfiSystemPartitions();
|
scanForEfiSystemPartitions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PartitionCoreModule::~PartitionCoreModule()
|
PartitionCoreModule::~PartitionCoreModule()
|
||||||
@ -267,7 +282,9 @@ PartitionCoreModule::immutableDeviceCopy( const Device* device )
|
|||||||
Q_ASSERT( device );
|
Q_ASSERT( device );
|
||||||
DeviceInfo* info = infoForDevice( device );
|
DeviceInfo* info = infoForDevice( device );
|
||||||
if ( !info )
|
if ( !info )
|
||||||
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
return info->immutableDevice.data();
|
return info->immutableDevice.data();
|
||||||
}
|
}
|
||||||
@ -291,9 +308,7 @@ PartitionCoreModule::createPartitionTable( Device* device, PartitionTable::Table
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionCoreModule::createPartition( Device* device,
|
PartitionCoreModule::createPartition( Device* device, Partition* partition, PartitionTable::Flags flags )
|
||||||
Partition* partition,
|
|
||||||
PartitionTable::Flags flags )
|
|
||||||
{
|
{
|
||||||
auto deviceInfo = infoForDevice( device );
|
auto deviceInfo = infoForDevice( device );
|
||||||
Q_ASSERT( deviceInfo );
|
Q_ASSERT( deviceInfo );
|
||||||
@ -304,7 +319,7 @@ PartitionCoreModule::createPartition( Device* device,
|
|||||||
|
|
||||||
deviceInfo->jobs << Calamares::job_ptr( job );
|
deviceInfo->jobs << Calamares::job_ptr( job );
|
||||||
|
|
||||||
if ( flags != KPM_PARTITION_FLAG(None) )
|
if ( flags != KPM_PARTITION_FLAG( None ) )
|
||||||
{
|
{
|
||||||
SetPartFlagsJob* fJob = new SetPartFlagsJob( device, partition, flags );
|
SetPartFlagsJob* fJob = new SetPartFlagsJob( device, partition, flags );
|
||||||
deviceInfo->jobs << Calamares::job_ptr( fJob );
|
deviceInfo->jobs << Calamares::job_ptr( fJob );
|
||||||
@ -313,21 +328,23 @@ PartitionCoreModule::createPartition( Device* device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionCoreModule::createVolumeGroup( QString &vgName,
|
PartitionCoreModule::createVolumeGroup( QString& vgName, QVector< const Partition* > pvList, qint32 peSize )
|
||||||
QVector< const Partition* > pvList,
|
|
||||||
qint32 peSize )
|
|
||||||
{
|
{
|
||||||
// Appending '_' character in case of repeated VG name
|
// Appending '_' character in case of repeated VG name
|
||||||
while ( hasVGwithThisName( vgName ) )
|
while ( hasVGwithThisName( vgName ) )
|
||||||
vgName.append('_');
|
{
|
||||||
|
vgName.append( '_' );
|
||||||
|
}
|
||||||
|
|
||||||
CreateVolumeGroupJob* job = new CreateVolumeGroupJob( vgName, pvList, peSize );
|
CreateVolumeGroupJob* job = new CreateVolumeGroupJob( vgName, pvList, peSize );
|
||||||
job->updatePreview();
|
job->updatePreview();
|
||||||
|
|
||||||
LvmDevice* device = new LvmDevice(vgName);
|
LvmDevice* device = new LvmDevice( vgName );
|
||||||
|
|
||||||
for ( const Partition* p : pvList )
|
for ( const Partition* p : pvList )
|
||||||
|
{
|
||||||
device->physicalVolumes() << p;
|
device->physicalVolumes() << p;
|
||||||
|
}
|
||||||
|
|
||||||
DeviceInfo* deviceInfo = new DeviceInfo( device );
|
DeviceInfo* deviceInfo = new DeviceInfo( device );
|
||||||
|
|
||||||
@ -342,7 +359,7 @@ PartitionCoreModule::createVolumeGroup( QString &vgName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionCoreModule::resizeVolumeGroup( LvmDevice *device, QVector< const Partition* >& pvList )
|
PartitionCoreModule::resizeVolumeGroup( LvmDevice* device, QVector< const Partition* >& pvList )
|
||||||
{
|
{
|
||||||
DeviceInfo* deviceInfo = infoForDevice( device );
|
DeviceInfo* deviceInfo = infoForDevice( device );
|
||||||
Q_ASSERT( deviceInfo );
|
Q_ASSERT( deviceInfo );
|
||||||
@ -355,7 +372,7 @@ PartitionCoreModule::resizeVolumeGroup( LvmDevice *device, QVector< const Partit
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionCoreModule::deactivateVolumeGroup( LvmDevice *device )
|
PartitionCoreModule::deactivateVolumeGroup( LvmDevice* device )
|
||||||
{
|
{
|
||||||
DeviceInfo* deviceInfo = infoForDevice( device );
|
DeviceInfo* deviceInfo = infoForDevice( device );
|
||||||
Q_ASSERT( deviceInfo );
|
Q_ASSERT( deviceInfo );
|
||||||
@ -371,7 +388,7 @@ PartitionCoreModule::deactivateVolumeGroup( LvmDevice *device )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionCoreModule::removeVolumeGroup( LvmDevice *device )
|
PartitionCoreModule::removeVolumeGroup( LvmDevice* device )
|
||||||
{
|
{
|
||||||
DeviceInfo* deviceInfo = infoForDevice( device );
|
DeviceInfo* deviceInfo = infoForDevice( device );
|
||||||
Q_ASSERT( deviceInfo );
|
Q_ASSERT( deviceInfo );
|
||||||
@ -399,28 +416,35 @@ PartitionCoreModule::deletePartition( Device* device, Partition* partition )
|
|||||||
QList< Partition* > lst;
|
QList< Partition* > lst;
|
||||||
for ( auto childPartition : partition->children() )
|
for ( auto childPartition : partition->children() )
|
||||||
if ( !isPartitionFreeSpace( childPartition ) )
|
if ( !isPartitionFreeSpace( childPartition ) )
|
||||||
|
{
|
||||||
lst << childPartition;
|
lst << childPartition;
|
||||||
|
}
|
||||||
|
|
||||||
for ( auto childPartition : lst )
|
for ( auto childPartition : lst )
|
||||||
|
{
|
||||||
deletePartition( device, childPartition );
|
deletePartition( device, childPartition );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Calamares::JobList& jobs = deviceInfo->jobs;
|
Calamares::JobList& jobs = deviceInfo->jobs;
|
||||||
if ( partition->state() == KPM_PARTITION_STATE(New) )
|
if ( partition->state() == KPM_PARTITION_STATE( New ) )
|
||||||
{
|
{
|
||||||
// First remove matching SetPartFlagsJobs
|
// First remove matching SetPartFlagsJobs
|
||||||
for ( auto it = jobs.begin(); it != jobs.end(); )
|
for ( auto it = jobs.begin(); it != jobs.end(); )
|
||||||
{
|
{
|
||||||
SetPartFlagsJob* job = qobject_cast< SetPartFlagsJob* >( it->data() );
|
SetPartFlagsJob* job = qobject_cast< SetPartFlagsJob* >( it->data() );
|
||||||
if ( job && job->partition() == partition )
|
if ( job && job->partition() == partition )
|
||||||
|
{
|
||||||
it = jobs.erase( it );
|
it = jobs.erase( it );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
++it;
|
++it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find matching CreatePartitionJob
|
// Find matching CreatePartitionJob
|
||||||
auto it = std::find_if( jobs.begin(), jobs.end(), [ partition ]( Calamares::job_ptr job )
|
auto it = std::find_if( jobs.begin(), jobs.end(), [partition]( Calamares::job_ptr job ) {
|
||||||
{
|
|
||||||
CreatePartitionJob* createJob = qobject_cast< CreatePartitionJob* >( job.data() );
|
CreatePartitionJob* createJob = qobject_cast< CreatePartitionJob* >( job.data() );
|
||||||
return createJob && createJob->partition() == partition;
|
return createJob && createJob->partition() == partition;
|
||||||
} );
|
} );
|
||||||
@ -430,7 +454,7 @@ PartitionCoreModule::deletePartition( Device* device, Partition* partition )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Remove it
|
// Remove it
|
||||||
if ( ! partition->parent()->remove( partition ) )
|
if ( !partition->parent()->remove( partition ) )
|
||||||
{
|
{
|
||||||
cDebug() << "Failed to remove partition from preview";
|
cDebug() << "Failed to remove partition from preview";
|
||||||
return;
|
return;
|
||||||
@ -449,9 +473,13 @@ PartitionCoreModule::deletePartition( Device* device, Partition* partition )
|
|||||||
{
|
{
|
||||||
PartitionJob* job = qobject_cast< PartitionJob* >( it->data() );
|
PartitionJob* job = qobject_cast< PartitionJob* >( it->data() );
|
||||||
if ( job && job->partition() == partition )
|
if ( job && job->partition() == partition )
|
||||||
|
{
|
||||||
it = jobs.erase( it );
|
it = jobs.erase( it );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
++it;
|
++it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
DeletePartitionJob* job = new DeletePartitionJob( device, partition );
|
DeletePartitionJob* job = new DeletePartitionJob( device, partition );
|
||||||
job->updatePreview();
|
job->updatePreview();
|
||||||
@ -471,10 +499,7 @@ PartitionCoreModule::formatPartition( Device* device, Partition* partition )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionCoreModule::resizePartition( Device* device,
|
PartitionCoreModule::resizePartition( Device* device, Partition* partition, qint64 first, qint64 last )
|
||||||
Partition* partition,
|
|
||||||
qint64 first,
|
|
||||||
qint64 last )
|
|
||||||
{
|
{
|
||||||
auto deviceInfo = infoForDevice( device );
|
auto deviceInfo = infoForDevice( device );
|
||||||
Q_ASSERT( deviceInfo );
|
Q_ASSERT( deviceInfo );
|
||||||
@ -486,9 +511,7 @@ PartitionCoreModule::resizePartition( Device* device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionCoreModule::setPartitionFlags( Device* device,
|
PartitionCoreModule::setPartitionFlags( Device* device, Partition* partition, PartitionTable::Flags flags )
|
||||||
Partition* partition,
|
|
||||||
PartitionTable::Flags flags )
|
|
||||||
{
|
{
|
||||||
auto deviceInfo = infoForDevice( device );
|
auto deviceInfo = infoForDevice( device );
|
||||||
Q_ASSERT( deviceInfo );
|
Q_ASSERT( deviceInfo );
|
||||||
@ -521,7 +544,9 @@ PartitionCoreModule::jobs() const
|
|||||||
for ( auto info : m_deviceInfos )
|
for ( auto info : m_deviceInfos )
|
||||||
{
|
{
|
||||||
if ( info->isDirty() )
|
if ( info->isDirty() )
|
||||||
|
{
|
||||||
lst << Calamares::job_ptr( new ClearMountsJob( info->device.data() ) );
|
lst << Calamares::job_ptr( new ClearMountsJob( info->device.data() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( auto info : m_deviceInfos )
|
for ( auto info : m_deviceInfos )
|
||||||
@ -555,18 +580,18 @@ PartitionCoreModule::lvmPVs() const
|
|||||||
bool
|
bool
|
||||||
PartitionCoreModule::hasVGwithThisName( const QString& name ) const
|
PartitionCoreModule::hasVGwithThisName( const QString& name ) const
|
||||||
{
|
{
|
||||||
auto condition = [ name ]( DeviceInfo* d ) {
|
auto condition = [name]( DeviceInfo* d ) {
|
||||||
return dynamic_cast<LvmDevice*>(d->device.data()) && d->device.data()->name() == name;
|
return dynamic_cast< LvmDevice* >( d->device.data() ) && d->device.data()->name() == name;
|
||||||
};
|
};
|
||||||
|
|
||||||
return std::find_if( m_deviceInfos.begin(), m_deviceInfos.end(), condition ) != m_deviceInfos.end();
|
return std::find_if( m_deviceInfos.begin(), m_deviceInfos.end(), condition ) != m_deviceInfos.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PartitionCoreModule::isInVG( const Partition *partition ) const
|
PartitionCoreModule::isInVG( const Partition* partition ) const
|
||||||
{
|
{
|
||||||
auto condition = [ partition ]( DeviceInfo* d ) {
|
auto condition = [partition]( DeviceInfo* d ) {
|
||||||
LvmDevice* vg = dynamic_cast<LvmDevice*>( d->device.data());
|
LvmDevice* vg = dynamic_cast< LvmDevice* >( d->device.data() );
|
||||||
return vg && vg->physicalVolumes().contains( partition );
|
return vg && vg->physicalVolumes().contains( partition );
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -581,7 +606,9 @@ PartitionCoreModule::dumpQueue() const
|
|||||||
{
|
{
|
||||||
cDebug() << "## Device:" << info->device->name();
|
cDebug() << "## Device:" << info->device->name();
|
||||||
for ( auto job : info->jobs )
|
for ( auto job : info->jobs )
|
||||||
|
{
|
||||||
cDebug() << "-" << job->prettyName();
|
cDebug() << "-" << job->prettyName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,16 +642,21 @@ PartitionCoreModule::refreshAfterModelChange()
|
|||||||
//FIXME: this should be removed in favor of
|
//FIXME: this should be removed in favor of
|
||||||
// proper KPM support for EFI
|
// proper KPM support for EFI
|
||||||
if ( PartUtils::isEfiSystem() )
|
if ( PartUtils::isEfiSystem() )
|
||||||
|
{
|
||||||
scanForEfiSystemPartitions();
|
scanForEfiSystemPartitions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartitionCoreModule::updateHasRootMountPoint()
|
void
|
||||||
|
PartitionCoreModule::updateHasRootMountPoint()
|
||||||
{
|
{
|
||||||
bool oldValue = m_hasRootMountPoint;
|
bool oldValue = m_hasRootMountPoint;
|
||||||
m_hasRootMountPoint = findPartitionByMountPoint( "/" );
|
m_hasRootMountPoint = findPartitionByMountPoint( "/" );
|
||||||
|
|
||||||
if ( oldValue != m_hasRootMountPoint )
|
if ( oldValue != m_hasRootMountPoint )
|
||||||
|
{
|
||||||
hasRootMountPointChanged( m_hasRootMountPoint );
|
hasRootMountPointChanged( m_hasRootMountPoint );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -639,7 +671,9 @@ PartitionCoreModule::updateIsDirty()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( oldValue != m_isDirty )
|
if ( oldValue != m_isDirty )
|
||||||
|
{
|
||||||
isDirtyChanged( m_isDirty );
|
isDirtyChanged( m_isDirty );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -650,16 +684,17 @@ PartitionCoreModule::scanForEfiSystemPartitions()
|
|||||||
QList< Device* > devices;
|
QList< Device* > devices;
|
||||||
for ( int row = 0; row < deviceModel()->rowCount(); ++row )
|
for ( int row = 0; row < deviceModel()->rowCount(); ++row )
|
||||||
{
|
{
|
||||||
Device* device = deviceModel()->deviceForIndex(
|
Device* device = deviceModel()->deviceForIndex( deviceModel()->index( row ) );
|
||||||
deviceModel()->index( row ) );
|
|
||||||
devices.append( device );
|
devices.append( device );
|
||||||
}
|
}
|
||||||
|
|
||||||
QList< Partition* > efiSystemPartitions =
|
QList< Partition* > efiSystemPartitions
|
||||||
CalamaresUtils::Partition::findPartitions( devices, PartUtils::isEfiBootable );
|
= CalamaresUtils::Partition::findPartitions( devices, PartUtils::isEfiBootable );
|
||||||
|
|
||||||
if ( efiSystemPartitions.isEmpty() )
|
if ( efiSystemPartitions.isEmpty() )
|
||||||
|
{
|
||||||
cWarning() << "system is EFI but no EFI system partitions found.";
|
cWarning() << "system is EFI but no EFI system partitions found.";
|
||||||
|
}
|
||||||
|
|
||||||
m_efiSystemPartitions = efiSystemPartitions;
|
m_efiSystemPartitions = efiSystemPartitions;
|
||||||
}
|
}
|
||||||
@ -674,11 +709,13 @@ PartitionCoreModule::scanForLVMPVs()
|
|||||||
|
|
||||||
for ( DeviceInfo* deviceInfo : m_deviceInfos )
|
for ( DeviceInfo* deviceInfo : m_deviceInfos )
|
||||||
{
|
{
|
||||||
if ( deviceInfo->device.data()->type() == Device::Type::Disk_Device)
|
if ( deviceInfo->device.data()->type() == Device::Type::Disk_Device )
|
||||||
|
{
|
||||||
physicalDevices << deviceInfo->device.data();
|
physicalDevices << deviceInfo->device.data();
|
||||||
|
}
|
||||||
else if ( deviceInfo->device.data()->type() == Device::Type::LVM_Device )
|
else if ( deviceInfo->device.data()->type() == Device::Type::LVM_Device )
|
||||||
{
|
{
|
||||||
LvmDevice* device = dynamic_cast<LvmDevice*>(deviceInfo->device.data());
|
LvmDevice* device = dynamic_cast< LvmDevice* >( deviceInfo->device.data() );
|
||||||
|
|
||||||
// Restoring physical volume list
|
// Restoring physical volume list
|
||||||
device->physicalVolumes().clear();
|
device->physicalVolumes().clear();
|
||||||
@ -711,29 +748,35 @@ PartitionCoreModule::scanForLVMPVs()
|
|||||||
for ( auto job : d->jobs )
|
for ( auto job : d->jobs )
|
||||||
{
|
{
|
||||||
// Including new LVM PVs
|
// Including new LVM PVs
|
||||||
CreatePartitionJob* partJob = dynamic_cast<CreatePartitionJob*>( job.data() );
|
CreatePartitionJob* partJob = dynamic_cast< CreatePartitionJob* >( job.data() );
|
||||||
if ( partJob )
|
if ( partJob )
|
||||||
{
|
{
|
||||||
Partition* p = partJob->partition();
|
Partition* p = partJob->partition();
|
||||||
|
|
||||||
if ( p->fileSystem().type() == FileSystem::Type::Lvm2_PV )
|
if ( p->fileSystem().type() == FileSystem::Type::Lvm2_PV )
|
||||||
|
{
|
||||||
m_lvmPVs << p;
|
m_lvmPVs << p;
|
||||||
|
}
|
||||||
else if ( p->fileSystem().type() == FileSystem::Type::Luks )
|
else if ( p->fileSystem().type() == FileSystem::Type::Luks )
|
||||||
{
|
{
|
||||||
// Encrypted LVM PVs
|
// Encrypted LVM PVs
|
||||||
FileSystem* innerFS = static_cast<const FS::luks*>(&p->fileSystem())->innerFS();
|
FileSystem* innerFS = static_cast< const FS::luks* >( &p->fileSystem() )->innerFS();
|
||||||
|
|
||||||
if ( innerFS && innerFS->type() == FileSystem::Type::Lvm2_PV )
|
if ( innerFS && innerFS->type() == FileSystem::Type::Lvm2_PV )
|
||||||
|
{
|
||||||
m_lvmPVs << p;
|
m_lvmPVs << p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if defined( WITH_KPMCORE4API )
|
#if defined( WITH_KPMCORE4API )
|
||||||
else if ( p->fileSystem().type() == FileSystem::Type::Luks2 )
|
else if ( p->fileSystem().type() == FileSystem::Type::Luks2 )
|
||||||
{
|
{
|
||||||
// Encrypted LVM PVs
|
// Encrypted LVM PVs
|
||||||
FileSystem* innerFS = static_cast<const FS::luks*>(&p->fileSystem())->innerFS();
|
FileSystem* innerFS = static_cast< const FS::luks* >( &p->fileSystem() )->innerFS();
|
||||||
|
|
||||||
if ( innerFS && innerFS->type() == FileSystem::Type::Lvm2_PV )
|
if ( innerFS && innerFS->type() == FileSystem::Type::Lvm2_PV )
|
||||||
|
{
|
||||||
m_lvmPVs << p;
|
m_lvmPVs << p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -744,13 +787,16 @@ PartitionCoreModule::scanForLVMPVs()
|
|||||||
PartitionCoreModule::DeviceInfo*
|
PartitionCoreModule::DeviceInfo*
|
||||||
PartitionCoreModule::infoForDevice( const Device* device ) const
|
PartitionCoreModule::infoForDevice( const Device* device ) const
|
||||||
{
|
{
|
||||||
for ( auto it = m_deviceInfos.constBegin();
|
for ( auto it = m_deviceInfos.constBegin(); it != m_deviceInfos.constEnd(); ++it )
|
||||||
it != m_deviceInfos.constEnd(); ++it )
|
|
||||||
{
|
{
|
||||||
if ( ( *it )->device.data() == device )
|
if ( ( *it )->device.data() == device )
|
||||||
|
{
|
||||||
return *it;
|
return *it;
|
||||||
|
}
|
||||||
if ( ( *it )->immutableDevice.data() == device )
|
if ( ( *it )->immutableDevice.data() == device )
|
||||||
|
{
|
||||||
return *it;
|
return *it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -763,7 +809,9 @@ PartitionCoreModule::findPartitionByMountPoint( const QString& mountPoint ) cons
|
|||||||
Device* device = deviceInfo->device.data();
|
Device* device = deviceInfo->device.data();
|
||||||
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
|
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
|
||||||
if ( PartitionInfo::mountPoint( *it ) == mountPoint )
|
if ( PartitionInfo::mountPoint( *it ) == mountPoint )
|
||||||
|
{
|
||||||
return *it;
|
return *it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -780,7 +828,7 @@ PartitionCoreModule::initLayout()
|
|||||||
{
|
{
|
||||||
m_partLayout = new PartitionLayout();
|
m_partLayout = new PartitionLayout();
|
||||||
|
|
||||||
m_partLayout->addEntry( QString("/"), QString("100%") );
|
m_partLayout->addEntry( QString( "/" ), QString( "100%" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -796,42 +844,52 @@ PartitionCoreModule::initLayout( const QVariantList& config )
|
|||||||
{
|
{
|
||||||
QVariantMap pentry = r.toMap();
|
QVariantMap pentry = r.toMap();
|
||||||
|
|
||||||
if ( !pentry.contains( "name" ) || !pentry.contains( "mountPoint" ) ||
|
if ( !pentry.contains( "name" ) || !pentry.contains( "mountPoint" ) || !pentry.contains( "filesystem" )
|
||||||
!pentry.contains( "filesystem" ) || !pentry.contains( "size" ) )
|
|| !pentry.contains( "size" ) )
|
||||||
{
|
{
|
||||||
cError() << "Partition layout entry #" << config.indexOf(r)
|
cError() << "Partition layout entry #" << config.indexOf( r )
|
||||||
<< "lacks mandatory attributes, switching to default layout.";
|
<< "lacks mandatory attributes, switching to default layout.";
|
||||||
delete( m_partLayout );
|
delete ( m_partLayout );
|
||||||
initLayout();
|
initLayout();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pentry.contains("size") && CalamaresUtils::getString( pentry, "size" ).isEmpty() )
|
if ( pentry.contains( "size" ) && CalamaresUtils::getString( pentry, "size" ).isEmpty() )
|
||||||
|
{
|
||||||
sizeString.setNum( CalamaresUtils::getInteger( pentry, "size", 0 ) );
|
sizeString.setNum( CalamaresUtils::getInteger( pentry, "size", 0 ) );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
sizeString = CalamaresUtils::getString( pentry, "size" );
|
sizeString = CalamaresUtils::getString( pentry, "size" );
|
||||||
|
}
|
||||||
|
|
||||||
if ( pentry.contains("minSize") && CalamaresUtils::getString( pentry, "minSize" ).isEmpty() )
|
if ( pentry.contains( "minSize" ) && CalamaresUtils::getString( pentry, "minSize" ).isEmpty() )
|
||||||
|
{
|
||||||
minSizeString.setNum( CalamaresUtils::getInteger( pentry, "minSize", 0 ) );
|
minSizeString.setNum( CalamaresUtils::getInteger( pentry, "minSize", 0 ) );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
minSizeString = CalamaresUtils::getString( pentry, "minSize" );
|
minSizeString = CalamaresUtils::getString( pentry, "minSize" );
|
||||||
|
}
|
||||||
|
|
||||||
if ( pentry.contains("maxSize") && CalamaresUtils::getString( pentry, "maxSize" ).isEmpty() )
|
if ( pentry.contains( "maxSize" ) && CalamaresUtils::getString( pentry, "maxSize" ).isEmpty() )
|
||||||
|
{
|
||||||
maxSizeString.setNum( CalamaresUtils::getInteger( pentry, "maxSize", 0 ) );
|
maxSizeString.setNum( CalamaresUtils::getInteger( pentry, "maxSize", 0 ) );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
maxSizeString = CalamaresUtils::getString( pentry, "maxSize" );
|
maxSizeString = CalamaresUtils::getString( pentry, "maxSize" );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !m_partLayout->addEntry( CalamaresUtils::getString( pentry, "name" ),
|
if ( !m_partLayout->addEntry( CalamaresUtils::getString( pentry, "name" ),
|
||||||
CalamaresUtils::getString( pentry, "mountPoint" ),
|
CalamaresUtils::getString( pentry, "mountPoint" ),
|
||||||
CalamaresUtils::getString( pentry, "filesystem" ),
|
CalamaresUtils::getString( pentry, "filesystem" ),
|
||||||
sizeString,
|
sizeString,
|
||||||
minSizeString,
|
minSizeString,
|
||||||
maxSizeString
|
maxSizeString ) )
|
||||||
) )
|
|
||||||
{
|
{
|
||||||
cError() << "Partition layout entry #" << config.indexOf(r)
|
cError() << "Partition layout entry #" << config.indexOf( r ) << "is invalid, switching to default layout.";
|
||||||
<< "is invalid, switching to default layout.";
|
delete ( m_partLayout );
|
||||||
delete( m_partLayout );
|
|
||||||
initLayout();
|
initLayout();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -839,7 +897,7 @@ PartitionCoreModule::initLayout( const QVariantList& config )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionCoreModule::layoutApply( Device *dev,
|
PartitionCoreModule::layoutApply( Device* dev,
|
||||||
qint64 firstSector,
|
qint64 firstSector,
|
||||||
qint64 lastSector,
|
qint64 lastSector,
|
||||||
QString luksPassphrase,
|
QString luksPassphrase,
|
||||||
@ -847,17 +905,14 @@ PartitionCoreModule::layoutApply( Device *dev,
|
|||||||
const PartitionRole& role )
|
const PartitionRole& role )
|
||||||
{
|
{
|
||||||
bool isEfi = PartUtils::isEfiSystem();
|
bool isEfi = PartUtils::isEfiSystem();
|
||||||
QList< Partition* > partList = m_partLayout->execute( dev, firstSector, lastSector,
|
QList< Partition* > partList = m_partLayout->execute( dev, firstSector, lastSector, luksPassphrase, parent, role );
|
||||||
luksPassphrase, parent, role
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ( Partition *part, partList )
|
foreach ( Partition* part, partList )
|
||||||
{
|
{
|
||||||
if ( part->mountPoint() == "/" )
|
if ( part->mountPoint() == "/" )
|
||||||
{
|
{
|
||||||
createPartition( dev, part,
|
createPartition(
|
||||||
part->activeFlags() | ( isEfi ? KPM_PARTITION_FLAG(None) : KPM_PARTITION_FLAG(Boot) )
|
dev, part, part->activeFlags() | ( isEfi ? KPM_PARTITION_FLAG( None ) : KPM_PARTITION_FLAG( Boot ) ) );
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -867,14 +922,10 @@ PartitionCoreModule::layoutApply( Device *dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionCoreModule::layoutApply( Device *dev,
|
PartitionCoreModule::layoutApply( Device* dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase )
|
||||||
qint64 firstSector,
|
|
||||||
qint64 lastSector,
|
|
||||||
QString luksPassphrase )
|
|
||||||
{
|
{
|
||||||
layoutApply( dev, firstSector, lastSector, luksPassphrase, dev->partitionTable(),
|
layoutApply(
|
||||||
PartitionRole( PartitionRole::Primary )
|
dev, firstSector, lastSector, luksPassphrase, dev->partitionTable(), PartitionRole( PartitionRole::Primary ) );
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -895,13 +946,13 @@ PartitionCoreModule::revertAllDevices()
|
|||||||
for ( auto it = m_deviceInfos.begin(); it != m_deviceInfos.end(); )
|
for ( auto it = m_deviceInfos.begin(); it != m_deviceInfos.end(); )
|
||||||
{
|
{
|
||||||
// In new VGs device info, there will be always a CreateVolumeGroupJob as the first job in jobs list
|
// In new VGs device info, there will be always a CreateVolumeGroupJob as the first job in jobs list
|
||||||
if ( dynamic_cast<LvmDevice*>( ( *it )->device.data() ) )
|
if ( dynamic_cast< LvmDevice* >( ( *it )->device.data() ) )
|
||||||
{
|
{
|
||||||
( *it )->isAvailable = true;
|
( *it )->isAvailable = true;
|
||||||
|
|
||||||
if ( !( *it )->jobs.empty() )
|
if ( !( *it )->jobs.empty() )
|
||||||
{
|
{
|
||||||
CreateVolumeGroupJob* vgJob = dynamic_cast<CreateVolumeGroupJob*>( ( *it )->jobs[0].data() );
|
CreateVolumeGroupJob* vgJob = dynamic_cast< CreateVolumeGroupJob* >( ( *it )->jobs[ 0 ].data() );
|
||||||
|
|
||||||
if ( vgJob )
|
if ( vgJob )
|
||||||
{
|
{
|
||||||
@ -933,7 +984,9 @@ PartitionCoreModule::revertDevice( Device* dev, bool individualRevert )
|
|||||||
DeviceInfo* devInfo = infoForDevice( dev );
|
DeviceInfo* devInfo = infoForDevice( dev );
|
||||||
|
|
||||||
if ( !devInfo )
|
if ( !devInfo )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
devInfo->forgetChanges();
|
devInfo->forgetChanges();
|
||||||
CoreBackend* backend = CoreBackendManager::self()->backend();
|
CoreBackend* backend = CoreBackendManager::self()->backend();
|
||||||
Device* newDev = backend->scanDevice( devInfo->device->deviceNode() );
|
Device* newDev = backend->scanDevice( devInfo->device->deviceNode() );
|
||||||
@ -946,13 +999,17 @@ PartitionCoreModule::revertDevice( Device* dev, bool individualRevert )
|
|||||||
for ( DeviceInfo* const info : m_deviceInfos )
|
for ( DeviceInfo* const info : m_deviceInfos )
|
||||||
{
|
{
|
||||||
if ( info && !info->device.isNull() && info->device->type() == Device::Type::Disk_Device )
|
if ( info && !info->device.isNull() && info->device->type() == Device::Type::Disk_Device )
|
||||||
|
{
|
||||||
devices.append( info->device.data() );
|
devices.append( info->device.data() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bootLoaderModel->init( devices );
|
m_bootLoaderModel->init( devices );
|
||||||
|
|
||||||
if ( individualRevert )
|
if ( individualRevert )
|
||||||
|
{
|
||||||
refreshAfterModelChange();
|
refreshAfterModelChange();
|
||||||
|
}
|
||||||
emit deviceReverted( newDev );
|
emit deviceReverted( newDev );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -961,9 +1018,7 @@ void
|
|||||||
PartitionCoreModule::asyncRevertDevice( Device* dev, std::function< void() > callback )
|
PartitionCoreModule::asyncRevertDevice( Device* dev, std::function< void() > callback )
|
||||||
{
|
{
|
||||||
QFutureWatcher< void >* watcher = new QFutureWatcher< void >();
|
QFutureWatcher< void >* watcher = new QFutureWatcher< void >();
|
||||||
connect( watcher, &QFutureWatcher< void >::finished,
|
connect( watcher, &QFutureWatcher< void >::finished, this, [watcher, callback] {
|
||||||
this, [ watcher, callback ]
|
|
||||||
{
|
|
||||||
callback();
|
callback();
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
} );
|
} );
|
||||||
@ -977,7 +1032,9 @@ void
|
|||||||
PartitionCoreModule::clearJobs()
|
PartitionCoreModule::clearJobs()
|
||||||
{
|
{
|
||||||
foreach ( DeviceInfo* deviceInfo, m_deviceInfos )
|
foreach ( DeviceInfo* deviceInfo, m_deviceInfos )
|
||||||
|
{
|
||||||
deviceInfo->forgetChanges();
|
deviceInfo->forgetChanges();
|
||||||
|
}
|
||||||
updateIsDirty();
|
updateIsDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -989,11 +1046,13 @@ PartitionCoreModule::isDirty()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PartitionCoreModule::isVGdeactivated( LvmDevice *device )
|
PartitionCoreModule::isVGdeactivated( LvmDevice* device )
|
||||||
{
|
{
|
||||||
for ( DeviceInfo* deviceInfo : m_deviceInfos )
|
for ( DeviceInfo* deviceInfo : m_deviceInfos )
|
||||||
if ( device == deviceInfo->device.data() && !deviceInfo->isAvailable )
|
if ( device == deviceInfo->device.data() && !deviceInfo->isAvailable )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1005,7 +1064,9 @@ PartitionCoreModule::createSummaryInfo() const
|
|||||||
for ( auto deviceInfo : m_deviceInfos )
|
for ( auto deviceInfo : m_deviceInfos )
|
||||||
{
|
{
|
||||||
if ( !deviceInfo->isDirty() )
|
if ( !deviceInfo->isDirty() )
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
SummaryInfo summaryInfo;
|
SummaryInfo summaryInfo;
|
||||||
summaryInfo.deviceName = deviceInfo->device->name();
|
summaryInfo.deviceName = deviceInfo->device->name();
|
||||||
summaryInfo.deviceNode = deviceInfo->device->deviceNode();
|
summaryInfo.deviceNode = deviceInfo->device->deviceNode();
|
||||||
|
@ -139,10 +139,10 @@ public:
|
|||||||
* If @p flags is not FlagNone, then the given flags are
|
* If @p flags is not FlagNone, then the given flags are
|
||||||
* applied to the newly-created partition.
|
* applied to the newly-created partition.
|
||||||
*/
|
*/
|
||||||
void createPartition( Device* device, Partition* partition,
|
void
|
||||||
PartitionTable::Flags flags = KPM_PARTITION_FLAG(None) );
|
createPartition( Device* device, Partition* partition, PartitionTable::Flags flags = KPM_PARTITION_FLAG( None ) );
|
||||||
|
|
||||||
void createVolumeGroup( QString &vgName, QVector< const Partition* > pvList, qint32 peSize );
|
void createVolumeGroup( QString& vgName, QVector< const Partition* > pvList, qint32 peSize );
|
||||||
|
|
||||||
void resizeVolumeGroup( LvmDevice* device, QVector< const Partition* >& pvList );
|
void resizeVolumeGroup( LvmDevice* device, QVector< const Partition* >& pvList );
|
||||||
|
|
||||||
@ -166,8 +166,13 @@ public:
|
|||||||
void initLayout();
|
void initLayout();
|
||||||
void initLayout( const QVariantList& config );
|
void initLayout( const QVariantList& config );
|
||||||
|
|
||||||
void layoutApply( Device *dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase );
|
void layoutApply( Device* dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase );
|
||||||
void layoutApply( Device *dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase, PartitionNode* parent, const PartitionRole& role );
|
void layoutApply( Device* dev,
|
||||||
|
qint64 firstSector,
|
||||||
|
qint64 lastSector,
|
||||||
|
QString luksPassphrase,
|
||||||
|
PartitionNode* parent,
|
||||||
|
const PartitionRole& role );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief jobs creates and returns a list of jobs which can then apply the changes
|
* @brief jobs creates and returns a list of jobs which can then apply the changes
|
||||||
@ -196,19 +201,19 @@ public:
|
|||||||
*/
|
*/
|
||||||
Partition* findPartitionByMountPoint( const QString& mountPoint ) const;
|
Partition* findPartitionByMountPoint( const QString& mountPoint ) const;
|
||||||
|
|
||||||
void revert(); // full revert, thread safe, calls doInit
|
void revert(); // full revert, thread safe, calls doInit
|
||||||
void revertAllDevices(); // convenience function, calls revertDevice
|
void revertAllDevices(); // convenience function, calls revertDevice
|
||||||
/** @brief rescans a single Device and updates DeviceInfo
|
/** @brief rescans a single Device and updates DeviceInfo
|
||||||
*
|
*
|
||||||
* When @p individualRevert is true, calls refreshAfterModelChange(),
|
* When @p individualRevert is true, calls refreshAfterModelChange(),
|
||||||
* used to reduce number of refreshes when calling revertAllDevices().
|
* used to reduce number of refreshes when calling revertAllDevices().
|
||||||
*/
|
*/
|
||||||
void revertDevice( Device* dev, bool individualRevert=true );
|
void revertDevice( Device* dev, bool individualRevert = true );
|
||||||
void asyncRevertDevice( Device* dev, std::function< void() > callback ); //like revertDevice, but asynchronous
|
void asyncRevertDevice( Device* dev, std::function< void() > callback ); //like revertDevice, but asynchronous
|
||||||
|
|
||||||
void clearJobs(); // only clear jobs, the Device* states are preserved
|
void clearJobs(); // only clear jobs, the Device* states are preserved
|
||||||
|
|
||||||
bool isDirty(); // true if there are pending changes, otherwise false
|
bool isDirty(); // true if there are pending changes, otherwise false
|
||||||
|
|
||||||
bool isVGdeactivated( LvmDevice* device );
|
bool isVGdeactivated( LvmDevice* device );
|
||||||
|
|
||||||
@ -225,9 +230,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
QList< SummaryInfo > createSummaryInfo() const;
|
QList< SummaryInfo > createSummaryInfo() const;
|
||||||
|
|
||||||
void dumpQueue() const; // debug output
|
void dumpQueue() const; // debug output
|
||||||
|
|
||||||
const OsproberEntryList osproberEntries() const; // os-prober data structure, cached
|
const OsproberEntryList osproberEntries() const; // os-prober data structure, cached
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void hasRootMountPointChanged( bool value );
|
void hasRootMountPointChanged( bool value );
|
||||||
|
@ -57,15 +57,19 @@ setFormat( Partition* partition, bool value )
|
|||||||
partition->setProperty( FORMAT_PROPERTY, value );
|
partition->setProperty( FORMAT_PROPERTY, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
PartitionTable::Flags flags(const Partition* partition)
|
PartitionTable::Flags
|
||||||
|
flags( const Partition* partition )
|
||||||
{
|
{
|
||||||
auto v = partition->property( FLAGS_PROPERTY );
|
auto v = partition->property( FLAGS_PROPERTY );
|
||||||
if (v.type() == QVariant::Int )
|
if ( v.type() == QVariant::Int )
|
||||||
return static_cast<PartitionTable::Flags>( v.toInt() );
|
{
|
||||||
|
return static_cast< PartitionTable::Flags >( v.toInt() );
|
||||||
|
}
|
||||||
return partition->activeFlags();
|
return partition->activeFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFlags(Partition* partition, PartitionTable::Flags f)
|
void
|
||||||
|
setFlags( Partition* partition, PartitionTable::Flags f )
|
||||||
{
|
{
|
||||||
partition->setProperty( FLAGS_PROPERTY, PartitionTable::Flags::Int( f ) );
|
partition->setProperty( FLAGS_PROPERTY, PartitionTable::Flags::Int( f ) );
|
||||||
}
|
}
|
||||||
@ -82,11 +86,11 @@ bool
|
|||||||
isDirty( Partition* partition )
|
isDirty( Partition* partition )
|
||||||
{
|
{
|
||||||
if ( LvmDevice::s_DirtyPVs.contains( partition ) )
|
if ( LvmDevice::s_DirtyPVs.contains( partition ) )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return !mountPoint( partition ).isEmpty()
|
return !mountPoint( partition ).isEmpty() || format( partition ) || flags( partition ) != partition->activeFlags();
|
||||||
|| format( partition )
|
|
||||||
|| flags( partition ) != partition->activeFlags();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace PartitionInfo
|
||||||
|
@ -60,6 +60,6 @@ void reset( Partition* partition );
|
|||||||
*/
|
*/
|
||||||
bool isDirty( Partition* partition );
|
bool isDirty( Partition* partition );
|
||||||
|
|
||||||
};
|
}; // namespace PartitionInfo
|
||||||
|
|
||||||
#endif /* PARTITIONINFO_H */
|
#endif /* PARTITIONINFO_H */
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
#include "core/PartitionLayout.h"
|
#include "core/PartitionLayout.h"
|
||||||
|
|
||||||
#include "core/KPMHelpers.h"
|
#include "core/KPMHelpers.h"
|
||||||
|
#include "core/PartUtils.h"
|
||||||
#include "core/PartitionActions.h"
|
#include "core/PartitionActions.h"
|
||||||
#include "core/PartitionInfo.h"
|
#include "core/PartitionInfo.h"
|
||||||
#include "core/PartUtils.h"
|
|
||||||
|
|
||||||
#include <kpmcore/core/device.h>
|
#include <kpmcore/core/device.h>
|
||||||
#include <kpmcore/core/partition.h>
|
#include <kpmcore/core/partition.h>
|
||||||
@ -42,9 +42,11 @@ getDefaultFileSystemType()
|
|||||||
|
|
||||||
if ( gs->contains( "defaultFileSystemType" ) )
|
if ( gs->contains( "defaultFileSystemType" ) )
|
||||||
{
|
{
|
||||||
PartUtils::findFS( gs->value( "defaultFileSystemType" ).toString(), &defaultFS);
|
PartUtils::findFS( gs->value( "defaultFileSystemType" ).toString(), &defaultFS );
|
||||||
if ( defaultFS == FileSystem::Unknown )
|
if ( defaultFS == FileSystem::Unknown )
|
||||||
|
{
|
||||||
defaultFS = FileSystem::Ext4;
|
defaultFS = FileSystem::Ext4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return defaultFS;
|
return defaultFS;
|
||||||
@ -67,9 +69,7 @@ PartitionLayout::PartitionLayout( const PartitionLayout& layout )
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PartitionLayout::~PartitionLayout()
|
PartitionLayout::~PartitionLayout() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PartitionLayout::addEntry( PartitionLayout::PartitionEntry entry )
|
PartitionLayout::addEntry( PartitionLayout::PartitionEntry entry )
|
||||||
@ -117,7 +117,12 @@ PartitionLayout::addEntry( const QString& mountPoint, const QString& size, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PartitionLayout::addEntry( const QString& label, const QString& mountPoint, const QString& fs, const QString& size, const QString& min, const QString& max )
|
PartitionLayout::addEntry( const QString& label,
|
||||||
|
const QString& mountPoint,
|
||||||
|
const QString& fs,
|
||||||
|
const QString& size,
|
||||||
|
const QString& min,
|
||||||
|
const QString& max )
|
||||||
{
|
{
|
||||||
PartitionLayout::PartitionEntry entry( size, min, max );
|
PartitionLayout::PartitionEntry entry( size, min, max );
|
||||||
|
|
||||||
@ -136,7 +141,9 @@ PartitionLayout::addEntry( const QString& label, const QString& mountPoint, cons
|
|||||||
entry.partMountPoint = mountPoint;
|
entry.partMountPoint = mountPoint;
|
||||||
PartUtils::findFS( fs, &entry.partFileSystem );
|
PartUtils::findFS( fs, &entry.partFileSystem );
|
||||||
if ( entry.partFileSystem == FileSystem::Unknown )
|
if ( entry.partFileSystem == FileSystem::Unknown )
|
||||||
|
{
|
||||||
entry.partFileSystem = m_defaultFsType;
|
entry.partFileSystem = m_defaultFsType;
|
||||||
|
}
|
||||||
|
|
||||||
m_partLayout.append( entry );
|
m_partLayout.append( entry );
|
||||||
|
|
||||||
@ -144,8 +151,10 @@ PartitionLayout::addEntry( const QString& label, const QString& mountPoint, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
QList< Partition* >
|
QList< Partition* >
|
||||||
PartitionLayout::execute( Device *dev, qint64 firstSector,
|
PartitionLayout::execute( Device* dev,
|
||||||
qint64 lastSector, QString luksPassphrase,
|
qint64 firstSector,
|
||||||
|
qint64 lastSector,
|
||||||
|
QString luksPassphrase,
|
||||||
PartitionNode* parent,
|
PartitionNode* parent,
|
||||||
const PartitionRole& role )
|
const PartitionRole& role )
|
||||||
{
|
{
|
||||||
@ -157,9 +166,9 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
|
|||||||
// TODO: Refine partition sizes to make sure there is room for every partition
|
// TODO: Refine partition sizes to make sure there is room for every partition
|
||||||
// Use a default (200-500M ?) minimum size for partition without minSize
|
// Use a default (200-500M ?) minimum size for partition without minSize
|
||||||
|
|
||||||
foreach( const PartitionLayout::PartitionEntry& part, m_partLayout )
|
foreach ( const PartitionLayout::PartitionEntry& part, m_partLayout )
|
||||||
{
|
{
|
||||||
Partition *currentPartition = nullptr;
|
Partition* currentPartition = nullptr;
|
||||||
|
|
||||||
qint64 size = -1;
|
qint64 size = -1;
|
||||||
// Calculate partition size
|
// Calculate partition size
|
||||||
@ -169,67 +178,67 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cWarning() << "Partition" << part.partMountPoint << "size ("
|
cWarning() << "Partition" << part.partMountPoint << "size (" << size << "sectors) is invalid, skipping...";
|
||||||
<< size << "sectors) is invalid, skipping...";
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( part.partMinSize.isValid() )
|
if ( part.partMinSize.isValid() )
|
||||||
|
{
|
||||||
minSize = part.partMinSize.toSectors( totalSize, dev->logicalSize() );
|
minSize = part.partMinSize.toSectors( totalSize, dev->logicalSize() );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
minSize = 0;
|
minSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ( part.partMaxSize.isValid() )
|
if ( part.partMaxSize.isValid() )
|
||||||
|
{
|
||||||
maxSize = part.partMaxSize.toSectors( totalSize, dev->logicalSize() );
|
maxSize = part.partMaxSize.toSectors( totalSize, dev->logicalSize() );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
maxSize = availableSize;
|
maxSize = availableSize;
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure we never go under minSize once converted to sectors
|
// Make sure we never go under minSize once converted to sectors
|
||||||
if ( maxSize < minSize )
|
if ( maxSize < minSize )
|
||||||
{
|
{
|
||||||
cWarning() << "Partition" << part.partMountPoint << "max size (" << maxSize
|
cWarning() << "Partition" << part.partMountPoint << "max size (" << maxSize << "sectors) is < min size ("
|
||||||
<< "sectors) is < min size (" << minSize << "sectors), using min size";
|
<< minSize << "sectors), using min size";
|
||||||
maxSize = minSize;
|
maxSize = minSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust partition size based on user-defined boundaries and available space
|
// Adjust partition size based on user-defined boundaries and available space
|
||||||
if ( size < minSize )
|
if ( size < minSize )
|
||||||
|
{
|
||||||
size = minSize;
|
size = minSize;
|
||||||
|
}
|
||||||
if ( size > maxSize )
|
if ( size > maxSize )
|
||||||
|
{
|
||||||
size = maxSize;
|
size = maxSize;
|
||||||
|
}
|
||||||
if ( size > availableSize )
|
if ( size > availableSize )
|
||||||
|
{
|
||||||
size = availableSize;
|
size = availableSize;
|
||||||
|
}
|
||||||
end = firstSector + size - 1;
|
end = firstSector + size - 1;
|
||||||
|
|
||||||
if ( luksPassphrase.isEmpty() )
|
if ( luksPassphrase.isEmpty() )
|
||||||
{
|
{
|
||||||
currentPartition = KPMHelpers::createNewPartition(
|
currentPartition = KPMHelpers::createNewPartition(
|
||||||
parent,
|
parent, *dev, role, part.partFileSystem, firstSector, end, KPM_PARTITION_FLAG( None ) );
|
||||||
*dev,
|
|
||||||
role,
|
|
||||||
part.partFileSystem,
|
|
||||||
firstSector,
|
|
||||||
end,
|
|
||||||
KPM_PARTITION_FLAG(None)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
currentPartition = KPMHelpers::createNewEncryptedPartition(
|
currentPartition = KPMHelpers::createNewEncryptedPartition(
|
||||||
parent,
|
parent, *dev, role, part.partFileSystem, firstSector, end, luksPassphrase, KPM_PARTITION_FLAG( None ) );
|
||||||
*dev,
|
|
||||||
role,
|
|
||||||
part.partFileSystem,
|
|
||||||
firstSector,
|
|
||||||
end,
|
|
||||||
luksPassphrase,
|
|
||||||
KPM_PARTITION_FLAG(None)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
PartitionInfo::setFormat( currentPartition, true );
|
PartitionInfo::setFormat( currentPartition, true );
|
||||||
PartitionInfo::setMountPoint( currentPartition, part.partMountPoint );
|
PartitionInfo::setMountPoint( currentPartition, part.partMountPoint );
|
||||||
if ( !part.partLabel.isEmpty() )
|
if ( !part.partLabel.isEmpty() )
|
||||||
|
{
|
||||||
currentPartition->fileSystem().setLabel( part.partLabel );
|
currentPartition->fileSystem().setLabel( part.partLabel );
|
||||||
|
}
|
||||||
// Some buggy (legacy) BIOSes test if the bootflag of at least one partition is set.
|
// Some buggy (legacy) BIOSes test if the bootflag of at least one partition is set.
|
||||||
// Otherwise they ignore the device in boot-order, so add it here.
|
// Otherwise they ignore the device in boot-order, so add it here.
|
||||||
partList.append( currentPartition );
|
partList.append( currentPartition );
|
||||||
|
@ -37,7 +37,6 @@ class Partition;
|
|||||||
class PartitionLayout
|
class PartitionLayout
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct PartitionEntry
|
struct PartitionEntry
|
||||||
{
|
{
|
||||||
QString partLabel;
|
QString partLabel;
|
||||||
@ -54,9 +53,11 @@ public:
|
|||||||
|
|
||||||
bool isValid() const
|
bool isValid() const
|
||||||
{
|
{
|
||||||
if ( !partSize.isValid() ||
|
if ( !partSize.isValid()
|
||||||
( partMinSize.isValid() && partMaxSize.isValid() && partMinSize > partMaxSize ) )
|
|| ( partMinSize.isValid() && partMaxSize.isValid() && partMinSize > partMaxSize ) )
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -67,14 +68,27 @@ public:
|
|||||||
~PartitionLayout();
|
~PartitionLayout();
|
||||||
|
|
||||||
bool addEntry( PartitionEntry entry );
|
bool addEntry( PartitionEntry entry );
|
||||||
bool addEntry( const QString& mountPoint, const QString& size, const QString& min = QString(), const QString& max = QString() );
|
bool addEntry( const QString& mountPoint,
|
||||||
bool addEntry( const QString& label, const QString& mountPoint, const QString& fs, const QString& size, const QString& min = QString(), const QString& max = QString() );
|
const QString& size,
|
||||||
|
const QString& min = QString(),
|
||||||
|
const QString& max = QString() );
|
||||||
|
bool addEntry( const QString& label,
|
||||||
|
const QString& mountPoint,
|
||||||
|
const QString& fs,
|
||||||
|
const QString& size,
|
||||||
|
const QString& min = QString(),
|
||||||
|
const QString& max = QString() );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Apply the current partition layout to the selected drive space.
|
* @brief Apply the current partition layout to the selected drive space.
|
||||||
* @return A list of Partition objects.
|
* @return A list of Partition objects.
|
||||||
*/
|
*/
|
||||||
QList< Partition* > execute( Device *dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase, PartitionNode* parent, const PartitionRole& role );
|
QList< Partition* > execute( Device* dev,
|
||||||
|
qint64 firstSector,
|
||||||
|
qint64 lastSector,
|
||||||
|
QString luksPassphrase,
|
||||||
|
PartitionNode* parent,
|
||||||
|
const PartitionRole& role );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FileSystem::Type m_defaultFsType;
|
FileSystem::Type m_defaultFsType;
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
#include "core/PartitionModel.h"
|
#include "core/PartitionModel.h"
|
||||||
|
|
||||||
#include "core/ColorUtils.h"
|
#include "core/ColorUtils.h"
|
||||||
#include "core/PartitionInfo.h"
|
|
||||||
#include "core/KPMHelpers.h"
|
#include "core/KPMHelpers.h"
|
||||||
|
#include "core/PartitionInfo.h"
|
||||||
|
|
||||||
#include "partition/FileSystem.h"
|
#include "partition/FileSystem.h"
|
||||||
#include "partition/PartitionQuery.h"
|
#include "partition/PartitionQuery.h"
|
||||||
@ -67,9 +67,9 @@ PartitionModel::PartitionModel( QObject* parent )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionModel::init( Device* device , const OsproberEntryList& osproberEntries )
|
PartitionModel::init( Device* device, const OsproberEntryList& osproberEntries )
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&m_lock);
|
QMutexLocker lock( &m_lock );
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_device = device;
|
m_device = device;
|
||||||
m_osproberEntries = osproberEntries;
|
m_osproberEntries = osproberEntries;
|
||||||
@ -87,7 +87,9 @@ PartitionModel::rowCount( const QModelIndex& parent ) const
|
|||||||
{
|
{
|
||||||
Partition* parentPartition = partitionForIndex( parent );
|
Partition* parentPartition = partitionForIndex( parent );
|
||||||
if ( parentPartition )
|
if ( parentPartition )
|
||||||
|
{
|
||||||
return parentPartition->children().count();
|
return parentPartition->children().count();
|
||||||
|
}
|
||||||
PartitionTable* table = m_device->partitionTable();
|
PartitionTable* table = m_device->partitionTable();
|
||||||
return table ? table->children().count() : 0;
|
return table ? table->children().count() : 0;
|
||||||
}
|
}
|
||||||
@ -95,16 +97,21 @@ PartitionModel::rowCount( const QModelIndex& parent ) const
|
|||||||
QModelIndex
|
QModelIndex
|
||||||
PartitionModel::index( int row, int column, const QModelIndex& parent ) const
|
PartitionModel::index( int row, int column, const QModelIndex& parent ) const
|
||||||
{
|
{
|
||||||
PartitionNode* parentPartition = parent.isValid()
|
PartitionNode* parentPartition = parent.isValid() ? static_cast< PartitionNode* >( partitionForIndex( parent ) )
|
||||||
? static_cast< PartitionNode* >( partitionForIndex( parent ) )
|
: static_cast< PartitionNode* >( m_device->partitionTable() );
|
||||||
: static_cast< PartitionNode* >( m_device->partitionTable() );
|
|
||||||
if ( !parentPartition )
|
if ( !parentPartition )
|
||||||
|
{
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
auto lst = parentPartition->children();
|
auto lst = parentPartition->children();
|
||||||
if ( row < 0 || row >= lst.count() )
|
if ( row < 0 || row >= lst.count() )
|
||||||
|
{
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
if ( column < 0 || column >= ColumnCount )
|
if ( column < 0 || column >= ColumnCount )
|
||||||
|
{
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
Partition* partition = parentPartition->children().at( row );
|
Partition* partition = parentPartition->children().at( row );
|
||||||
return createIndex( row, column, partition );
|
return createIndex( row, column, partition );
|
||||||
}
|
}
|
||||||
@ -113,19 +120,27 @@ QModelIndex
|
|||||||
PartitionModel::parent( const QModelIndex& child ) const
|
PartitionModel::parent( const QModelIndex& child ) const
|
||||||
{
|
{
|
||||||
if ( !child.isValid() )
|
if ( !child.isValid() )
|
||||||
|
{
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
Partition* partition = partitionForIndex( child );
|
Partition* partition = partitionForIndex( child );
|
||||||
if ( !partition )
|
if ( !partition )
|
||||||
|
{
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
PartitionNode* parentNode = partition->parent();
|
PartitionNode* parentNode = partition->parent();
|
||||||
if ( parentNode == m_device->partitionTable() )
|
if ( parentNode == m_device->partitionTable() )
|
||||||
|
{
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
for ( auto p : m_device->partitionTable()->children() )
|
for ( auto p : m_device->partitionTable()->children() )
|
||||||
{
|
{
|
||||||
if ( parentNode == p )
|
if ( parentNode == p )
|
||||||
|
{
|
||||||
return createIndex( row, 0, parentNode );
|
return createIndex( row, 0, parentNode );
|
||||||
|
}
|
||||||
++row;
|
++row;
|
||||||
}
|
}
|
||||||
cWarning() << "No parent found!";
|
cWarning() << "No parent found!";
|
||||||
@ -137,7 +152,9 @@ PartitionModel::data( const QModelIndex& index, int role ) const
|
|||||||
{
|
{
|
||||||
Partition* partition = partitionForIndex( index );
|
Partition* partition = partitionForIndex( index );
|
||||||
if ( !partition )
|
if ( !partition )
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
switch ( role )
|
switch ( role )
|
||||||
{
|
{
|
||||||
@ -147,18 +164,22 @@ PartitionModel::data( const QModelIndex& index, int role ) const
|
|||||||
if ( col == NameColumn )
|
if ( col == NameColumn )
|
||||||
{
|
{
|
||||||
if ( isPartitionFreeSpace( partition ) )
|
if ( isPartitionFreeSpace( partition ) )
|
||||||
|
{
|
||||||
return tr( "Free Space" );
|
return tr( "Free Space" );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return isPartitionNew( partition )
|
return isPartitionNew( partition ) ? tr( "New partition" ) : partition->partitionPath();
|
||||||
? tr( "New partition" )
|
|
||||||
: partition->partitionPath();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( col == FileSystemColumn )
|
if ( col == FileSystemColumn )
|
||||||
|
{
|
||||||
return CalamaresUtils::Partition::prettyNameForFileSystemType( partition->fileSystem().type() );
|
return CalamaresUtils::Partition::prettyNameForFileSystemType( partition->fileSystem().type() );
|
||||||
|
}
|
||||||
if ( col == MountPointColumn )
|
if ( col == MountPointColumn )
|
||||||
|
{
|
||||||
return PartitionInfo::mountPoint( partition );
|
return PartitionInfo::mountPoint( partition );
|
||||||
|
}
|
||||||
if ( col == SizeColumn )
|
if ( col == SizeColumn )
|
||||||
{
|
{
|
||||||
qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSize();
|
qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSize();
|
||||||
@ -169,9 +190,13 @@ PartitionModel::data( const QModelIndex& index, int role ) const
|
|||||||
}
|
}
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
if ( index.column() == NameColumn )
|
if ( index.column() == NameColumn )
|
||||||
|
{
|
||||||
return ColorUtils::colorForPartition( partition );
|
return ColorUtils::colorForPartition( partition );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
{
|
{
|
||||||
int col = index.column();
|
int col = index.column();
|
||||||
@ -179,18 +204,19 @@ PartitionModel::data( const QModelIndex& index, int role ) const
|
|||||||
if ( col == NameColumn )
|
if ( col == NameColumn )
|
||||||
{
|
{
|
||||||
if ( isPartitionFreeSpace( partition ) )
|
if ( isPartitionFreeSpace( partition ) )
|
||||||
|
{
|
||||||
name = tr( "Free Space" );
|
name = tr( "Free Space" );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
name = isPartitionNew( partition )
|
name = isPartitionNew( partition ) ? tr( "New partition" ) : partition->partitionPath();
|
||||||
? tr( "New partition" )
|
|
||||||
: partition->partitionPath();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QString prettyFileSystem = CalamaresUtils::Partition::prettyNameForFileSystemType( partition->fileSystem().type() );
|
QString prettyFileSystem
|
||||||
|
= CalamaresUtils::Partition::prettyNameForFileSystemType( partition->fileSystem().type() );
|
||||||
qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSize();
|
qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSize();
|
||||||
QString prettySize = KFormat().formatByteSize( size );
|
QString prettySize = KFormat().formatByteSize( size );
|
||||||
return QVariant(name + " " + prettyFileSystem + " " + prettySize);
|
return QVariant( name + " " + prettyFileSystem + " " + prettySize );
|
||||||
}
|
}
|
||||||
case SizeRole:
|
case SizeRole:
|
||||||
return ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSize();
|
return ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSize();
|
||||||
@ -201,9 +227,11 @@ PartitionModel::data( const QModelIndex& index, int role ) const
|
|||||||
return isPartitionNew( partition );
|
return isPartitionNew( partition );
|
||||||
|
|
||||||
case FileSystemLabelRole:
|
case FileSystemLabelRole:
|
||||||
if ( partition->fileSystem().supportGetLabel() != FileSystem::cmdSupportNone &&
|
if ( partition->fileSystem().supportGetLabel() != FileSystem::cmdSupportNone
|
||||||
!partition->fileSystem().label().isEmpty() )
|
&& !partition->fileSystem().label().isEmpty() )
|
||||||
|
{
|
||||||
return partition->fileSystem().label();
|
return partition->fileSystem().label();
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
case FileSystemTypeRole:
|
case FileSystemTypeRole:
|
||||||
@ -218,40 +246,45 @@ PartitionModel::data( const QModelIndex& index, int role ) const
|
|||||||
// Osprober roles:
|
// Osprober roles:
|
||||||
case OsproberNameRole:
|
case OsproberNameRole:
|
||||||
foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
|
foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
|
||||||
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone &&
|
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone
|
||||||
!partition->fileSystem().uuid().isEmpty() &&
|
&& !partition->fileSystem().uuid().isEmpty() && osproberEntry.uuid == partition->fileSystem().uuid() )
|
||||||
osproberEntry.uuid == partition->fileSystem().uuid() )
|
{
|
||||||
return osproberEntry.prettyName;
|
return osproberEntry.prettyName;
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
case OsproberPathRole:
|
case OsproberPathRole:
|
||||||
foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
|
foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
|
||||||
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone &&
|
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone
|
||||||
!partition->fileSystem().uuid().isEmpty() &&
|
&& !partition->fileSystem().uuid().isEmpty() && osproberEntry.uuid == partition->fileSystem().uuid() )
|
||||||
osproberEntry.uuid == partition->fileSystem().uuid() )
|
{
|
||||||
return osproberEntry.path;
|
return osproberEntry.path;
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
case OsproberCanBeResizedRole:
|
case OsproberCanBeResizedRole:
|
||||||
foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
|
foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
|
||||||
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone &&
|
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone
|
||||||
!partition->fileSystem().uuid().isEmpty() &&
|
&& !partition->fileSystem().uuid().isEmpty() && osproberEntry.uuid == partition->fileSystem().uuid() )
|
||||||
osproberEntry.uuid == partition->fileSystem().uuid() )
|
{
|
||||||
return osproberEntry.canBeResized;
|
return osproberEntry.canBeResized;
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
case OsproberRawLineRole:
|
case OsproberRawLineRole:
|
||||||
foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
|
foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
|
||||||
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone &&
|
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone
|
||||||
!partition->fileSystem().uuid().isEmpty() &&
|
&& !partition->fileSystem().uuid().isEmpty() && osproberEntry.uuid == partition->fileSystem().uuid() )
|
||||||
osproberEntry.uuid == partition->fileSystem().uuid() )
|
{
|
||||||
return osproberEntry.line;
|
return osproberEntry.line;
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
case OsproberHomePartitionPathRole:
|
case OsproberHomePartitionPathRole:
|
||||||
foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
|
foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
|
||||||
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone &&
|
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone
|
||||||
!partition->fileSystem().uuid().isEmpty() &&
|
&& !partition->fileSystem().uuid().isEmpty() && osproberEntry.uuid == partition->fileSystem().uuid() )
|
||||||
osproberEntry.uuid == partition->fileSystem().uuid() )
|
{
|
||||||
return osproberEntry.homePath;
|
return osproberEntry.homePath;
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
// end Osprober roles.
|
// end Osprober roles.
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -262,7 +295,9 @@ QVariant
|
|||||||
PartitionModel::headerData( int section, Qt::Orientation, int role ) const
|
PartitionModel::headerData( int section, Qt::Orientation, int role ) const
|
||||||
{
|
{
|
||||||
if ( role != Qt::DisplayRole )
|
if ( role != Qt::DisplayRole )
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
switch ( section )
|
switch ( section )
|
||||||
{
|
{
|
||||||
@ -283,9 +318,11 @@ PartitionModel::headerData( int section, Qt::Orientation, int role ) const
|
|||||||
Partition*
|
Partition*
|
||||||
PartitionModel::partitionForIndex( const QModelIndex& index ) const
|
PartitionModel::partitionForIndex( const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&m_lock);
|
QMutexLocker lock( &m_lock );
|
||||||
if ( !index.isValid() )
|
if ( !index.isValid() )
|
||||||
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
return reinterpret_cast< Partition* >( index.internalPointer() );
|
return reinterpret_cast< Partition* >( index.internalPointer() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ public:
|
|||||||
|
|
||||||
ResetHelper( const ResetHelper& ) = delete;
|
ResetHelper( const ResetHelper& ) = delete;
|
||||||
ResetHelper& operator=( const ResetHelper& ) = delete;
|
ResetHelper& operator=( const ResetHelper& ) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PartitionModel* m_model;
|
PartitionModel* m_model;
|
||||||
};
|
};
|
||||||
@ -75,7 +76,7 @@ public:
|
|||||||
FileSystemLabelRole,
|
FileSystemLabelRole,
|
||||||
FileSystemTypeRole,
|
FileSystemTypeRole,
|
||||||
PartitionPathRole,
|
PartitionPathRole,
|
||||||
PartitionPtrRole, // passed as void*, use sparingly
|
PartitionPtrRole, // passed as void*, use sparingly
|
||||||
OsproberNameRole,
|
OsproberNameRole,
|
||||||
OsproberPathRole,
|
OsproberPathRole,
|
||||||
OsproberCanBeResizedRole,
|
OsproberCanBeResizedRole,
|
||||||
@ -89,7 +90,7 @@ public:
|
|||||||
FileSystemColumn,
|
FileSystemColumn,
|
||||||
MountPointColumn,
|
MountPointColumn,
|
||||||
SizeColumn,
|
SizeColumn,
|
||||||
ColumnCount // Must remain last
|
ColumnCount // Must remain last
|
||||||
};
|
};
|
||||||
|
|
||||||
PartitionModel( QObject* parent = nullptr );
|
PartitionModel( QObject* parent = nullptr );
|
||||||
@ -108,10 +109,7 @@ public:
|
|||||||
|
|
||||||
Partition* partitionForIndex( const QModelIndex& index ) const;
|
Partition* partitionForIndex( const QModelIndex& index ) const;
|
||||||
|
|
||||||
Device* device() const
|
Device* device() const { return m_device; }
|
||||||
{
|
|
||||||
return m_device;
|
|
||||||
}
|
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user