API Changes, logicalSectorSize -> logicalSize, totalSectors -> totalLogical.

This commit is contained in:
Chantara Tith 2016-08-31 10:30:45 +07:00 committed by Philip
parent 8882a477be
commit ff86874d66
6 changed files with 15 additions and 15 deletions

View File

@ -128,11 +128,11 @@ doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPass
empty_space_size = 1; empty_space_size = 1;
} }
qint64 firstFreeSector = empty_space_size MiB / dev->logicalSectorSize() + 1; qint64 firstFreeSector = empty_space_size MiB / dev->logicalSize() + 1;
if ( isEfi ) if ( isEfi )
{ {
qint64 lastSector = firstFreeSector + ( uefisys_part_size MiB / dev->logicalSectorSize() ); qint64 lastSector = firstFreeSector + ( uefisys_part_size MiB / dev->logicalSize() );
core->createPartitionTable( dev, PartitionTable::gpt ); core->createPartitionTable( dev, PartitionTable::gpt );
Partition* efiPartition = KPMHelpers::createNewPartition( Partition* efiPartition = KPMHelpers::createNewPartition(
dev->partitionTable(), dev->partitionTable(),
@ -157,7 +157,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPass
} }
bool shouldCreateSwap = false; bool shouldCreateSwap = false;
qint64 availableSpaceB = ( dev->totalSectors() - firstFreeSector ) * dev->logicalSectorSize(); qint64 availableSpaceB = ( dev->totalLogical() - firstFreeSector ) * dev->logicalSize();
qint64 suggestedSwapSizeB = swapSuggestion( availableSpaceB ); qint64 suggestedSwapSizeB = swapSuggestion( availableSpaceB );
qint64 requiredSpaceB = qint64 requiredSpaceB =
( Calamares::JobQueue::instance()-> ( Calamares::JobQueue::instance()->
@ -168,10 +168,10 @@ doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPass
// If there is enough room for ESP + root + swap, create swap, otherwise don't. // If there is enough room for ESP + root + swap, create swap, otherwise don't.
shouldCreateSwap = availableSpaceB > requiredSpaceB; shouldCreateSwap = availableSpaceB > requiredSpaceB;
qint64 lastSectorForRoot = dev->totalSectors() - 1; //last sector of the device qint64 lastSectorForRoot = dev->totalLogical() - 1; //last sector of the device
if ( shouldCreateSwap ) if ( shouldCreateSwap )
{ {
lastSectorForRoot -= suggestedSwapSizeB / dev->logicalSectorSize() + 1; lastSectorForRoot -= suggestedSwapSizeB / dev->logicalSize() + 1;
} }
Partition* rootPartition = nullptr; Partition* rootPartition = nullptr;
@ -213,7 +213,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPass
PartitionRole( PartitionRole::Primary ), PartitionRole( PartitionRole::Primary ),
FileSystem::LinuxSwap, FileSystem::LinuxSwap,
lastSectorForRoot + 1, lastSectorForRoot + 1,
dev->totalSectors() - 1 dev->totalLogical() - 1
); );
} }
else else
@ -224,7 +224,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPass
PartitionRole( PartitionRole::Primary ), PartitionRole( PartitionRole::Primary ),
FileSystem::LinuxSwap, FileSystem::LinuxSwap,
lastSectorForRoot + 1, lastSectorForRoot + 1,
dev->totalSectors() - 1, dev->totalLogical() - 1,
luksPassphrase luksPassphrase
); );
} }

View File

