Exemplo n.º 1
0
void
PartitionCoreModule::init()
{
    CoreBackend* backend = CoreBackendManager::self()->backend();
    auto devices = backend->scanDevices();

    // Remove the device which contains / from the list
    for ( auto it = devices.begin(); it != devices.end(); )
        if ( hasRootPartition( *it ) )
            it = devices.erase( it );
        else
            ++it;

    for ( auto device : devices )
    {
        auto deviceInfo = new DeviceInfo( device );
        m_deviceInfos << deviceInfo;

        deviceInfo->partitionModel->init( device );
    }
    m_deviceModel->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
}
Exemplo n.º 2
0
void
PartitionCoreModule::init()
{
    CoreBackend* backend = CoreBackendManager::self()->backend();
    auto devices = backend->scanDevices( true );

    // Remove the device which contains / from the list
    for ( auto it = devices.begin(); it != devices.end(); )
        if ( hasRootPartition( *it ) )
            it = devices.erase( it );
        else
            ++it;

    for ( auto device : devices )
    {
        auto deviceInfo = new DeviceInfo( device );
        m_deviceInfos << deviceInfo;
    }
    m_deviceModel->init( devices );

    // The following PartUtils::runOsprober call in turn calls PartUtils::canBeResized,
    // which relies on a working DeviceModel.
    m_osproberLines = PartUtils::runOsprober( this );

    for ( auto deviceInfo : m_deviceInfos )
    {
        deviceInfo->partitionModel->init( deviceInfo->device.data(), m_osproberLines );
    }

    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
}
Exemplo n.º 3
0
void
PartitionCoreModule::doInit()
{
    FileSystemFactory::init();

    using DeviceList = QList< Device* >;

    CoreBackend* backend = CoreBackendManager::self()->backend();
    DeviceList devices = backend->scanDevices( true );

    cDebug() << "Winnowing" << devices.count() << "devices.";

    // Remove the device which contains / from the list
    for ( DeviceList::iterator it = devices.begin(); it != devices.end(); )
        if ( ! (*it) || hasRootPartition( *it ) ||
             (*it)->deviceNode().startsWith( "/dev/zram") ||
             isIso9660( *it ) )
        {
            cDebug() << "  .. Winnowing" << ( (*it) ? (*it)->deviceNode() : QString( "<null device>" ) );
            it = devices.erase( it );
        }
        else
            ++it;

    cDebug() << "LIST OF DETECTED DEVICES:";
    cDebug() << "node\tcapacity\tname\tprettyName";
    for ( auto device : devices )
    {
        auto deviceInfo = new DeviceInfo( device );
        m_deviceInfos << deviceInfo;
        cDebug() << device->deviceNode() << device->capacity() << device->name() << device->prettyName();
    }
    cDebug() << ".." << devices.count() << "devices detected.";
    m_deviceModel->init( devices );

    // The following PartUtils::runOsprober call in turn calls PartUtils::canBeResized,
    // which relies on a working DeviceModel.
    m_osproberLines = PartUtils::runOsprober( this );

    // We perform a best effort of filling out filesystem UUIDs in m_osproberLines
    // because we will need them later on in PartitionModel if partition paths
    // change.
    // It is a known fact that /dev/sda1-style device paths aren't persistent
    // across reboots (and this doesn't affect us), but partition numbers can also
    // change at runtime against our will just for shits and giggles.
    // But why would that ever happen? What system could possibly be so poorly
    // designed that it requires a partition path rearrangement at runtime?
    // Logical partitions on an MSDOS disklabel of course.
    // See DeletePartitionJob::updatePreview.
    for ( auto deviceInfo : m_deviceInfos )
    {
        for ( auto it = PartitionIterator::begin( deviceInfo->device.data() );
              it != PartitionIterator::end( deviceInfo->device.data() ); ++it )
        {
            Partition* partition = *it;
            for ( auto jt = m_osproberLines.begin();
                  jt != m_osproberLines.end(); ++jt )
            {
                if ( jt->path == partition->partitionPath() &&
                     partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone &&
                     !partition->fileSystem().uuid().isEmpty() )
                {
                    jt->uuid = partition->fileSystem().uuid();
                }
            }
        }
    }

    for ( auto deviceInfo : m_deviceInfos )
    {
        deviceInfo->partitionModel->init( deviceInfo->device.data(), m_osproberLines );
    }

    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
}