Add EFI System Partition scanning support to PartitionCoreModule.
This commit is contained in:
parent
67b96f750a
commit
f4a13b2041
@ -47,6 +47,8 @@
|
|||||||
|
|
||||||
// Qt
|
// Qt
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
hasRootPartition( Device* device )
|
hasRootPartition( Device* device )
|
||||||
@ -124,6 +126,10 @@ PartitionCoreModule::init()
|
|||||||
m_deviceModel->init( devices );
|
m_deviceModel->init( devices );
|
||||||
|
|
||||||
m_bootLoaderModel->init( devices );
|
m_bootLoaderModel->init( devices );
|
||||||
|
|
||||||
|
if ( QDir( "/sys/firmware/efi/efivars" ).exists() )
|
||||||
|
scanForEfiSystemPartitions(); //FIXME: this should be removed in favor of
|
||||||
|
// proper KPM support for EFI
|
||||||
}
|
}
|
||||||
|
|
||||||
PartitionCoreModule::~PartitionCoreModule()
|
PartitionCoreModule::~PartitionCoreModule()
|
||||||
@ -327,6 +333,12 @@ PartitionCoreModule::hasRootMountPoint() const
|
|||||||
return m_hasRootMountPoint;
|
return m_hasRootMountPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList< Partition* >
|
||||||
|
PartitionCoreModule::efiSystemPartitions() const
|
||||||
|
{
|
||||||
|
return m_efiSystemPartitions;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionCoreModule::dumpQueue() const
|
PartitionCoreModule::dumpQueue() const
|
||||||
{
|
{
|
||||||
@ -384,6 +396,52 @@ PartitionCoreModule::updateIsDirty()
|
|||||||
isDirtyChanged( m_isDirty );
|
isDirtyChanged( m_isDirty );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PartitionCoreModule::scanForEfiSystemPartitions()
|
||||||
|
{
|
||||||
|
m_efiSystemPartitions.clear();
|
||||||
|
|
||||||
|
QList< Device* > devices;
|
||||||
|
for ( int row = 0; row < deviceModel()->rowCount(); ++row )
|
||||||
|
{
|
||||||
|
Device* device = deviceModel()->deviceForIndex(
|
||||||
|
deviceModel()->index( row ) );
|
||||||
|
devices.append( device );
|
||||||
|
}
|
||||||
|
|
||||||
|
//FIXME: Unfortunately right now we have to call sgdisk manually because
|
||||||
|
// the KPM submodule does not expose the ESP flag from libparted.
|
||||||
|
// The following findPartitions call and lambda should be scrapped and
|
||||||
|
// rewritten based on libKPM. -- Teo 5/2015
|
||||||
|
QList< Partition* > efiSystemPartitions =
|
||||||
|
PMUtils::findPartitions( devices,
|
||||||
|
[]( Partition* partition ) -> bool
|
||||||
|
{
|
||||||
|
QProcess process;
|
||||||
|
process.setProgram( "sgdisk" );
|
||||||
|
process.setArguments( { "-i",
|
||||||
|
QString::number( partition->number() ),
|
||||||
|
partition->devicePath() } );
|
||||||
|
process.setProcessChannelMode( QProcess::MergedChannels );
|
||||||
|
process.start();
|
||||||
|
if ( process.waitForFinished() )
|
||||||
|
{
|
||||||
|
if ( process.readAllStandardOutput()
|
||||||
|
.contains( "C12A7328-F81F-11D2-BA4B-00A0C93EC93B" ) )
|
||||||
|
{
|
||||||
|
cDebug() << "Found EFI system partition at" << partition->partitionPath();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} );
|
||||||
|
|
||||||
|
if ( efiSystemPartitions.isEmpty() )
|
||||||
|
cDebug() << "WARNING: system is EFI but no EFI system partitions found.";
|
||||||
|
|
||||||
|
m_efiSystemPartitions = efiSystemPartitions;
|
||||||
|
}
|
||||||
|
|
||||||
PartitionCoreModule::DeviceInfo*
|
PartitionCoreModule::DeviceInfo*
|
||||||
PartitionCoreModule::infoForDevice( Device* device ) const
|
PartitionCoreModule::infoForDevice( Device* device ) const
|
||||||
{
|
{
|
||||||
|
@ -91,6 +91,8 @@ public:
|
|||||||
|
|
||||||
bool hasRootMountPoint() const;
|
bool hasRootMountPoint() const;
|
||||||
|
|
||||||
|
QList< Partition* > efiSystemPartitions() const;
|
||||||
|
|
||||||
void revert();
|
void revert();
|
||||||
|
|
||||||
void clearJobs();
|
void clearJobs();
|
||||||
@ -134,6 +136,7 @@ private:
|
|||||||
bool isDirty() const;
|
bool isDirty() const;
|
||||||
};
|
};
|
||||||
QList< DeviceInfo* > m_deviceInfos;
|
QList< DeviceInfo* > m_deviceInfos;
|
||||||
|
QList< Partition* > m_efiSystemPartitions;
|
||||||
|
|
||||||
DeviceModel* m_deviceModel;
|
DeviceModel* m_deviceModel;
|
||||||
BootLoaderModel* m_bootLoaderModel;
|
BootLoaderModel* m_bootLoaderModel;
|
||||||
@ -144,6 +147,7 @@ private:
|
|||||||
void init();
|
void init();
|
||||||
void updateHasRootMountPoint();
|
void updateHasRootMountPoint();
|
||||||
void updateIsDirty();
|
void updateIsDirty();
|
||||||
|
void scanForEfiSystemPartitions();
|
||||||
|
|
||||||
DeviceInfo* infoForDevice( Device* ) const;
|
DeviceInfo* infoForDevice( Device* ) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user