Logo Search packages:      
Sourcecode: partitionmanager version File versions  Download package

static void scanDevicePartitions ( PedDevice *  pedDevice,
Device d,
PedDisk *  pedDisk,
QMap< QString, QStringList > &  mountInfo 
) [static]

Scans a Device for Partitions.

This function will scan a Device for all Partitions on it, detect the FileSystem for each Partition, try to determine the FileSystem usage, read the FileSystem label and store it all in newly created objects that are in the end added to the Device's PartitionTable.

Parameters:
pedDevice libparted pointer to the device
d Device
pedDisk libparted pointer to the disk label
mountInfo map of mount points

Definition at line 177 of file libparted.cpp.

References PartitionNode::append(), FileSystemFactory::create(), Job::detectFileSystem(), Partition::deviceNode(), PartitionRole::Extended, PartitionNode::findPartitionBySector(), PartitionTable::isSnapped(), PartitionRole::Logical, PartitionRole::None, Device::partitionTable(), PartitionRole::Primary, FileSystem::readLabel(), readSectorsUsed(), FileSystem::readUUID(), FileSystem::setLabel(), FileSystem::setUUID(), FileSystem::SupportExternal, FileSystem::supportGetLabel(), FileSystem::supportGetUUID(), and PartitionTable::updateUnallocated().

Referenced by LibParted::scanDevices().

{
      Q_ASSERT(pedDevice);
      Q_ASSERT(pedDisk);
      Q_ASSERT(d.partitionTable());

      PedPartition* pedPartition = NULL;

      while ((pedPartition = ped_disk_next_partition(pedDisk, pedPartition)))
      {
            if (pedPartition->num < 1)
                  continue;

            PartitionRole::Roles r = PartitionRole::None;
            FileSystem::Type type = Job::detectFileSystem(pedDevice, pedPartition);

            switch(pedPartition->type)
            {
                  case PED_PARTITION_NORMAL:
                        r = PartitionRole::Primary;
                        break;

                  case PED_PARTITION_EXTENDED:
                        r = PartitionRole::Extended;
                        type = FileSystem::Extended;
                        break;

                  case PED_PARTITION_LOGICAL:
                        r = PartitionRole::Logical;
                        break;

                  default:
                        continue;
            }

            // Find an extended partition this partition is in.
            PartitionNode* parent = d.partitionTable()->findPartitionBySector(pedPartition->geom.start, PartitionRole(PartitionRole::Extended));

            // None found, so it's a primary in the device's partition table.
            if (parent == NULL)
                  parent = d.partitionTable();

            const QString node = pedDisk->dev->path + QString::number(pedPartition->num);
            FileSystem* fs = FileSystemFactory::create(type, pedPartition->geom.start, pedPartition->geom.end);

            Partition* part = new Partition(parent, d, PartitionRole(r), fs, pedPartition->geom.start, pedPartition->geom.end,
                        pedPartition->num, SetPartFlagsJob::availableFlags(pedPartition),
                        mountInfo[node], ped_partition_is_busy(pedPartition), SetPartFlagsJob::activeFlags(pedPartition));

            readSectorsUsed(pedDisk, *part, mountInfo);

            if (fs->supportGetLabel() == FileSystem::SupportExternal)
                  fs->setLabel(fs->readLabel(part->deviceNode()));

            if (fs->supportGetUUID() == FileSystem::SupportExternal)
                  fs->setUUID(fs->readUUID(part->deviceNode()));

            parent->append(part);

            PartitionTable::isSnapped(d, *part);
      }

      d.partitionTable()->updateUnallocated(d);

      ped_disk_destroy(pedDisk);
}


Generated by  Doxygen 1.6.0   Back to index