@ -148,7 +148,7 @@ PartitionModel::data( const QModelIndex& index, int role ) const
return PartitionInfo::mountPoint( partition ); return PartitionInfo::mountPoint( partition );
if ( col == SizeColumn ) if ( col == SizeColumn )
{ {
qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSectorSize(); qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSize();
return KFormat().formatByteSize( size ); return KFormat().formatByteSize( size );
} }
cDebug() << "Unknown column" << col; cDebug() << "Unknown column" << col;
@ -175,12 +175,12 @@ PartitionModel::data( const QModelIndex& index, int role ) const
} }
} }
QString prettyFileSystem = KPMHelpers::prettyNameForFileSystemType( partition->fileSystem().type() ); QString prettyFileSystem = KPMHelpers::prettyNameForFileSystemType( partition->fileSystem().type() );
qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSectorSize(); 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->logicalSectorSize(); return ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSize();
case IsFreeSpaceRole: case IsFreeSpaceRole:
return KPMHelpers::isPartitionFreeSpace( partition ); return KPMHelpers::isPartitionFreeSpace( partition );

View File

@ -594,7 +594,7 @@ ChoicePage::doAlongsideApply()
qint64 oldLastSector = candidate->lastSector(); qint64 oldLastSector = candidate->lastSector();
qint64 newLastSector = firstSector + qint64 newLastSector = firstSector +
m_afterPartitionSplitterWidget->splitPartitionSize() / m_afterPartitionSplitterWidget->splitPartitionSize() /
dev->logicalSectorSize(); dev->logicalSize();
m_core->resizePartition( dev, candidate, firstSector, newLastSector ); m_core->resizePartition( dev, candidate, firstSector, newLastSector );
Partition* newPartition = nullptr; Partition* newPartition = nullptr;

View File

@ -47,7 +47,7 @@ QStringList
buildUnknownDisklabelTexts( Device* dev ) buildUnknownDisklabelTexts( Device* dev )
{ {
QStringList texts = { QObject::tr( "Unpartitioned space or unknown partition table" ), QStringList texts = { QObject::tr( "Unpartitioned space or unknown partition table" ),
KFormat().formatByteSize( dev->totalSectors() * dev->logicalSectorSize() ) }; KFormat().formatByteSize( dev->totalLogical() * dev->logicalSize() ) };
return texts; return texts;
} }

View File

@ -135,7 +135,7 @@ PartitionSizeController::updatePartResizerWidget()
return; return;
m_updating = true; m_updating = true;
qint64 sectorSize = qint64( m_spinBox->value() ) * 1024 * 1024 / m_device->logicalSectorSize(); qint64 sectorSize = qint64( m_spinBox->value() ) * 1024 * 1024 / m_device->logicalSize();
qint64 firstSector = m_partition->firstSector(); qint64 firstSector = m_partition->firstSector();
qint64 lastSector = firstSector + sectorSize - 1; qint64 lastSector = firstSector + sectorSize - 1;
@ -185,7 +185,7 @@ PartitionSizeController::doUpdateSpinBox()
{ {
if ( !m_spinBox ) if ( !m_spinBox )
return; return;
qint64 mbSize = m_partition->length() * m_device->logicalSectorSize() / 1024 / 1024; qint64 mbSize = m_partition->length() * m_device->logicalSize() / 1024 / 1024;
m_spinBox->setValue( mbSize ); m_spinBox->setValue( mbSize );
if ( m_currentSpinBoxValue != -1 && //if it's not the first time we're setting it if ( m_currentSpinBoxValue != -1 && //if it's not the first time we're setting it
m_currentSpinBoxValue != mbSize ) //and the operation changes the SB value m_currentSpinBoxValue != mbSize ) //and the operation changes the SB value

View File

@ -93,7 +93,7 @@ public:
break; break;
case FileSystem::cmdSupportFileSystem: case FileSystem::cmdSupportFileSystem:
{ {
qint64 byteLength = m_device->logicalSectorSize() * m_length; qint64 byteLength = m_device->logicalSize() * m_length;
bool ok = fs.resize( report, m_partition->partitionPath(), byteLength ); bool ok = fs.resize( report, m_partition->partitionPath(), byteLength );
if ( !ok ) if ( !ok )
return Calamares::JobResult::error( return Calamares::JobResult::error(